Update full example in readme
This commit is contained in:
parent
78c30e038a
commit
8d0f389106
40
README.md
40
README.md
@ -33,11 +33,15 @@ supports [partial application][currying], so the parameter order is:
|
|||||||
var u = require('updeep');
|
var u = require('updeep');
|
||||||
|
|
||||||
var person = {
|
var person = {
|
||||||
name: {
|
name: { first: 'Bill', last: 'Sagat' },
|
||||||
first: 'Bill',
|
children: [
|
||||||
last: 'Sagat',
|
{ name: 'Mary-Kate', age: 7 },
|
||||||
},
|
{ name: 'Ashley', age: 7 }
|
||||||
children: ['Marty', 'Ashley'],
|
],
|
||||||
|
todo: [
|
||||||
|
'Be funny',
|
||||||
|
'Manage household'
|
||||||
|
],
|
||||||
email: 'bill@example.com',
|
email: 'bill@example.com',
|
||||||
version: 1
|
version: 1
|
||||||
};
|
};
|
||||||
@ -45,20 +49,26 @@ var person = {
|
|||||||
var inc = function(i) { return i + 1; }
|
var inc = function(i) { return i + 1; }
|
||||||
|
|
||||||
var newPerson = u({
|
var newPerson = u({
|
||||||
name: {
|
// Change first name
|
||||||
first: 'Bob',
|
name: { first: 'Bob' },
|
||||||
},
|
// Increment all children's ages
|
||||||
children: { 0: 'Mary-Kate' },
|
children: u.map({ age: inc }),
|
||||||
|
// Update email
|
||||||
email: 'bob@example.com',
|
email: 'bob@example.com',
|
||||||
|
// Remove todo
|
||||||
|
todo: u.reject('Be funny'),
|
||||||
|
// Increment version
|
||||||
version: inc
|
version: inc
|
||||||
}, person);
|
}, person);
|
||||||
|
|
||||||
// => {
|
// => {
|
||||||
// name: {
|
// name: { first: 'Bob', last: 'Sagat' },
|
||||||
// first: 'Bob',
|
// children: [
|
||||||
// last: 'Sagat',
|
// { name: 'Mary-Kate', age: 8 },
|
||||||
// },
|
// { name: 'Ashley', age: 8 }
|
||||||
// children: ['Mary-Kate', 'Ashley'],
|
// ],
|
||||||
|
// todo: [
|
||||||
|
// 'Manage household'
|
||||||
|
// ],
|
||||||
// email: 'bob@example.com',
|
// email: 'bob@example.com',
|
||||||
// version: 2
|
// version: 2
|
||||||
//}
|
//}
|
||||||
|
Loading…
Reference in New Issue
Block a user