https://github.com/stoeffel/curry-this https://github.com/stoeffel/bind-last https://github.com/stoeffel/bind-first
Curry-this makes creating curryied function simple and expresive by invoking curry with the function bind syntax ::.
Apart from the expresive way of creating a curried function, the main feature are placeholders.
A placeholder (_) is a Symbol which allows to curry specific arguments of a function.
Install it: npm install --save curry-this
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
| // require() some stuff from npm (like you were using browserify) | |
| // and then hit Run Code to run it on the right | |
| var Enum = require('enum'); | |
| cameraType=new Enum({'HIKVISION':"HikVision", 'DAHUA':"Dahua", "FOSCAM":"Foscam"}); | |
| console.log(cameraType.enums); | |
| cameraType.enums.forEach(function(element) { |
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
| // require() some stuff from npm (like you were using browserify) | |
| // and then hit Rebuild to run it on the right | |
| var get = require('101/pluck'); | |
| var set = require('101/set'); | |
| var clone = require('101/clone'); | |
| var lense = function(key) { | |
| var l = get(key); | |
| l.set = function(value, obj) { return set(clone(obj), key, value); }; | |
| l.mod = function(mod, obj) { |
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
| // require() some stuff from npm (like you were using browserify) | |
| // and then hit Rebuild to run it on the right | |
| var get = require('101/pluck'); | |
| var set = require('101/set'); | |
| var lense = function(key) { | |
| var l = get(key); | |
| l.set = set(key); | |
| l.mod = function(mod, obj) { | |
| return l.set(mod(l(obj))); |
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 curry = require('101/curry') | |
| var compose = require('101/compose') | |
| var set = require('101/set') | |
| var clone = require('101/clone') | |
| var insert = compose(curry(set, 3), clone); | |
| var obj = { foo: 1 } | |
| var cloned = insert(obj)('bar', 2) | |
| var cloned2 = insert(cloned)('baz', 3) |
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
| function compose2(fn1, fn2) { | |
| return (...args) => fn1(fn2.apply(null, args)); | |
| } | |
| function compose(...fns) { | |
| let head = fns.shift(); | |
| let tail = fns; | |
| if (head && tail.length === 0) { | |
| return head; |
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 gulp = require('reactive-gulp')(require('gulp')); | |
| gulp.task('default', '**/*.js') | |
| .pipe(mocha()) | |
| .pipe(uglify()) | |
| .dest('./dist/'); | |
| // is the same as | |
| var gulp = require('gulp'); | |
| gulp.task('default', function() { |
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
| cond([ | |
| [isTrue(foo), doStuffFoo], | |
| [isTrue(bar), doStuffBar], | |
| [always(true), otherwise] | |
| ]); | |
| //or | |
| cond( | |
| [isTrue(foo), doStuffFoo], | |
| [isTrue(bar), doStuffBar], |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> | |
| <script id="jsbin-javascript"> | |
| var l = function(func) { |