Skip to content
A library for manipulating nested data in a way reminiscent of MongoDB's "Update Operators" work (eg. `$set`, `$unset`, `$push` and `$inc`)".
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.gitignore
.jshintrc
LICENSE
README.md
bower.json
index.js
index.umd.js
package.json
test.html

README.md

Manip

A library for manipulating nested data in a way reminiscent of MongoDB's "Update Operators" work (eg. $set, $unset, $push and $inc)".

The following operations are current supported:

  • $set
  • $unset
  • $push
  • $inc

Given a set of data, sometimes you want to be able to be able to modify deeply nested data without hard coding the path to that data or worring if the sub sub subdocument you want to add to already exists.

Take the following example:

var jack = {
	eyes: 'blue',
	car: {
		ford: {
			wheels: 4,
			age: 3,
			color: 'blue'
		}
	}
};

I could increase the age of the car by one year

manip(jack, {'$inc': {'car.ford.age': 1}}));

and now the data is:

{
	eyes: 'blue',
	car: {
		ford: {
			wheels: 4,
			age: 4,
			color: 'blue'
		}
	}
}

Source Code

Source code is prepared using Browserify which is also compatible with Node.JS. There is a UMD bundle which can be used with AMD or a vanilla browser (where it will export a global called manip.

You can’t perform that action at this time.