Returns Native Types
Real Array/Object/Map/Set - not custom wrappers like Immutable.js. Works everywhere. Zero learning curve. 100% library compatible.
Returns native JavaScript types. Immutability faster than mutation. Zero learning curve.
import { produce } from '@sylphx/pura'
// Returns real Array - use it anywhere!
const state = [1, 2, 3]
const next = produce(state, draft => {
draft.push(4)
draft[0] = 999
})
// next is a real Array
next[0] // â
works - it's a real Array
next instanceof Array // â
true
await api.send(next) // â
works with any library
// Objects - returns real Object
const user = { name: 'John', age: 30 }
const updated = produce(user, draft => {
draft.age = 31
})
// Maps & Sets - returns real Map/Set
const map = new Map([['a', 1]])
const newMap = produce(map, draft => {
draft.set('b', 2)
})
newMap.get('b') // â
works - it's a real Map1.06-105x faster across all scenarios. Structural sharing for arrays/maps/sets (Immer only does objects).
O(log n) vs O(n). Updating element 500 in a 10K array:
Returns native types (Immutable.js uses custom List/Map wrappers). Zero learning curve. Use result[0] not result.get(0). Works with any library expecting native types.
| Scenario | Immer | Pura | Speedup |
|---|---|---|---|
| Sets (1K) | 2.31K ops/s | 243K ops/s | 105x faster ð |
| Maps (1K) | 2.08K ops/s | 25.1K ops/s | 12x faster ð |
| Objects (Deep) | 681K ops/s | 1.70M ops/s | 2.5x faster â |
| Arrays (100) | 0.87M ops/s | 4.63M ops/s | 5.3x faster â |
npm install @sylphx/pura
# or
bun add @sylphx/pura
# or
pnpm add @sylphx/pura