Fluent.js
Tiny library for building fluent interfaces in JavaScript
Install / Use
/learn @nikaspran/Fluent.jsREADME
fluent.js 
A tiny library for building fluent interfaces in JavaScript
Installation
npm install fluent.js --save
Usage
Simple functions
var fluent = require('fluent.js');
var insert = fluent({
insert: '*',
into: '[]',
after: '*'
}, function handler(value, array, otherValue) {
array.splice(array.indexOf(otherValue) + 1, 0, value);
return array;
});
console.log(insert(2).into([1, 3]).after(1)); //[1, 2, 3]
Extending objects (and prototypes)
var fluent = require('fluent.js');
fluent({
with: '*',
after: '*'
}, function handler(value, otherValue) {
var copy = this.slice(0);
copy.splice(copy.indexOf(otherValue) + 1, 0, value);
return copy;
}, Array.prototype);
console.log(['this', 'awesome'].with('is').after('this')); //['this', 'is', 'awesome']
TODO
- Argument validation
- ES6 object destructuring
- Branching functions
- ???
Contributing
Make sure gulp build passes, otherwise try to maintain similar code style.
License
MIT
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
