This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const zip = (arr, ...arrs) => { | |
return arr.map((val, i) => arrs.reduce((a, arr) => [...a, arr[i]], [val])); | |
} | |
// example | |
const a = [1, 2, 3]; | |
const b = [4, 5, 6]; | |
const c = [7, 8, 9]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compose = (...fns) => (...args) => { | |
return fns.slice(0, -1).reduceRight((res, fn) => fn(res), | |
fns[fns.length -1].apply(null,args) | |
); | |
}; | |
const bind = (f) => (...args) => { | |
if(args[0] instanceof Error) return args[0]; | |
try{ | |
return f.apply(null, args); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const partial = (fn, ...args) => partialApply(fn, args); | |
const partialApply = (fn, args) => fn.bind(null, ...args); | |
// example | |
const add = (a, b) => a + b; | |
const sum = (...args) => args.reduce(add, 0); | |
const add10 = partial(sum, 4, 6); | |
const add40 = partialApply(sum, [5, 15, 20]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const compose = (...fns) => (...args) => { | |
return fns.slice(0, -1).reduceRight((res, fn) => fn(res), | |
fns[fns.length -1].apply(null,args) | |
); | |
}; | |
const pipe = (f1, ...fns) => (...args) => { | |
return fns.reduce((res, fn) => fn(res), f1.apply(null,args)); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const curry = (fn, ...args) => fn.length === 0 | |
? fn | |
: fn.length > args.length | |
? (...args2) => curry(...[fn,...args,...args2]) | |
: fn(...args); | |
// example | |
const add = curry((a,b,c,d) => a + b + c + d); | |
const add1 = add(1); | |
const add3 = add1(2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---- | |
// Sass (v3.4.14) | |
// Compass (v1.0.3) | |
// ---- | |
@mixin pos-absolute($positions...){ | |
position: absolute; | |
@include position($positions...); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataSystem = () -> | |
this.data = {} | |
this | |
proto = DataSystem.prototype | |
proto.set = ( keys , value , obj ) -> | |
obj = obj || this.data | |
if typeof keys is 'string' | |
keys = keys.split('.') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var t = console.log; | |
var select = function( selector ){ | |
return new Collection( document.querySelectorAll( selector ) ); | |
}; | |
var Collection = function( collection ){ | |
collection = collection || []; | |
this.collection = Array.prototype.slice.call(collection); |
NewerOlder