How to use the partial function from lodash
Find comprehensive JavaScript lodash.partial code examples handpicked from public code repositorys.
6461 6462 6463 6464 6465 6466 6467 6468 6469 6470
* @param {...*} [arg] Arguments to be partially applied. * @returns {Function} Returns the new partially applied function. * @example * * var greet = function(greeting, name) { return greeting + ' ' + name; }; * var hi = _.partial(greet, 'hi'); * hi('fred'); * // => 'hi fred' */ function partial(func) {
73
711
29
292 293 294 295 296 297 298 299 300 301
module.exports.overSome = _.overSome; module.exports.pad = _.pad; module.exports.padEnd = _.padEnd; module.exports.padStart = _.padStart; module.exports.parseInt = _.parseInt; module.exports.partial = _.partial; module.exports.partialRight = _.partialRight; module.exports.partition = _.partition; module.exports.partitionBy = _.partitionBy; module.exports.pick = _.pick;
19
122
0
+ 92 other calls in file
GitHub: mrijk/speculaas
34 35 36 37 38 39 40 41 42 43
function cat(...predicates) { const pairs = _.chunk(predicates, 2); return { op: 'cat', conform: _.partial(_conform, pairs), unform: values => _.map(pairs, ([k, p]) => unform(p, values[k])), gen: () => tcg.array(_.map(pairs, ([, p]) => gen(p))), describe: () => [cat.name, ...describe(predicates)], explain: function*(values, {via}) {
1
12
2
GitHub: bcgov/EDUC-STUDENT-ADMIN
197 198 199 200 201 202 203 204 205 206
const privateKey = config.get('tokenGenerate:privateKey'); const uiToken = jsonwebtoken.sign({}, privateKey, signOptions); log.verbose('Generated JWT', uiToken); return uiToken; }, isValidUiTokenWithRoles: partial(isValidUiToken, isUserHasRoles), isValidUserWithRoles: partial(isValidUser, isUserHasRoles), ...createRoleHelpers(userRoles), async getApiCredentials() {
5
5
10
+ 3 other calls in file
GitHub: mdmarufsarker/lodash
335 336 337 338 339 340 341 342 343 344 345 346 347
once(); const overArgs = _.overArgs((x, y) => [x, y], [n => n + 1, n => n + 2]); console.log(overArgs(1, 2)); // => [2, 4] const partial = _.partial((a, b, c) => a + b + c, 1, 2); console.log(partial(3)); // => 6 const partialRight = _.partialRight((a, b, c) => a + b + c, 1, 2); console.log(partialRight(3)); // => 6
0
4
0
+ 15 other calls in file
GitHub: Eveble/eveble
2953 2954 2955 2956 2957 2958 2959 2960 2961 2962
json[key] = serializer.fromJSONValue(json[key]); } } return new TypeCtor(json); }; return lodash.partial(construct, this, type); } getFactory(typeName) { return this.ejson.getType(typeName); }
0
2
0
+ 4 other calls in file
1353 1354 1355 1356 1357 1358 1359 1360 1361 1362
app.commands.register('project:new', handleNew, '文件: 新建') app.commands.register('project:open', handleOpen, '文件: 打开...') app.commands.register('project:save', handleSave, '文件: 保存') app.commands.register( 'project:save-as', _.partial(handleSave, undefined, true), '文件: 另存为...' ) app.commands.register( 'project:import-fragment',
0
1
1
+ 2 other calls in file
39 40 41 42 43 44 45 46 47 48 49 50
// return fn.apply(this, _.concat(fixed, arguments)) //concat обьединяет в массив // } // } //partial =================== //принимает функцию и аргументы к ней const double = _.partial(multiple, 2) const half = _.partialRight(divide, 2) const half2 = _.partial(divide, _, 2) //_ первый параметр оставляем под значение 20 half2(20) logger.info('умножаем число 21 на 2 через partial = ' + double(21))
0
1
0
+ 3 other calls in file
GitHub: sindeshiva/Test
497 498 499 500 501 502 503 504 505 506
/** * @param options {open_project.LaunchArgs} */ start (options, bus) { // curry left options return ipc.on('request', _.partial(this.handleEvent, options, bus)) }, }
0
0
0
GitHub: Hupeng7/es6demo
198 199 200 201 202 203 204 205 206 207 208
//_.partial(func,[partials]) function greet1(greeting, name) { return greeting + ' ' + name; } var sayHelloTo = _.partial(greet1, 'hello'); var sayHelloTo1 = sayHelloTo('fred'); console.log('sayHelloTo1--->', sayHelloTo1); //sayHelloTo1---> hello fred
0
0
0
+ 7 other calls in file
93 94 95 96 97 98 99 100 101 102 103 104
QUnit.test("추가 합성", function () { const trim = (str) => str.replace(/^\s*|\s*$/g, ''); const normalize = (str) => str.replace(/\-/g, ''); const validLength = (param, str) => str.length === param; const checkLengthSsn = _.partial(validLength, 9); const cleanInput = R.compose(normalize, trim); const isValidSsn = R.compose(checkLengthSsn, cleanInput);
0
0
0
+ 4 other calls in file
GitHub: xunonxyz/cypress
175 176 177 178 179 180 181 182
return ipc.removeAllListeners() }, start (options: EventsStartArgs, bus: EventEmitter) { // curry left options // ipc.on('request', _.partial(this.handleEvent, options, bus)) }, }
0
0
1
+ 5 other calls in file
GitHub: lewisvoncken/cypress
47 48 49 50 51 52 53 54 55
} const yarn = createCLIExecutable('yarn') const npx = createCLIExecutable('npx') const runAllBuild = _.partial(npx, ['lerna', 'run', 'build-prod', '--ignore', 'cli']) // removes transpiled JS files in the original package folders const runAllCleanJs = _.partial(npx, ['lerna', 'run', 'clean-js', '--ignore', 'cli'])
0
0
1
+ 3 other calls in file
lodash.get is the most popular function in lodash (7670 examples)