1.0.3 • Published 6 years ago

rails-like-scope v1.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

This Package tries to give rails ActiveRecord scope functionality To simple javascript class

const { withScope } = require('./index');
class Example {
    static reverse(self) {
        return self.reverse();
    }

    static multipleBy2(self) {
        return self.map((x) => x*2);
    }

    static add(self, num) {
        return self.map((x) => x + num);
    }


}
withScope(Example).addScope('reverse').addScope('multipleBy2').addScope('add');

const result = Example.scope([1,2,3]).reverse().multipleBy2().add(5).finish();
// Should out put [ 11, 9, 7]
console.log(result);
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago