Update a tcomb object at a path
For updating bigger objects, it's more convenient to provide a path and an update payload.
The normal tcomb.update
signature forces you to provide a deep update object.
This module takes a path
array and an update
payload and combines them into a tcomb-compatible update.
$ npm install --save tcomb-update-path
var updatePath = require('tcomb-update-path')
var tcomb = require('tcomb')
var Struct = tcomb.struct({
foo: tcomb.struct({
bar: tcomb.String
})
})
var struct = Struct({
foo: {bar: 'str'}
})
updatePath(struct, ['foo', 'bar'], {
$set: 'new str'
})
//=> {foo: {bar: 'new str'}}
An instantiated tcomb type (usually a struct or list).
The path to the object being updated. Can be an array or a string dot-path.
A valid tcomb update action, which will be done at the given path
.
MIT © Andrew Joslin