Menu

gitpiper

Immutable.js Cheat Sheet in April 2024

Last Updated: 7 April 2024

README.md

Maps

var map = Immutable.Map({ a: 1, b: 2, c: 3 })
map
  .set('b', 50)
  .get('b') // 50

Lists

var list = Immutable.List.of(1, 2)

list
  .push(3, 4, 5)
  .unshift(0)
  .concat(list2, list3)
  .get(0)
  .size

Nested maps

var nested = Immutable.fromJS({ user: { profile: { name: 'John' } } })

nested
  // Update
  .mergeDeep({ user: { profile: { age: 90 } } })
  .setIn([ 'user', 'profile', 'name' ], 'Jack')
  .updateIn([ 'user', 'profile', 'name' ], (s) => s.toUpperCase())

  // Get
  .getIn(['user', 'profile', 'name']) // 'JACK'

338+ more cheat sheets for you in April 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️