[go: up one dir, main page]

@webkrafters/data-distillery
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Data Distillery

Returns an object constructed using slices of an exisitng object.

Install:
npm i -S data-distillery
Alternate: npm i -S @webkrafters/data-distillery

Example

import distill from 'data-distillery'; 

const source = {
    address: {
        city: 'Test City',
        state: 'My Province'
    },
    matrix: [
        [ [ 0, 3, 1 ], [ 4, 0, 3 ] ],
        [ [ 4, 1, 9 ], [ 7, 4, 9 ] ],
        [ [ 8, 7, 3 ], [ 0, 3, 1 ] ]
    ],
    registered: {
        time: new Date(),
        timezone: 'Eastern Time'
    },
    tags: [ 'test', 'foo', 'bar', 'baz', 'boo', 'tap', 'bak' ]
};

distill( source, [
    'matrix.1.1',
    'matrix[2].0',
    'address',
    'registered.timezone',
    'tags[4]',
    'matrix[0][1]'
]);
// returns distilled object => {
//   matrix: {
//     0: { 1: [ 4, 0, 3 ] },
//     1: { 1: [ 7, 4, 9 ] },
//     2: { 0: [ 8, 7, 3 ] }
//   },
//   address: {
//     city: 'Test City',
//     state: 'My Province'
//   },
//   registered: {
//     timezone: 'Eastern Time'
//   },
//   tags: {
//     4: 'boo'
//   }
// }

License

MIT

Package Sidebar

Install

npm i @webkrafters/data-distillery

Weekly Downloads

7

Version

0.0.3

License

MIT

Unpacked Size

11.3 kB

Total Files

7

Last publish

Collaborators

  • webkrafters