Given a constructor and a value, returns a new instance of that constructor containing the value — the applicative “pure” / of helper. Part of Ramda Function since v0.3.0 (stable — not deprecated).
Warning: Since Ramda v0.29.0, R.of is binary: R.of(Ctor, val). Old unary R.of(42) no longer returns [42] — it returns a function waiting for a value. Use R.of(Array, 42).
Syntax
Call R.of. Start with this line.
Ramda
R.of(Ctor, val) or R.of(Ctor)(val)
Call
What it does
R.of(Ctor, val) or R.of(Ctor)(val)
Primary signature.
R.of(...)
Call the function helper.
Prefer import { of } from "ramda" when you want a named import.
Library declarations
Ramda
R.of(Ctor, val) or R.of(Ctor)(val)
Parameters
Parameter
Description
Ctor
Required. Constructor / type with an of method (preferred)
val
Required. Any value to wrap
Return Value
Return Value
Description
*
Instance of Ctor wrapping val (or [val])
Ramda Examples
Example 1 — Official: Wrap with Array
Put a single value into an array using the constructor form.
Unary call.R.of(42) only fills the constructor slot → a function.
Complete call.R.of(Array, 10) wraps one value.
ES6 Array.of. Accepts many arguments; see the Array.of tutorial.
Docs note. Ramda’s of is not the same as ES6 of.
Compatibility
Browser & Runtime Support
R.of is a Ramda Function helper since v0.3.0. The current binary signature (Ctor, then val) applies from v0.29.0. It runs anywhere modern Ramda runs — browsers (CDN or bundle) and Node.js / Bun / Deno.
✓ Stable · Binary since 0.29.0
R.of()
Available in full Ramda builds. Prefer Ramda 0.29+ so R.of(Array, val) matches current docs. Works in evergreen browsers and current Node LTS when Ramda is loaded.
100%With Ramda 0.29+
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.ofRamda 0.29.0+ API
Bottom line: Safe for production on Ramda 0.29+. On older Ramda, unary R.of(x) meant [x] — migrate to R.of(Array, x). Official reference: ramdajs.com/docs/#of.
Frequently Asked Questions
R.of(Ctor, val) returns a new instance of Ctor that contains val. It tries Ctor['fantasy-land/of'] first, then Ctor.of, and if neither exists it wraps val in an array: [val]. Added in v0.3.0. Since v0.29.0 it is binary: constructor first, value second.
Array.of can take many arguments: Array.of(10, 20) is [10, 20]. R.of always wraps one value, and the constructor is an argument: R.of(Array, 10) is [10]. They are different functions. See MDN Array.of.
Before Ramda 0.29.0, R.of(x) always returned [x]. Now R.of is curried with two slots, so R.of(42) is a function waiting for a value. Write R.of(Array, 42) to wrap 42 in an array.
Yes. R.of(Array, 42) and R.of(Array)(42) are the same. R.of(Array) is a reusable wrapper you can pass to map.
No. R.of is a stable Ramda Function helper from v0.3.0. The binary constructor signature is the current API from v0.29.0. It is not deprecated, experimental, or non-standard.