2.2.0 • Published 10 years ago

grovel v2.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
10 years ago

grovel

js-standard-style Build Status Coverage Status Maintainer status

Disclaimer: this library is tailor-made for another project. No attempt will be made to spin it into its own project / PRs with new features will be ignored.

A collection of utilities to handle almost-immutable data.

The idea is to be able to do oldState === newState or oldState.a.b.c === newState.a.b.c rather than _.isEqual. Hence, assocIn generates a lot of shallow copies. Oh well.

Usage

The recommended way to use grovel is to use babel with function binding, which allows you to write code like this:

import {assocIn, getIn} from 'grovel'

function doSomething () {
  const a = {}::assocIn(['earth', 'france', 'cheese'], 'camembert')
  const france = a::getIn(['earth', 'france'])
  assert.same(france, {cheese: 'camembert'})

  const b = a::assocIn(['earth', 'england', 'cheese'], 'cheddar')
  assert.same(england, {cheese: 'cheddar'})

  const france2 = b::getIn(['earth', 'france'])
  assert(france2 === france)
}

However, grovel/core exports regular old functions, if that's more your style.

2.2.0

10 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.5.0

10 years ago

1.3.0

10 years ago

1.2.0

10 years ago

1.1.0

10 years ago