Eloquent
Easily build up chaining structures
Example
var eloquent = ; var structure = { thisflag = false; } signal: { thisflag = true; } clear: { thisflag = false; } util: signalIf: { if cond thisflag = true; } hasFlag: _returns: true /* the method should not be wrapped */ { return !!thisflag; } status: _returns: true /* the getter should not be wrapped */ { return !!thisflag; } emit: { if thisflag console; } ; var Signaler = ; signal // emits clear signalclear util; // emits// The above statement logs 'Signal!' twice. console; //-> trueconsole; //-> true
To-Do
Some things that still need to be done
- DRYing out the implementation
- Review/revise the underscore-prefix API (as suggested by Sindre Sorhus)
- Add better ability to mix dynamic properties with non-dynamic properties
- Performance increases (static prototype buildup at creation of Eloquent structure, etc.)
License
Licensed under the MIT License. You can find a copy of it in LICENSE.