Sha256: cc0b1da037ce69e16620d7e1d08f4ad11a5b25a416bd04ae45a22b82e47c8260
Contents?: true
Size: 1.39 KB
Versions: 6
Compression:
Stored size: 1.39 KB
Contents
var split, join, lines, unlines, words, unwords, chars, unchars, reverse, repeat; split = curry$(function(sep, str){ return str.split(sep); }); join = curry$(function(sep, xs){ return xs.join(sep); }); lines = function(str){ if (!str.length) { return []; } return str.split('\n'); }; unlines = function(it){ return it.join('\n'); }; words = function(str){ if (!str.length) { return []; } return str.split(/[ ]+/); }; unwords = function(it){ return it.join(' '); }; chars = function(it){ return it.split(''); }; unchars = function(it){ return it.join(''); }; reverse = function(str){ return str.split('').reverse().join(''); }; repeat = curry$(function(n, str){ var out, res$, i$; res$ = []; for (i$ = 0; i$ < n; ++i$) { res$.push(str); } out = res$; return out.join(''); }); module.exports = { split: split, join: join, lines: lines, unlines: unlines, words: words, unwords: unwords, chars: chars, unchars: unchars, reverse: reverse, repeat: repeat }; function curry$(f, bound){ var context, _curry = function(args) { return f.length > 1 ? function(){ var params = args ? args.concat() : []; context = bound ? context || this : this; return params.push.apply(params, arguments) < f.length && arguments.length ? _curry.call(context, params) : f.apply(context, params); } : f; }; return _curry(); }
Version data entries
6 entries across 6 versions & 2 rubygems