R.once(fn) returns a wrapper that runs fnonly the first time you call it. Later calls return that first result and skip fn entirely — even if the arguments change.
Stable:R.once has been in Ramda since v0.1.0. It is not deprecated, experimental, or non-standard. For per-argument caching, use R.memoizeWith instead.
Syntax
Call R.once. Start with this line.
Ramda
R.once(fn)
Call
What it does
R.once(fn)
Primary signature.
R.once(...)
Call the function helper.
Prefer import { once } from "ramda" when you want a named import.
Library declarations
Ramda
R.once(fn)
Parameters
Parameter
Description
fn
Required. Function to guard (runs at most once)
Return Value
Return Value
Description
*
Wrapper with the same call shape as fn
Ramda Examples
Example 1 — Official addOneOnce
Add one on the first call. The nested second line still returns that first 11.
Singleton.initA() creates one object and reuses it.
Same reference.initA() === initA() is true.
Separate latch.initB does not share state with initA.
Trap. Do not write R.once(boot)() at every call site — that boots again every time.
Compatibility
Browser & Runtime Support
R.once is a Ramda Function helper since v0.1.0. It is plain JavaScript — no special browser API. It runs anywhere Ramda loads (CDN, npm, bundler).
✓ Stable · Ramda 0.1.0+
R.once()
Available in every Ramda full build since the earliest releases. Works in evergreen browsers and current Node LTS / Bun / Deno when Ramda is installed.
100%With Ramda 0.1+
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
R.onceRamda 0.1.0+
Bottom line: Safe for production once Ramda is loaded. Use a CDN build such as ramda.min.js in the browser, or npm install ramda for Node. No polyfill is needed beyond shipping Ramda itself.
Frequently Asked Questions
R.once(fn) returns a new function. The first time you call it, it runs fn and remembers the return value. Every later call returns that same value and does not run fn again, even if the arguments change. Added in v0.1.0.
addOneOnce = R.once(x => x + 1); addOneOnce(10) //=> 11. Then addOneOnce(addOneOnce(50)) //=> 11 because the first result is already stored and later arguments are ignored.
once stores one result for the whole wrapper, no matter which arguments arrive later. memoizeWith stores a result per cache key, so different arguments can still compute different values.
No. After the first successful call, arguments are ignored. addOneOnce(10) is 11; addOneOnce(50) is still 11.
No. Each call to R.once(fn) builds a fresh wrapper with its own called flag and result. Reuse the function once returned. Calling R.once(fn) again starts a new first run.
No. R.once is a stable Ramda Function helper from v0.1.0. It is not deprecated, experimental, or non-standard.