How to use the partial function from ramda
Find comprehensive JavaScript ramda.partial code examples handpicked from public code repositorys.
GitHub: studiomohawk/uiengine
37 38 39 40 41 42 43 44 45 46
} else { // look up variants from folder if they are not specified. variants = await findVariants(state, componentId) } const fetch = R.partial(fetchObject, [state, componentId, context]) const fetches = mapIndexed(fetch, variants) const list = await Promise.all(fetches) debug2(state, `Variant.fetchObjects(${componentId}):end`)
25
1
1
GitHub: shuiniuer/blog
212 213 214 215 216 217 218 219 220 221
``` `partial`:允许多参数的函数接受一个数组,指定最左边的部分参数。 ``` var multiply2 = (a, b) => a * b; var double = R.partial(multiply2, [2]); double(2) // 4 var greet = (salutation, title, firstName, lastName) => salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
0
1
1
+ 5 other calls in file
1572 1573 1574 1575 1576 1577 1578 1579 1580 1581
* @category Object * @sig (* -> *) -> {*} -> (* -> *) * @param {Function} fn The function to bind to context * @param {Object} thisObj The context to bind `fn` to * @return {Function} A function that will execute in the context of `thisObj`. * @see R.partial * @example * * var log = R.bind(console.log, console); * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
0
0
0
+ 89 other calls in file
GitHub: desenmeng/ramda
38 39 40 41 42 43 44 45 46 47 48 49
var filenameToIdentifier = R.partialRight(path.basename, '.js'); // identifierToFilename :: String -> String var identifierToFilename = R.pipe(R.ifElse(R.test(/^(?!__$)_/), R.partial(path.join, __dirname, '..', 'src', 'internal'), R.partial(path.join, __dirname, '..', 'src')), R.concat(_, '.js')); // parse :: String -> {ast: AST, comments: [Comment], tokens: [Token]}
0
0
0
GitHub: dqmmpb/define-demos
142 143 144 145 146 147 148 149 150 151 152 153
log(average([1, 2, 3, 4, 5, 6, 7])); log(sumOfArr([1, 2, 3, 4, 5, 6, 7])); // sumOfArr2的写法以下两种是一致的 //var sumOfArr2 = R.partial(R.reduce(R.add), [0]); var sumOfArr2 = R.reduce(R.add, 0); var average2 = R.converge(R.divide, [sumOfArr2, lengthOfArr]); log(sumOfArr2([1, 2, 3, 4, 5, 6, 7])); log(average2([1, 2, 3, 4, 5, 6, 7]));
0
0
0
+ 9 other calls in file
26 27 28 29 30 31 32 33 34 35
const parseAndSaveFile = R.compose( trySavingFile, addType, R.objOf('path'), R.partial(path.resolve, [__dirname]), R.concat('../') ); return nodeDir.promiseFiles(dir).then(R.compose(
0
0
0
10878 10879 10880 10881 10882 10883 10884 10885 10886
* * const greet = (salutation, title, firstName, lastName) => * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; * * const sayHello = R.partial(greet, ['Hello']); * const sayHelloToMs = R.partial(sayHello, ['Ms.']); * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!' * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d) */
0
0
2
+ 23 other calls in file
ramda.clone is the most popular function in ramda (30311 examples)