@specialblend/callable
v0.1.0
Published
Callable ES6 classes
Downloads
6
Maintainers
Readme
callable
callable ES6 classes
installation
npm i @specialblend/callable
example
import Callable from '@specialblend/callable';
export class CheckYoSelfFoo extends Callable {
constructor(foo, bar) {
super();
this.foo = foo;
this.bar = bar;
}
[Symbol.for('call')](name) {
return `Yo, ${name}! They say it dont ${this.foo}, but ${this.bar}`;
}
getFoo() {
return this.foo;
}
getBar() {
return this.bar;
}
}
const check = new CheckYoSelfFoo('be like it is', 'it do!');
// => be like it is
console.log(check.getFoo());
// => be like it is
console.log(check.foo);
// => it do!
console.log(check.getBar());
// => it do!
console.log(check.bar);
// => Yo, foo! They say it dont be like it is, but it do!
console.log(check('foo'));