Skip to content

Instantly share code, notes, and snippets.

View alexeyraspopov's full-sized avatar
✍️
Working on something exciting

Oleksii alexeyraspopov

✍️
Working on something exciting
View GitHub Profile
function min(initial){
return map(function(value){
if(isNaN(initial) || value < initial){
initial = value;
}
return initial;
})
}
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]);
}
var data = require('./index');
function wrapper(process){
var observable, wrapper;
observable = data();
wrapper = function(value){
return arguments.length ? process(observable, value) : observable();
};
@alexeyraspopov
alexeyraspopov / birds.js
Last active August 29, 2015 14:03
Traits in JavaScript with CommonJS Modules
var rolesComposition = require('./trait');
function Duck(swimMessage, flyMessage){
this.swimMessage = swimMessage;
this.flyMessage = flyMessage;
}
Duck.prototype = rolesComposition(require('./swimming'), require('./flying'));
function Penguin(swimMessage){
CLI -> GUI -> NUI
Переход от CLI к GUI, на примере работы с гитом:
* усложняется работа за счет взаимодействия с мышью
* если использовать шорткаты вместо мыши, необходимо кроме знания команд знать и комбинации привязанные к ним. И в таком случае GUI является посредником опыта пользователя.
function* counter(start){
while (true) yield start++;
}
function range(min, max, inc=1){
return Array.apply(null, Array(max - min + 1))
.map((_, index) => index + min)
.filter((_, index) => !(index % inc));
}
// 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);
}
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);
}));
}
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);