UNPKG

obj-chain-core

Version:

fluent chaining for obj with dot-prop access

495 lines (158 loc) 5.34 kB
# [obj-chain](https://github.com/aretecode/obj-chain#readme) *0.0.3* > fluent chaining for obj with dot-prop access ### src/index.js #### flow(funcs) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | funcs | `Array.<Function>` | functions to flow left to right |   | ##### Returns - `Function` passes args through the functions, bound to this #### new ObjChain() ##### Returns - `Void` #### ObjChain.init(data[, plugins=]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | data | `string` `Object` | json data |   | | plugins= | `Array.<string>` | | *Optional* | ##### Returns - `JSONChain` #### ObjChain.constructor(data[, plugins=]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | data | `string` `Object` | |   | | plugins= | `Array.<string>` | | *Optional* | ##### Returns - `Void` #### ObjChain.update(key, val) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | key | `string` `any` | |   | | val | `Serializable` `any` | |   | ##### Returns - `ObjChain` @chainable #### ObjChain.escape(key) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | key | `string` | key with `.` |   | ##### Returns - `string` string with escaped `\\.` #### ObjChain.setIfNotEmpty(key, val) sets !.has(key) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | key | `string` `any` | |   | | val | `Serializable` `any` | |   | ##### Returns - `ObjChain` @chainable #### ObjChain.has(key) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | key | `string` `any` | |   | ##### Returns - `Boolean` #### ObjChain.del(key) delete. remove ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | key | `string` `any` | |   | ##### Returns - `ObjChain` #### ObjChain.val([key=null]) get a value ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | key=null | `string` `any` | | *Optional* | ##### Returns - `any` current key or named if there is key param #### ObjChain.save() save/write data ##### Returns - `ObjChain` #### ObjChain.use(obj) use middleware ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | obj | `Object` | |   | ##### Returns - `ObjChain` #### ObjChain.extend(methods[, nest=false]) take strings, make them methods to .set on ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | methods | `Array.<string>` | |   | | nest=false | `boolean` | nest the .set | *Optional* | ##### Returns - `JSONChain` #### ObjChain.toString() ##### Returns - `string` ### src/plugins/ConfigPlugin.js #### configPlugin(chain[, name]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | chain | `ObjChain` | |   | | name | `string` | | *Optional* | ##### Returns - `Void` ### src/plugins/KebabPlugin.js #### extendKebab(methods) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | methods | `Array.<string>` | |   | ##### Returns - `ObjectChain` @chainable ### src/plugins/SnapshotPlugin.js #### getAst(state) *private method* ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | state | | |   | ##### Returns - code generated state #### getSnapshot([type='ast', index=1]) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | type='ast' | `String` | snapshot type to use | *Optional* | | index=1 | `Number` | index starting from last to use | *Optional* | ##### Returns - snapshot #### snapAst(state) *private method* ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | state | | |   | | now=Date.now() | `number` | | *Optional* | ##### Returns - `ObjChain` @chainable #### snapStr(state) *private method* ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | state | | |   | | now=Date.now() | `number` | | *Optional* | ##### Returns - `ObjChain` @chainable #### snapshot([types='ast', props='data']) ##### Parameters | Name | Type | Description | | | ---- | ---- | ----------- | -------- | | types='ast' | `Array.<string>` `string` | [ast, stringify] | *Optional* | | props='data' | `Array.<string>` `string` | properties to snapshot | *Optional* | ##### Returns - `ObjChain` @chainable *Documentation generated with [doxdox](https://github.com/neogeek/doxdox).*