expressive-objects

1.2.0 • Public • Published

Build Status Test Coverage Code Climate Issue Count dependencies Status devDependencies Status

expressive-objects

Build expressive APIs with chained properties.

If you ever wanted to build something with an API like chai, you might be looking for this.

This does not create 'connectors' that keep returning the same object, instead this builds a real object with property chains (paths) defined by yourself.

const expressive = require('expressive-objects');

const api = [{
    path: 'increment.two.by',
    value: function(number) {
        return 2 + number;
    }
}, {
    path: 'increment.two',
    value: function() {
        return 3;
    }
}, {
    path: 'this is a potato',
    value: 'potato'
}, {
    path: ['this', 'also', 'works'],
    value: true
}];

const obj = expressive(api);

console.log(obj.increment.two.by(3)); // 5;
console.log(obj.increment.two()); // 3;
console.log(obj.this.is.a.potato); // 'potato';
console.log(obj.this.also.works); // true

Readme

Keywords

none

Package Sidebar

Install

npm i expressive-objects

Weekly Downloads

6

Version

1.2.0

License

ISC

Last publish

Collaborators

  • pantoninho