This file contains 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 slice = Array.prototype.slice; | |
function curry(f){ | |
var n = f.length; | |
return function curried(as){ | |
return function(){ | |
var args = as.concat(slice.call(arguments)) | |
return args.length < n ? curried(args) : f.apply(null, args); |
This file contains 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'; | |
function unsubscribe(subscribers, callback){ | |
return function(){ | |
var index = subscribers.indexOf(callback); | |
if(index > -1){ | |
subscribers.splice(index, 1); | |
} | |
}; |
This file contains 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 View(props) { | |
return ( | |
props.allow | |
? HelloWorld({ name: props.name }) | |
: P(null, [Text('Not allowed')]) | |
); | |
} | |
function HelloWorld(props) { | |
return ( |
This file contains 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 transform(options) { | |
return function(k, v) { | |
return options.hasOwnProperty(k) ? options[k](v, k) : v; | |
}; | |
} |
This file contains 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 Filter = {}; | |
Filter.ELEMENT = 1 | |
Filter.TEXT = 2 | |
Filter.COMMENT = 4; |
This file contains 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 INCREMENT = 'INCREMENT', DECREMENT = 'DECREMENT'; | |
function reducer(state, action) { | |
switch (action.type) { | |
case INCREMENT: | |
return state + 1; | |
case DECREMENT: | |
return state - 1; | |
} | |
} |
This file contains 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
// https://developer.mozilla.org/ru/docs/Web/API/ValidityState | |
var validityState = { valid: false, stepMismatch: true, tooLong: false }; | |
function errorMessage(validity) { | |
// Constant goes in expression | |
switch (true) { | |
// Variable goes in a case clause | |
case !validity.valid: | |
return 'is not a Number'; | |
case validity.stepMismatch: |
This file contains 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
Maybe(13) | |
.bind(a => a * a) | |
.bind(log); | |
isWorthy("Loki") | |
.bind(null, () => Just("Vision")) | |
.bind(name => log(name, "is worthy")); | |
function isWorthy(name) { | |
return name === "Thor" ? Just(name) : Nothing(); |