How to use the lodash.get function in lodash

To help you get started, we’ve selected a few lodash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reactioncommerce / reaction / server / methods / accounts / accounts.js View on Github external
const currentUser = Meteor.users.findOne(this.userId);
  const currentUserName = getCurrentUserName(currentUser);
  // uses primaryShop's data (name, address etc) in email copy sent to new merchant
  const dataForEmail = getDataForEmail({ shop: primaryShop, currentUserName, name, token, emailLogo });

  Meteor.users.update(userId, {
    $set: {
      "services.password.reset": { token, email, when: new Date() },
      name,
      "profile.preferences.reaction.activeShopId": shopId
    }
  });

  Reaction.Email.send({
    to: email,
    from: `${_.get(dataForEmail, "primaryShop.name")} <${_.get(dataForEmail, "primaryShop.emails[0].address")}>`,
    subject: SSR.render(subject, dataForEmail),
    html: SSR.render(tpl, dataForEmail)
  });

  return true;
}
github tracking-exposed / facebook / routes / events.js View on Github external
function processEvents(req) {

    var ipaddr = _.get(req.headers, "x-forwarded-for") || "127.0.0.1";
    var geoip = utils.getGeoIP(ipaddr);
    var geoinfo = geoip.code;

    if(!geoinfo) {
        geoinfo = geoip.ip;
        if(geoinfo !== "127.0.0.1") {
            // debug("Anomaly, unresolved IP different from localhost: %s", geoinfo);
            geoinfo = "redacted";
        }
    }

    var headers = processHeaders(_.get(req, 'headers'), {
        'content-length': 'length',
        'x-fbtrex-build': 'build',
        'x-fbtrex-version': 'version',
        'x-fbtrex-userid': 'supporterId',
github cncjs / cncjs / src / app / controllers / Smoothie / Smoothie.js View on Github external
.value();

        for (let i = 0; i < words.length; ++i) {
            const word = words[i];

            // Gx, Mx
            if (word.indexOf('G') === 0 || word.indexOf('M') === 0) {
                const r = _.find(SMOOTHIE_MODAL_GROUPS, (group) => {
                    return _.includes(group.modes, word);
                });

                if (!r) {
                    continue;
                }

                const prevWord = _.get(payload, 'modal.' + r.group, '');
                if (prevWord) {
                    _.set(payload, 'modal.' + r.group, ensureArray(prevWord).concat(word));
                } else {
                    _.set(payload, 'modal.' + r.group, word);
                }

                continue;
            }

            // T: tool number
            if (word.indexOf('T') === 0) {
                _.set(payload, 'tool', word.substring(1));
                continue;
            }

            // F: feed rate
github strapi / strapi-examples / gatsby-strapi-tutorial / cms / plugins / users-permissions / controllers / Auth.js View on Github external
connect: async (ctx, next) => {
    const grantConfig = await strapi.store({
      environment: '',
      type: 'plugin',
      name: 'users-permissions',
      key: 'grant'
    }).get();

    const [ protocol, host ] = strapi.config.url.split('://');
    _.defaultsDeep(grantConfig, { server: { protocol, host } });

    const provider = process.platform === 'win32' ? ctx.request.url.split('\\')[2] : ctx.request.url.split('/')[2];
    const config = grantConfig[provider];

    if (!_.get(config, 'enabled')) {
      return ctx.badRequest(null, 'This provider is disabled.');
    }

    const Grant = require('grant-koa');
    const grant = new Grant(grantConfig);

    return strapi.koaMiddlewares.compose(grant.middleware)(ctx, next);
  },
github vue-generators / vue-form-generator / src / fields / abstractField.js View on Github external
this.schema.set(this.model, newValue);
				changed = true;
			} else if (this.schema.model) {
				this.setModelValueByPath(this.schema.model, newValue);
				changed = true;
			}

			if (changed) {
				this.$emit("model-updated", newValue, this.schema.model);

				if (isFunction(this.schema.onChanged)) {
					this.schema.onChanged.call(this, this.model, newValue, oldValue, this.schema);
				}

				if (objGet(this.formOptions, "validateAfterChanged", false) === true) {
					if (objGet(this.schema, "validateDebounceTime", objGet(this.formOptions, "validateDebounceTime", 0)) > 0) {
						this.debouncedValidate();
					} else {
						this.validate();
					}
				}
			}
		},
github elastic / kibana / x-pack / legacy / plugins / canvas / public / state / selectors / workpad.ts View on Github external
export function getSelectedPage(state: State): string {
  const pageIndex = getSelectedPageIndex(state);
  const pages = getPages(state);
  return get(pages, `[${pageIndex}].id`);
}
github bmd-studio / stm32-for-vscode / init.js View on Github external
_.map(configArray, (config, ind) => {
    if (_.get(config, checkPath) === _.get(configObj, checkPath)) {
      hasConfig = true;
      if (!_.isEqual(config, configObj)) {
        hasConfig = false;
        configArray.splice(ind, 1);
      }
    }
  });
  return hasConfig;
github poooi / poi / views / components / main / parts / repair-panel.es View on Github external
const dockName =
                dock.api_state == -1
                  ? this.props.t('main:Locked')
                  : dock.api_state == 0
                  ? this.props.t('main:Empty')
                  : displayShipName
                  ? this.props.t(
                      `resources:${$ships[ships[dock.api_ship_id].api_ship_id].api_name}`,
                    )
                  : ''
              const completeTime = dock.api_complete_time || -1
              let hpPercentage
              if (dock.api_state > 0) {
                hpPercentage =
                  (100 * get(ships, [dock.api_ship_id, 'api_nowhp'])) /
                  get(ships, [dock.api_ship_id, 'api_maxhp'])
              }
              return (
                
                  
                    {enableAvatar && (
                      <>
                        {dock.api_state > 0 ? (
github nestjs / graphql / lib / graphql-ast.explorer.ts View on Github external
return inputs.map(element => {
      const { name, required } = this.getFieldTypeDefinition(element.type);
      return {
        name: get(element, 'name.value'),
        type: name,
        hasQuestionToken: !required,
        kind: StructureKind.Parameter,
      };
    });
  }