Created
November 24, 2016 01:02
-
-
Save alesanabv/a63f1a0cfae3fc482333723cd8598b3b to your computer and use it in GitHub Desktop.
my own functional lib, only for learning
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
'use strict'; | |
export const each = fn => arr => Array.prototype.forEach.call(arr, fn); | |
export const map = fn => arr => Array.prototype.map.call(arr, fn); | |
export const reduce = (fn, initial = {}) => arr => Array.prototype.reduce.call(arr, fn, initial); | |
export const on = (event, fn) => el => el.addEventListener(event, fn); | |
export const onAll = (event, fn) => each(on(event, fn)); | |
export const flatten = arr => reduce((a, b) => a.concat(b), [])(arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment