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 min(initial){ | |
return map(function(value){ | |
if(isNaN(initial) || value < initial){ | |
initial = value; | |
} | |
return initial; | |
}) | |
} |
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 SomeViewModel(title){ | |
this.title = data(title) | |
.map(toLowerCase); | |
this.description = event(node, 'change') | |
.map(getTargetValue) | |
.filter(Boolean); | |
this.full = computed(interpolate('$0: $1'), [this.title, this.description]); | |
} |
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 data = require('./index'); | |
function wrapper(process){ | |
var observable, wrapper; | |
observable = data(); | |
wrapper = function(value){ | |
return arguments.length ? process(observable, value) : observable(); | |
}; |
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 rolesComposition = require('./trait'); | |
function Duck(swimMessage, flyMessage){ | |
this.swimMessage = swimMessage; | |
this.flyMessage = flyMessage; | |
} | |
Duck.prototype = rolesComposition(require('./swimming'), require('./flying')); | |
function Penguin(swimMessage){ |
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
CLI -> GUI -> NUI | |
Переход от CLI к GUI, на примере работы с гитом: | |
* усложняется работа за счет взаимодействия с мышью | |
* если использовать шорткаты вместо мыши, необходимо кроме знания команд знать и комбинации привязанные к ним. И в таком случае GUI является посредником опыта пользователя. |
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* counter(start){ | |
while (true) yield start++; | |
} |
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 range(min, max, inc=1){ | |
return Array.apply(null, Array(max - min + 1)) | |
.map((_, index) => index + min) | |
.filter((_, index) => !(index % inc)); | |
} |
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
// returns a function which receive an array of values and apply they to `fn` as params | |
function spread(fn){ | |
return fn.apply.bind(fn, null); | |
} |
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.call.bind(Array.prototype.slice); | |
function use(fn, fns){ | |
return function(){ | |
var args = slice(arguments); | |
return fn.apply(null, args.map(function(arg, index){ | |
return fns[index](arg); | |
})); | |
} |
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); |