How to use the lodash.has 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 spderosso / deja-vu / packages / compiler / src / component-input / operations / captures-to-inputs.operation.ts View on Github external
// it's capturing an input from the context
          const capturedInput = captureToInput(nameOrInput.slice(1));
          inputsFromContext.push({ input: capturedInput, field: nameOrInput });

          return capturedInput + restNode.sourceString;
        } else {
          return nameOrInput + restNode.sourceString;
        }
      } else {
        const name = nameOrInput;
        if (_.has(symbolTable, name)) {
          const stEntry = _.get(symbolTable, name);
          if (stEntry.kind === 'concept' || stEntry.kind === 'app') {
            const component = rest.slice(1)
              .split(NAV_SPLIT_REGEX)[0];
            if (_.has(symbolTable, [name, 'symbolTable', component])) {
              return name + rest;
            }
          } else if (stEntry.kind === 'component') {
            return name + rest;
          } else {
            throw new Error(`Unexpected entry type for ${pretty(stEntry)}`);
          }
        }
        if (_.has(context, name)) {
          const component = rest.slice(1)
            .split('.', 1)[0];
          const memberAndOutputAccess = rest.slice(component.length + 1);
          const [memberAccess, outputAccess] = memberAndOutputAccess.slice(1)
            .split(NAV_SPLIT_REGEX);
          const field = name + '.' + component + '.' + memberAccess;
github ballerina-attic / composer / modules / web / js / ballerina / visitors / swagger-json-gen / resource-definition-visitor.js View on Github external
addParametersAsAnnotations(resourceDefinition, httpMethodJson) {
        // Ignoring the first argument as it is "message" by default.
        if (resourceDefinition.getArguments().length > 1) {
            let parametersArray = [];
            if (_.has(httpMethodJson, 'parameters')) {
                parametersArray = _.get(httpMethodJson, 'parameters');
            } else {
                _.set(httpMethodJson, 'parameters', parametersArray);
            }

            for (const [index, param] of resourceDefinition.getArguments().entries()) {
                if (index > 0 && param.getChildren().length > 0 && param.getChildren()[0].getChildren().length > 0 &&
                        resourceDefinition.getFactory().isAnnotationEntry(param.getChildren()[0].getChildren()[0])) {
                    let paramAlreadyExists = false;
                    for (const existingParameter of parametersArray) {
                        // Check if parameter already exists.
                        const annotation = param.getChildren()[0];
                        const annotationValue = annotation.getChildren()[0].getRightValue();
                        if (this.removeDoubleQuotes(annotationValue) === existingParameter.name) {
                            paramAlreadyExists = true;
                        }
github pump-io / pump.io / test / scrubber-user-inbox-api-test-as-root.js View on Github external
"private stuff is ignored": function(err, act, resp) {
                    assert.ifError(err);
                    assert.isObject(act);
                    assert.isFalse(_.has(act, "_uuid"));
                    assert.include(act, "actor");
                    assert.isObject(act.actor);
                    assert.isFalse(_.has(act.actor, "_user"));
                    assert.include(act, "object");
                    assert.isObject(act.object);
                    assert.isFalse(_.has(act.object, "_user"));
                }
            }
github apostrophecms / absolution / index.js View on Github external
_.each(options.urlAttributes, function(attr) {
        if (_.has(attribs, attr) && attribs[attr].trim()) {
          attribs[attr] = url.resolve(base, attribs[attr]);
          if (options.decorator) {
            attribs[attr] = options.decorator(attribs[attr]);
          }
        }
      });
      result += '<' + name;
github farskipper / ecmaless / packages / ecmaless-compiler / src / c / ImportBlock.js View on Github external
var id = key;
            if(n.as && n.as.type === "Identifier"){
                id = n.as.value;
            }

            if(module && module.commonjs){
                if(!n.is){
                    throw ctx.error(n.loc, "Need to use `is ` when importing js");
                }
                if(n.is.type !== "FunctionType"){
                    throw ctx.error(n.loc, "import `is ` currently only works on functions");
                }
                if(n.is["return"].type !== "Type" || n.is["return"].value !== "Nil"){
                    throw ctx.error(n.loc, "import `is ` currently only works on functions that return Nil");
                }
                if(!_.has(module.commonjs, ["value", key])){
                    throw ctx.error(n.loc, module.commonjs.path + " does not export `" + key);
                }
                if(!_.isFunction(module.commonjs.value[key])){
                    throw ctx.error(n.loc, module.commonjs.path + " export `" + key + " is not a function");
                }

                ctx.scope.set(id, comp(n.is));

                estree.push(e("var",
                    id,
                    e("get",
                        e("id", module_id, n.loc),
                        e("str", key, n.loc),
                        n.loc),
                    n.loc));
                return;
github clay / clay-kiln / lib / core-data / get-variations.js View on Github external
function addVariationField(schema, componentName, variations) {
  if (_.has(variations, componentName)) {
    return addField(schema, variations[componentName]);
  } else {
    return schema;
  }
}
github mjswensen / themer / web / src / PreBuiltList.js View on Github external
const PreBuiltLink = ({ colors, children }) => {
  const { activeColorSet } = useContext(ThemeContext);
  const oppositeColorSet = activeColorSet === 'dark' ? 'light' : 'dark';
  const preparedState = {
    colors,
    activeColorSet: has(colors, activeColorSet) ? activeColorSet : oppositeColorSet,
    calculateIntermediaryShades: {
      dark: !has(colors, 'dark.shade1'),
      light: !has(colors, 'light.shade1'),
    },
  };
  return ({ children });
};
github FirebaseExtended / firebase-queue / src / queue.js View on Github external
} else {
        error = 'options.suppressStack must be a boolean.';
        logger.debug('Queue(): Error during initialization', error);
        throw new Error(error);
      }
    }
    self.processingFunction = constructorArguments[2];
  } else {
    error = 'Queue can only take at most three arguments - queueRef, ' +
      'options (optional), and processingFunction.';
    logger.debug('Queue(): Error during initialization', error);
    throw new Error(error);
  }

  if (_.has(constructorArguments[0], 'tasksRef') &&
      _.has(constructorArguments[0], 'specsRef')) {
    self.tasksRef = constructorArguments[0].tasksRef;
    self.specsRef = constructorArguments[0].specsRef;
  } else if (_.isPlainObject(constructorArguments[0])) {
    error = 'When ref is an object it must contain both keys \'tasksRef\' ' +
      'and \'specsRef\'';
    logger.debug('Queue(): Error during initialization', error);
    throw new Error(error);
  } else {
    self.tasksRef = constructorArguments[0].child('tasks');
    self.specsRef = constructorArguments[0].child('specs');
  }

  self.workers = [];
  for (var i = 0; i < self.numWorkers; i++) {
    var processId = (self.specId ? self.specId + ':' : '') + i;
    self.workers.push(new QueueWorker(
github Kaniwani / kw-frontend / app / containers / QuizInfo / InfoPanel / index.js View on Github external
function InfoPanel({
  id, category, detailLevel, measureRef, contentRect,
}) {
  if (has(contentRect, 'bounds', 'top')) {
    smoothScrollY(contentRect.bounds.top);
  }

  return (
    
      
      
      {category !== 'lessons' &&
        detailLevel > 1 && (
          
            
          
        )}
    
  );
}