How to use the pick function from lodash

Find comprehensive JavaScript lodash.pick code examples handpicked from public code repositorys.

20
21
22
23
24
25
26
27
28
29
brew.text = brew.text.replaceAll('\r\n', '\n');
if(brew.text.startsWith('```metadata')) {
	const index = brew.text.indexOf('```\n\n');
	const metadataSection = brew.text.slice(12, index - 1);
	const metadata = yaml.load(metadataSection);
	Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']));
	brew.text = brew.text.slice(index + 5);
}
if(brew.text.startsWith('```css')) {
	const index = brew.text.indexOf('```\n\n');
fork icon296
star icon859
watch icon36

3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
*  names or arrays of property names.
* @param {*} [thisArg] The `this` binding of `callback`.
* @returns {Object} Returns an object composed of the picked properties.
* @example
*
* _.pick({ 'name': 'fred', '_userid': 'fred1' }, 'name');
* // => { 'name': 'fred' }
*
* _.pick({ 'name': 'fred', '_userid': 'fred1' }, function(value, key) {
*   return key.charAt(0) != '_';
fork icon73
star icon711
watch icon29

+ 3 other calls in file

334
335
336
337
338
339
340
341
342
343
  // Publish message about the exception
  const runId = task.runs.length - 1;
  await ctx.publisher.taskException(_.defaults({
    status,
    runId,
  }, _.pick(run, 'workerGroup', 'workerId')), task.routes);
  ctx.monitor.log.taskException({ taskId: task.taskId, runId });
}

return status;
fork icon238
star icon317
watch icon18

90
91
92
93
94
95
96
97
98
99
    collection = _.get(self, '_collection.collectionName');
    query = jsonObjToMongo(conditions);
    req = _.extend({collection}, _.pick(self, ['op', 'options', '_conditions', '_fields', '_update', '_path', '_distinct', '_doc']));
} else if (isModel) {
    op = self.$op || self.$__.op;
    if (op !== 'validate') conditions = _.pick(self._doc, '_id');
    query = jsonObjToMongo(conditions)
    collection = self.constructor.collection.collectionName;
    req = {
        collection,
fork icon8
star icon454
watch icon7

80
81
82
83
84
85
86
87
88
89
90
  const { coordinate: { namespace } } = body
  return listShortcuts({ user, namespace })
}


function toTerminalMetadata (terminal) {
  const metadata = _.pick(terminal.metadata, ['name', 'namespace'])
  metadata.identifier = _.get(terminal, 'metadata.annotations["dashboard.gardener.cloud/identifier"]')
  return metadata
}

fork icon88
star icon199
watch icon22

+ 19 other calls in file

55
56
57
58
59
60
61
62
63
64
65
66
67


exports.formatFailedTests = (tests) => {
    const formattedTests = [];


    tests.forEach((test) => {
        const testItem = _.pick(test, ['fullTitle', 'file']);


        if (_.find(formattedTests, testItem)) {
            return;
        }
fork icon56
star icon556
watch icon11

+ 6 other calls in file

757
758
759
760
761
762
763
764
765
766
767
768
      });
    });


const getUserSettings = async({ name }) => {
  const [ user, medicUser ] = await getUserDocsByName(name);
  Object.assign(medicUser, _.pick(user, 'name', 'roles', 'facility_id'));
  return hydrateUserSettings(medicUser);
};


/*
fork icon181
star icon402
watch icon53

+ 8 other calls in file

404
405
406
407
408
409
410
411
412
async last12MonthsStatsForInit(json, target) {
  json.last12Months = await this.getStats({granularities: '1month', hits: 12}, target);
}

async monthlyDataUsageForInit(json, target) {
  json.monthlyDataUsage = _.pick(await this.monthlyDataStats(target), [
    'totalDownload', 'totalUpload', 'monthlyBeginTs', 'monthlyEndTs'
  ])
}
fork icon117
star icon456
watch icon48

+ 12 other calls in file

257
258
259
260
261
262
263
264
265
266
const sqnNumber = this.client.send(packetObj);
this.client.addMessageHandler('stateVersion', function(err, msg) {
  if (err) {
    return callback(err, null);
  }
  const versionInfo = pick(msg, [
    'vendorId',
    'productId',
    'version'
  ]);
fork icon17
star icon33
watch icon7

+ 4 other calls in file

1412
1413
1414
1415
1416
1417
1418
1419
1420

redUser.contact = {}
profiles.forEach((profile) => {
  const profileType = profile.is
  const fieldsToAssignToContactFromProfile = fields[profileType]
  const fieldsAndValues = _.pick(profile, fieldsToAssignToContactFromProfile)
  const fieldAndNonFalsyValues = deleteFalsyProperties(fieldsAndValues)
  redUser.contact = Object.assign({}, redUser.contact, fieldAndNonFalsyValues)
})
fork icon7
star icon18
watch icon6

+ 13 other calls in file

142
143
144
145
146
147
148
149
150
151
    const expires = data.maxAge > 0 ? response.body.now + data.maxAge * 1000 : 0;
    expect(Math.abs(c.expires.getTime() - expires) < 5, "Cookie expires should match");
    delete c.expires;
  }
  expect(
    _.pick(c, "name", "value", "path", "maxAge", "domain", "secure", "httpOnly")
  ).to.deep.equal(data);
};

verifyCookie({
fork icon309
star icon0
watch icon49

1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
  } else {
    throw e;
  }
}
if (checkIfExists) {
  return _.pick(challenge, ["id", "legacyId"]);
}
await helper.ensureUserCanViewChallenge(currentUser, challenge);

// // FIXME: Temporarily hard coded as the migrad
fork icon44
star icon17
watch icon25

+ 41 other calls in file

190
191
192
193
194
195
196
197
198
199
// They are included as the widget might receive expressions such as rowsets that reference
// variables that are only present in the outer scope.
const innerContextVars = (instanceCtx.globalContextVars || [])
    .concat(instanceCtx.contextVars)
    .concat(widgetDef.contextVars);
const innerContextVarValues = Object.assign(Object.assign(Object.assign({}, instanceCtx.contextVarValues), mappedContextVarValues), _.pick(widgetDef.privateContextVarValues || {}, (widgetDef.privateContextVars || []).map((cv) => cv.id)));
const innerInstanceCtx = Object.assign(Object.assign({}, instanceCtx), { contextVars: innerContextVars, contextVarValues: innerContextVarValues, getContextVarExprValue: (contextVarId, expr) => {
        // If no context variable, evaluate expression
        if (contextVarId == null) {
            return new mwater_expressions_1.PromiseExprEvaluator({
fork icon3
star icon4
watch icon3

+ 5 other calls in file

682
683
684
685
686
687
688
689
690
691
692
 * @param {String} m2mToken the m2m token
 */
async function rePostResourcesOnKafka (challengeUuid, m2mToken) {
  const challengeResourcesResponse = await helper.getRequest(`${config.V5_RESOURCES_API_URL}?challengeId=${challengeUuid}&perPage=100`, m2mToken)
  for (const resource of (challengeResourcesResponse.body || [])) {
    await helper.postBusEvent(config.RESOURCE_CREATE_TOPIC, _.pick(resource, ['id', 'challengeId', 'memberId', 'memberHandle', 'roleId', 'created', 'createdBy', 'updated', 'updatedBy', 'legacyId']))
  }
}


/**
fork icon6
star icon3
watch icon35

+ 3 other calls in file

103
104
105
106
107
108
109
110
111
112
}
const list = async ({ order, start, limit, filters }) => {
  let query = ds.createQuery(kind)

  if (order && order.property) {
    query = query.order(order.property, _.pick(order, ['descending']))
  }
  query = query.offset(start).limit(limit)

  if (filters) {
fork icon3
star icon3
watch icon3

+ 10 other calls in file

335
336
337
338
339
340
341
342
343
344
const rootCategories = categories.filter(category => category && category.parentCid === parentCid);
rootCategories.forEach(category => recursive(category, categoriesData, '', 0));
const pickFields = ['cid', 'name', 'level', 'icon', 'parentCid', 'color', 'bgColor', 'backgroundImage', 'imageClass'];
fields = fields || [];
if (fields.includes('text') && fields.includes('value')) {
  return categoriesData.map(category => _.pick(category, fields));
}
if (fields.length) {
  pickFields.push(...fields);
}
fork icon1
star icon1
watch icon5

+ 3 other calls in file

363
364
365
366
367
368
369
370
371
372
  }
  let post = _.get(result, `content['${field.author}/${field.permlink}']`);
  if (!post || !post.author) post = createMockPost(field);

  Object.assign(field,
    _.pick(post, ['children', 'total_pending_payout_value',
      'total_payout_value', 'pending_payout_value', 'curator_payout_value', 'cashout_time']));
  field.fullBody = post.body;
});
return obj;
fork icon0
star icon3
watch icon3

139
140
141
142
143
144
145
146
147
const { route } = routeInfo;

const routeOptions = Object.assign(
  {},
  topOpts,
  _.pick(route, ["pageTitle", "bundleChunkSelector", "templateFile", "selectTemplate"])
);

routeOptions.uiConfig = _.get(fastify, "settings.app.config.ui", {});
fork icon309
star icon0
watch icon49

+ 7 other calls in file

296
297
298
299
300
301
302
303
304
305
module.exports.parseInt            = _.parseInt;
module.exports.partial             = _.partial;
module.exports.partialRight        = _.partialRight;
module.exports.partition           = _.partition;
module.exports.partitionBy         = _.partitionBy;
module.exports.pick                = _.pick;
module.exports.pickBy              = _.pickBy;
module.exports.pickWhen            = _.pickWhen;
module.exports.pipeline            = _.pipeline;
module.exports.property            = _.property;
fork icon19
star icon122
watch icon0

+ 92 other calls in file

124
125
126
127
128
129
130
131
132
133
 *
 * @return {Tag[]} doc.tags
 *         All the JSDoc tags found in the docstring.
 */
Docstring.prototype.toJSON = function() {
  var docstring = _.pick(this, [
    'name',
    'namespace',
    'description',
    'loc',
fork icon3
star icon6
watch icon1

+ 15 other calls in file

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)