1.0.1 • Published 5 years ago
object-pipeline v1.0.1
object-pipeline
A JavaScript Object Processor, A Pipeline Function
Install
npm i -S object-pipeline
Usage
const pipeline = require('object-pipeline');
const nameObj = {
tim: 'tim',
jack: 'jack',
};
pipeline(nameObj, 'tim', item => `hello, ${item}.`);
// { tim: 'hello, tim', jack: 'jack' }
pipeline(nameObj, [ 'tim', 'xxx' ], item => `hello, ${item}.`);
// { tim: 'hello, tim', jack: 'jack' }
pipeline(nameObj, { tim: item => `no, ${item}` }, item => `hello, ${item}.`);
// { tim: 'no, tim', jack: 'jack' }
pipeline(nameObj, [ { tim: item => `no, ${item}` }, 'jack' ], item => `hello, ${item}.`);
// { tim: 'no, tim', jack: 'hello, jack.' }
Build
tsc
Roadmap
- add pickout function to pick out useless attributes of an object
- add optional-chaining to pipeline and pickout
- add Array support
Coverage
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
All files | 100 | 100 | 100 | 100 | |
pipeline.js | 100 | 100 | 100 | 100 |