Selector.prototype.get = function (obj) { var getValue = R.bind(this.getValue, this), transformValue = R.bind(this.transformValue, this); var getAndTransform = R.pipe(getValue, transformValue); // We cannot curry without losing `this` so this is our best option. return obj ? getAndTransform(obj) : getAndTransform; };
render() { return React.createElement( Component, R.merge(this.props, { refWrap: node => this.wrap = node, refList: node => this.list = node, refAnchor: node => this.anchor = node, onLayout: R.bind(this.onLayout, this) }) ) }
fs.readdir('./', (err, files) => { var version_folders = R.filter(R.bind(version_folder_re.test, version_folder_re), files).sort(semver_compare) var html = make_html({ releases: version_folders, version: version }) fs.writeFileSync('releases.html', html, {encoding: 'utf8'}) })
constructor (events, callback = noop, options = {}) { events = splitSpaces(events); if (options.context) { callback = R.bind(callback, options.context); } this.events = events; this.callback = callback; this.options = options; }
findAll: function() { return Promise.all( R.map(R.bind(this.find, this), this.defaultSections) ) .then(function(sections) { if (!R.is(Array, sections) || R.isEmpty(sections)) { return []; } return R.reject(function(section) { return !section; }, sections); }); },
export function checkProperties(obj, checker) { debug('checkProperties: %j', obj) R.forEach(R.bind(checker, obj), R.keys(obj)) return obj }
function getSnakeAndFood$$(head$, gameStart$) { var listOf = R.bind(Immutable.List.of, Immutable.List); //this is actually a 'stepper' of the food that gets eaten by the snake var eatenFood$ = new Bacon.Bus(); //after the snake eats, its length will increase in the next X movements. //Therefore we need to keep a buffer that indicates how much more the snake //is supposed to grow. The buffer will decrease as the snake moves and //it will increase every time the snake eats var decreaseIfGreatterThanZero = R.cond([R.gt(R.__, 0), R.dec], [R.T, R.identity]); var growthBuffer$$ = Bacon.update( 0, [head$, gameStart$], R.always(0), [head$, eatenFood$], R.pipe(decreaseIfGreatterThanZero, R.add(config.FOOD_INCREASE)), [head$], decreaseIfGreatterThanZero ).skipDuplicates(); //The current length of the snake var increaseIfBufferIsNotEmpty = R.cond( [R.compose(R.gt(R.__, 0), R.nthArg(1)), R.add(1)], [R.T, R.identity] ); var length$$ = Bacon.update( 1, [head$, gameStart$], R.always(1), [growthBuffer$$, head$], increaseIfBufferIsNotEmpty ).skipDuplicates(); //the latest "length$$" positions where the head of the snake has passed //through. In other words: the positions of the full body of the snake //(including its head) var snake$$ = Bacon.update( null, [head$, gameStart$], R.compose(listOf, R.nthArg(1)), [head$, length$$], function(old, head, len) { var result = old.unshift(head); return len === result.size ? result : result.pop(); } ).filter(R.compose(R.not, R.isNil)); //the position of food var getNewFoodPositionIfHeadHitsFood = R.cond( [R.eqDeep, R.compose(getAvailablePosition, R.nthArg(2))], [R.T, R.identity] ); var food$$ = Bacon.update( null, [snake$$, head$, gameStart$], R.compose(getAvailablePosition, R.nthArg(1)), [head$, snake$$], getNewFoodPositionIfHeadHitsFood ).skipDuplicates(); //if the food changes that means that the snake has eaten, //therefore we need to plug these changes to 'eatenFood$' var isInitialHead$$ = Bacon.update( true, [head$, gameStart$], true, [head$], false ).skipDuplicates(); eatenFood$.plug(food$$.filter(isInitialHead$$.not())); return { snake$$: snake$$, food$$: food$$ }; }
expand(stxl) { let result = List(); if (stxl.size === 0) { return result; } let prev = List(); let enf = new Enforester(stxl, prev, this.context); let self = this; while (!enf.done) { let term = _.pipe( _.bind(enf.enforest, enf), _.cond([ [isVariableDeclarationStatement, term => { // first, remove the use scope from each binding term.declaration.declarators = term.declaration.declarators.map(decl => { return new Term('VariableDeclarator', { binding: removeScope(decl.binding, self.context.useScope), init: decl.init }); }); // syntax id^{a, b} = <init>^{a, b} // -> // syntaxrec id^{a,b,c} = function() { return <<id^{a}>> } // syntaxrec id^{a,b} = <init>^{a,b,c} if (isSyntaxDeclaration(term.declaration)) { // TODO: do stuff let scope = freshScope('nonrec'); term.declaration.declarators.forEach(decl => { let name = decl.binding.name; let nameAdded = name.addScope(scope); let nameRemoved = name.removeScope(self.context.currentScope[self.context.currentScope.length - 1]); let newBinding = gensym(name.val()); self.context.bindings.addForward(nameAdded, nameRemoved, newBinding); decl.init = decl.init.addScope(scope, self.context.bindings); }); } // for syntax declarations we need to load the compiletime value // into the environment if (isSyntaxDeclaration(term.declaration) || isSyntaxrecDeclaration(term.declaration)) { term.declaration.declarators.forEach(decl => { registerBindings(decl.binding, self.context); loadSyntax(decl, self.context, self.context.env); }); // do not add syntax declarations to the result return Nothing(); } else { // add each binding to the environment term.declaration.declarators.forEach(decl => registerBindings(decl.binding, self.context) ); } return Just(term); }], [isFunctionWithName, term => { term.name = removeScope(term.name, self.context.useScope); registerBindings(term.name, self.context); return Just(term); }], [isImport, term => { let mod = self.context.modules.load(term.moduleSpecifier.val(), self.context); // NOTE: this is a hack for MVP modules if (term.forSyntax) { console.log('import for syntax is not implemented yet'); // todo // mod.invoke(self.context); } else { mod.visit(self.context); } let boundNames = bindImports(term, mod, self.context); if (boundNames.size === 0) { return Just(term); } return Nothing(); }], [isEOF, Nothing], [_.T, Just] ]), Maybe.maybe(List(), _.identity) )(); result = result.concat(term); } return result; }