rescript-immutable-js
v0.1.0
Published
The `rescript-immutable-js` package provides ReScript bindings for the Immutable.js library.
Readme
ReScript Project Template
The rescript-immutable-js package provides ReScript bindings for the Immutable.js library.
Usage Examples
ImmutableList
open ImmutableList
// Create a new list
let myList = make([1, 2, 3])
// Add elements to the list
let updatedList = myList->push(4)->pushN(5, 6)
// Concatenate lists
let anotherList = make([6, 7, 8])
let combinedList = updatedList->concat(anotherList)
// Access elements
let thirdElement = combinedList.get(2)
// Filter elements
let evenNumbers = combinedList.filter(num => num mod 2 == 0)
// Convert to array
let arrayResult = evenNumbers.toArray()ImmutableMap
open ImmutableMap
// Create a new map
let myMap = make({
key1: "value1",
key2: "value2"
})
// Set a new key-value pair
let updatedMap = myMap->set("key3", "value3")
// Get a value
let value = updatedMap.get("key2")
// Map over key-value pairs
let upperCaseMap = updatedMap->map((k, v) => v->Js.String2.toUpperCase)
// Convert to object
let objResult = upperCaseMap.toObject()Installation
npm install rescript-immutable-js
pnpm add rescript-immutable-js
bun add rescript-immutable-js
deno add npm:rescript-immutable-jsDevelopment
- Build:
pnpm run res:build - Clean:
pnpm run res:clean - Build & watch:
pnpm run res:dev
License
MIT License
