How to use the get function from lodash

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

66
67
68
69
70
71
72
73
74
75
    }
    newObjectFields[joins[index].alias][key] = joinItem[key];
  });
} else if (_.get(drItem, drSelector, drItem[drSelector])
  && _.get(drItem, drSelector, drItem[drSelector])
    === _.get(joinItem, joinSelector, joinItem[joinSelector])
) {
  Object.keys(joinItem).forEach((key) => {
    if (!newObjectFields[joins[index].alias]) {
      newObjectFields[joins[index].alias] = {};
fork icon148
star icon998
watch icon12

+ 199 other calls in file

97
98
99
100
101
102
103
104
105
106
107
108
    }


    #getInheritedProperty(name, defaultValue) {
        return name in this.#data
            ? this.#data[name]
            : _.get(this.parent, name, defaultValue);
    }
}


module.exports = {
fork icon56
star icon556
watch icon11

+ 6 other calls in file

174
175
176
177
178
179
180
181
182
183
}

// Chrome mobile returns screenshots that are larger than visible viewport due to a bug:
// https://bugs.chromium.org/p/chromedriver/issues/detail?id=2853
// Due to this, screenshot is cropped incorrectly.
const capabilities = _.get(currentNode, 'desiredCapabilities');

const isAndroid = capabilities && Boolean(
    (capabilities.platformName && capabilities.platformName.match(/Android/i)) ||
    (capabilities.browserName && capabilities.browserName.match(/Android/i))
fork icon56
star icon556
watch icon11

+ 2 other calls in file

746
747
748
749
750
751
752
753
754
755
756
757


Users.plugin(passportLocalMongoose, config.passportLocalMongoose);


Users.post('init', (doc) => {
  for (const field of config.accountUpdateFields) {
    const fieldName = _.get(config, field);
    doc[`__${fieldName}`] = doc[fieldName];
  }
});

fork icon66
star icon525
watch icon8

+ 15 other calls in file

4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
  }
}

