LoginSignup
5
2

More than 5 years have passed since last update.

reduxでimmutablejsつかうならicepickがあるよ

Last updated at Posted at 2017-03-16

npmのページ

これはなに?

immutablejsでできることを、ただの関数にしたもの。
underscoreやlodashと同じような気分で使える。

サイトままですが。

import i from 'icepick'

const coll = {
  a: 'foo',
  b: [1, 2, 3],
  c: { d: 'bar' }
}

const newColl = i.assocIn(coll, ['c', 'd'], 'baz')

assert(newColl.c.d === 'baz')
assert(newColl.b === coll.b)

const coll = {}
const newColl = i.assocIn(coll, ['a', 'b', 'c'], 1)
assert(newColl.a.b.c === 1)
5
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
2