require=function(a){return function(b){var c={};return a[b]||this[b](c)||(a[b]=c)}}({});Just 88 characters without any 3rd-party libraries and build scripts.
Readable version:
| module.exports = function(array){ | |
| return array.reduce(function(a, b){ | |
| return a.pipe(b); | |
| }); | |
| }; |
| <snippet> | |
| <content><![CDATA[ | |
| ${2:${1:module}} = require('${1:module}')$0 | |
| ]]></content> | |
| <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
| <tabTrigger>req</tabTrigger> | |
| <!-- Optional: Set a scope to limit where the snippet will trigger --> | |
| <scope>source.js</scope> | |
| </snippet> |
| demethodize = Function.prototype.bind.bind(Function.prototype.call); | |
| concat = demethodize(Array.prototype.concat); | |
| curry = demethodize(Function.prototype.bind); | |
| map = demethodize(Array.prototype.map); |
| function pick(property){ | |
| return (target) => target[property]; | |
| } | |
| function property(target){ | |
| return (property) => target[property]; | |
| } | |
| function invoke(method, args){ | |
| return (target) => target[method].apply(this, args); |
| demethodize = Function.prototype.bind.bind(Function.prototype.call); | |
| slice = demethodize(Array.prototype.slice); | |
| function limitTo(fn, limit){ | |
| return () => fn.apply(this, slice(arguments, 0, limit)); | |
| } |
| function compose(f, g){ | |
| return (...args) => f(g(...args)); | |
| } | |
| function identity(value){ | |
| return value; | |
| } | |
| function process(...list){ | |
| // something to do |
| function mapReduce(map, reduce, zero){ | |
| return function loop(from, to){ | |
| if(from > to){ | |
| return zero; | |
| } | |
| return reduce(map(from), loop(from + 1, to)); | |
| }; | |
| } |
| function filter(fn){ | |
| var child = stream(); | |
| child.changed = function(old, value){ | |
| return fn(value); | |
| }; | |
| return child; | |
| } |
| function TodoVM(model){ | |
| this.title = observable(model.title); | |
| this.completed = observable(model.observable) | |
| } | |
| filters = { | |
| all: () => true, | |
| active: (todo) => !todo.completed(), | |
| completed: (todo) => todo.completed() | |
| }; |