let msg = rawmsg.message.obj;
(async () => {
  const eid = _.get(rawmsg, 'message.appInfo.eid')
  if (eid) {
    const revoked = await rclient.sismemberAsync(Constants.REDIS_KEY_EID_REVOKE_SET, eid);
    if (revoked) {
      this.simpleTxData(msg, null, { code: 401, msg: "Unauthorized eid" }, callback);
fork icon117
star icon463
watch icon0

1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
  default: currentDefault || 'default',
  list: Object.keys(profileConfig[category]).filter(p => p != 'default'),
  subTypes: Object.keys(profileConfig[category][cloudDefault])
}
if (category == 'alarm') {
  json.profiles.alarm.defaultLargeUpload2TxMin = _.get(
    fc.getConfig().profiles.alarm, [currentDefault, 'large_upload_2', 'txMin'],
    fc.getConfig().profiles.alarm.default.large_upload_2.txMin
  )
}
fork icon117
star icon456
watch icon48

+ 38 other calls in file

77
78
79
80
81
82
83
84
85
86
  const intfInfo = await FireRouter.getSingleInterface(intf, true).catch((err) => {
    log.error(`Cannot get interface info of ${intf}`, err.message);
    return null;
  });
  if (intfInfo) {
    autonomousPeerInfo = _.get(intfInfo, ["state", "autonomy", "peerInfo"], undefined);
  }
}
const dumpResult = await exec(`sudo wg show ${intf} dump | tail +2`).then(result => result.stdout.trim().split('\n')).catch((err) => {
  log.error(`Failed to dump wireguard peers on ${intf}`, err.message);
fork icon117
star icon456
watch icon48

+ 7 other calls in file

263
264
265
266
267
268
269
270
271
272
pgn.description = pgnData.Description

//console.log(`pgn: ${JSON.stringify(pgn)}`)

// Stringify timestamp because SK Server needs it that way.
const ts = _.get(pgn, 'timestamp', new Date())
pgn.timestamp = _.isDate(ts) ? ts.toISOString() : ts
this.emit('pgn', pgn)
cb && cb(undefined, pgn)
if ( pgnData.callback ) {
fork icon26
star icon65
watch icon14

320
321
322
323
324
325
326
327
328
329
} else {
    for (const ticket of tickets) {
        const userInputDatas = await prepareUserInputs(ticket);
        for (const input of userInputDatas) {
            const inputLabels = input.problemCategory;
            const currentLable = _.get(inputLabels, labels[i].path);
            if (currentLable.name == labels[i].name && currentLable.enable == 1) {
                labels[i].annotated += 1;
            }
        }
fork icon15
star icon37
watch icon8

+ 7 other calls in file

1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
    labelCase[item] = 0;
});
for await (const input of srs.userInputs) {
    const userInputLabel = input.problemCategory;
    for (const i in pathsArray) {
        const currentLable = _.get(userInputLabel, pathsArray[i]);
        if (currentLable.name == labelsArray[i].split(".").pop() && currentLable.enable == 1) {
            labelCase[labelsArray[i]] += 1;
        }
    }
fork icon15
star icon37
watch icon8

+ 3 other calls in file

366
367
368
369
370
371
372
373
374
375
376
377
}


async function waitFor (callback, options = null) {
    const timeout = get(options, 'timeout', 15000)
    const interval = get(options, 'interval', 150)
    const delay = get(options, 'delay', 0)
    let savedError = null


    if (delay > 0) {
        await new Promise((res) => {
fork icon12
star icon32
watch icon10

+ 19 other calls in file

122
123
124
125
126
127
128
129
130
131

for (let i = 0; i < bankTransactionsData.length; i++) {

    // User can cancel the task at any time, in this all operations should be stopped
    task = await bankSyncTaskUtils.getOne(context, { id: taskId })
    const taskStatus = get(task, 'status')
    if (!task || taskStatus !== TASK_PROCESSING_STATUS) {
        logger.info({ msg: 'status != processing. Aborting processing bank transactions loop', taskStatus, taskSchemaName: bankSyncTaskUtils.gql.SINGULAR_FORM, taskId })
        return
    }
fork icon12
star icon32
watch icon10

+ 4 other calls in file

1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
value.projectType = 'Project';
value.descriptionGeneral = 'Purchase order confirmation.';
value.locationType = 'Location';

try {
    const orderNumber = _.get(value, 'idLocal');
    value.idSystemLocal = orderNumberToCALSId[orderNumber];

    if (!Object.hasOwnProperty.call(productCodeToCALSId, value.idSystemLocal)) {
        productCodeToCALSId[value.idSystemLocal] = {};
fork icon10
star icon3
watch icon5

+ 4 other calls in file

99
100
101
102
103
104
105
106
107
108
        op: op,
        options: self.$__.saveOptions,
        _doc: self._doc
    }
} else if (self instanceof mongoose.Aggregate) {
    collection = _.get(self, '_model.collection.collectionName');
    req = {
        collection,
        op: 'aggregate',
        _pipeline: self._pipeline,
fork icon6
star icon429
watch icon7

97
98
99
100
101
102
103
104
105
106
]

// When OIDC is configured, some more configuration is required
if (config.oidc) {
  const redirectUri = _.get(config, 'oidc.redirect_uri')
  const redirectUris = _.get(config, 'oidc.redirect_uris')
  if (redirectUri && _.isEmpty(redirectUris)) {
    _.set(config, 'oidc.redirect_uris', [redirectUri])
  }
  requiredConfigurationProperties.push(
fork icon88
star icon199
watch icon22

+ 5 other calls in file

833
834
835
836
837
838
839
840
841
842
843
  ])
  return shortcut
}


function fromShortcutSecretResource (secret) {
  const shortcutsBase64 = _.get(secret, 'data.shortcuts')
  const shortcuts = yaml.load(decodeBase64(shortcutsBase64))
  return _
    .chain(shortcuts)
    .map(pickShortcutValues)
fork icon88
star icon199
watch icon22

+ 43 other calls in file

15
16
17
18
19
20
21
22
23
24
25
26
module.exports = [
    // Raw request body update
    function (context, run, done) {
        if (!context.item) { return done(new Error('Nothing to update body.')); }


        let request = _.get(context.item, 'request'),
            requestBody = _.get(request, 'body'),
            rawContent;


        // bail out if raw language is not json
fork icon92
star icon181
watch icon34

+ 15 other calls in file

173
174
175
176
177
178
179
180
181
    })
  )
);

const filterBrowserifyTransforms = _.curry((defaults, filtered, pkg) => {
  const transforms = _.get(pkg, 'browserify.transform', []).reduce((acc, tx) => {
    if (_.isArray(tx)) {
      tx = tx[0];
    }
fork icon305
star icon154
watch icon43

+ 7 other calls in file

51
52
53
54
55
56
57
58
59
60
let processedUserPayload;
const { appId, advertiserId, deduplicationKey, sendingUnHashedData } = Config;
// ref: https://s.pinimg.com/ct/docs/conversions_api/dist/v3.html
const processedCommonPayload = processCommonPayload(message);

processedCommonPayload.event_id = get(message, `${deduplicationKey}`) || message.messageId;
const userPayload = constructPayload(message, USER_CONFIGS, 'pinterest');
const isValidUserPayload = checkUserPayloadValidity(userPayload);
if (isValidUserPayload === false) {
  throw new InstrumentationError(
fork icon74
star icon52
watch icon20

30
31
32
33
34
35
36
37
38
39
}

const keyWithoutArrayLogic = regExpResult[1];
if (regExpResult[2] === '-' || regExpResult[3] === '-') {
  // unshift
  const array = _.get(object, keyWithoutArrayLogic);
  _.set(object, keyWithoutArrayLogic, array ? [value, ...array] : [value]);
} else {
  // push
  const array = _.get(object, keyWithoutArrayLogic);
fork icon59
star icon212
watch icon8

+ 2 other calls in file

Other functions in lodash

Sorted by popularity

function icon

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