当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.includes函数代码示例

本文整理汇总了TypeScript中lodash.includes函数的典型用法代码示例。如果您正苦于以下问题:TypeScript includes函数的具体用法?TypeScript includes怎么用?TypeScript includes使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了includes函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: switch

 }).filter(file => {
   switch (storageType) {
     case StorageType.FILE:
       return file.isFile && (!fileExtensions || includes(fileExtensions, extname(file.name)));
     case StorageType.FOLDER:
       return file.isDirectory;
     default: {
       return file.isDirectory || !fileExtensions || includes(fileExtensions, extname(file.name));
     }
   }
 });
开发者ID:Vrakfall,项目名称:.atom,代码行数:11,代码来源:file-proposal-provider.ts

示例2: schemaValidationErrorToValidationErrorItem

function schemaValidationErrorToValidationErrorItem(schemaValidationError: SchemaValidationError): ValidationErrorItem {
    if (
        _.includes(
            [
                'type',
                'anyOf',
                'allOf',
                'oneOf',
                'additionalProperties',
                'minProperties',
                'maxProperties',
                'pattern',
                'format',
                'uniqueItems',
                'items',
                'dependencies',
            ],
            schemaValidationError.name,
        )
    ) {
        return {
            field: schemaValidationError.property,
            code: ValidationErrorCodes.incorrectFormat,
            reason: schemaValidationError.message,
        };
    } else if (
        _.includes(
            ['minimum', 'maximum', 'minLength', 'maxLength', 'minItems', 'maxItems', 'enum', 'const'],
            schemaValidationError.name,
        )
    ) {
        return {
            field: schemaValidationError.property,
            code: ValidationErrorCodes.valueOutOfRange,
            reason: schemaValidationError.message,
        };
    } else if (schemaValidationError.name === 'required') {
        return {
            field: schemaValidationError.argument,
            code: ValidationErrorCodes.requiredField,
            reason: schemaValidationError.message,
        };
    } else if (schemaValidationError.name === 'not') {
        return {
            field: schemaValidationError.property,
            code: ValidationErrorCodes.unsupportedOption,
            reason: schemaValidationError.message,
        };
    } else {
        throw new Error(`Unknnown schema validation error name: ${schemaValidationError.name}`);
    }
}
开发者ID:YuitoSato,项目名称:0x-launch-kit,代码行数:52,代码来源:utils.ts

示例3: unsetIgnoredSubProperties

        _.keys(one).forEach((key) => {
            let concatPath: string = path ? path + '.' + key : key;
            if (!_.includes(this.options.ignoreProperties, concatPath) && !_.includes(this.options.ignoreSubProperties, concatPath)) {

                unsetIgnoredSubProperties(one[key]);
                unsetIgnoredSubProperties(two[key]);

                let getDeletedProperties = (obj: any, propPath: string = null) => {
                    if (_.isPlainObject(obj)) {
                        for (var objKey of _.keys(obj)) {
                            unsetIgnoredSubProperties(obj[objKey]);
                            getDeletedProperties(obj[objKey], propPath ? propPath + '.' + objKey : objKey);
                        }
                    } else if (_.isBoolean(obj) || _.isDate(obj) || _.isNumber(obj)
                        || _.isNull(obj) || _.isRegExp(obj) || _.isString(obj) || _.isArray(obj)) {
                        result.push(new DeepDiff('deleted', propPath, obj, null));
                    }
                };

                if (_.isPlainObject(one[key])) {
                    if (!_.has(two, key)) {
                        getDeletedProperties(one[key], concatPath);
                    } else {
                        result = _.concat(result, this.deepDiff(one[key], two[key], path ? path + '.' + key : key));
                    }
                } else if (_.isBoolean(one[key]) || _.isDate(one[key]) || _.isNumber(one[key])
                    || _.isNull(one[key]) || _.isRegExp(one[key]) || _.isString(one[key])) {
                    if (!_.has(two, key)) {
                        result.push(new DeepDiff('deleted', concatPath, one[key], null));
                    } else if (_.isDate(one[key]) || _.isDate(two[key])) {
                        if (new Date(one[key]).valueOf() !== new Date(two[key]).valueOf()) {
                            result.push(new DeepDiff('edited', concatPath, new Date(one[key]), new Date(two[key])));
                        }
                    } else if (hash(one[key]) !== hash(two[key])) {
                        result.push(new DeepDiff('edited', concatPath, one[key], two[key]));
                    }
                } else if (_.isArray(one[key]) && _.isArray(two[key]) && !_.isEqual(one[key], two[key])) {
                    for (var i = 0; i < one[key].length; i++) {
                        unsetIgnoredSubProperties(one[key][i]);
                    }
                    for (var i = 0; i < two[key].length; i++) {
                        unsetIgnoredSubProperties(two[key][i]);
                    }
                    if (hash(one[key]) !== hash(two[key])) {
                        result.push(new DeepDiff('array', concatPath, one[key], two[key]));
                    }
                } else if (!_.has(two, key)) {
                    getDeletedProperties(one[key], concatPath);
                }
            }
        });
开发者ID:hydra-newmedia,项目名称:chrobject,代码行数:51,代码来源:EntryAppService.ts

示例4: function

 descriptor.value =  async function(...args: any[]) {
     try {
         const result = await originalMethod.apply(this, args);
         return result;
     } catch (error) {
         if (_.includes(error.message, constants.INVALID_JUMP_PATTERN)) {
             throw new Error(ZeroExError.InvalidJump);
         }
         if (_.includes(error.message, constants.OUT_OF_GAS_PATTERN)) {
             throw new Error(ZeroExError.OutOfGas);
         }
         throw error;
     }
 };
开发者ID:linki,项目名称:0x.js,代码行数:14,代码来源:decorators.ts

示例5: isConwaySymbol

export function isConwaySymbol(symbol: string) {
  if (!!platonicMapping.get(symbol) || !!archimedeanMapping.get(symbol)) {
    return true;
  }
  const prefix = symbol[0];
  const number = parseInt(symbol.substring(1), 10);
  if (prefix === 'J' && number >= 0 && number <= 92) {
    return true;
  }
  if (_.includes(['P', 'A'], prefix) && _.includes(polygons, number)) {
    return true;
  }
  return false;
}
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:14,代码来源:names.ts

示例6:

			items = _.filter(_.uniq(items), (item: BaseModel<any>) => {
				if (_.includes(filters, "node") && item instanceof NodeModel) {
					return true;
				}
				if (_.includes(filters, "link") && item instanceof LinkModel) {
					return true;
				}
				if (_.includes(filters, "port") && item instanceof PortModel) {
					return true;
				}
				if (_.includes(filters, "point") && item instanceof PointModel) {
					return true;
				}
				return false;
			});
开发者ID:ajthinking,项目名称:react-diagrams,代码行数:15,代码来源:DiagramModel.ts

示例7: function

 let processProject = function (project: ProjectModel, count?: number) {
   let username = project.user;
   let uniqueName = project.unique_name;
   if (!_.includes(newState.userNames, username)) {
     newState.userNames.push(username);
     newState.byUserNames[username] = new UserModel();
   }
   if (!_.includes(newState.byUserNames[username].projects, uniqueName)) {
     newState.byUserNames[username].projects.push(uniqueName);
   }
   if (count != null) {
     newState.byUserNames[username].num_projects = count;
   }
   return newState;
 };
开发者ID:ttsvetanov,项目名称:polyaxon,代码行数:15,代码来源:projects.ts

示例8: parseDateMath

export function parseDateMath(mathString, time, roundUp?) {
  var dateTime = time;
  var i = 0;
  var len = mathString.length;

  while (i < len) {
    var c = mathString.charAt(i++);
    var type;
    var num;
    var unit;

    if (c === '/') {
      type = 0;
    } else if (c === '+') {
      type = 1;
    } else if (c === '-') {
      type = 2;
    } else {
      return undefined;
    }

    if (isNaN(mathString.charAt(i))) {
      num = 1;
    } else if (mathString.length === 2) {
      num = mathString.charAt(i);
    } else {
      var numFrom = i;
      while (!isNaN(mathString.charAt(i))) {
        i++;
        if (i > 10) { return undefined; }
      }
      num = parseInt(mathString.substring(numFrom, i), 10);
    }

    if (type === 0) {
      // rounding is only allowed on whole, single, units (eg M or 1M, not 0.5M or 2M)
      if (num !== 1) {
        return undefined;
      }
    }
    unit = mathString.charAt(i++);

    if (!_.includes(units, unit)) {
      return undefined;
    } else {
      if (type === 0) {
        if (roundUp) {
          dateTime.endOf(unit);
        } else {
          dateTime.startOf(unit);
        }
      } else if (type === 1) {
        dateTime.add(num, unit);
      } else if (type === 2) {
        dateTime.subtract(num, unit);
      }
    }
  }
  return dateTime;
}
开发者ID:Sensetif,项目名称:grafana,代码行数:60,代码来源:datemath.ts

示例9:

export const isTutke2 = viite => {
    if (viite == null || viite.tutkinnonOsa == null || viite.tutkinnonOsa.tyyppi == null) {
        return false;
    }

    return _.includes(yhteisetTutkinnonOsat, viite.tutkinnonOsa.tyyppi);
};
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:7,代码来源:yleinenData.ts

示例10:

        _.forEach(virtualStudy.data.studies, study => {

            // check if the study in this virtual study is already in the selected studies list
            // and only add the samples if its not already present
            if (!_.includes(selectedPhysicalStudyIds, study.id)) {
                filteredMutationSamples[study.id] = filteredMutationSamples[study.id] || {};
                filteredCnaSamples[study.id] = filteredCnaSamples[study.id] || {};
                filteredMutationCnaSamples[study.id] = filteredMutationCnaSamples[study.id] || {};
                filteredallSamples[study.id] = filteredallSamples[study.id] || {};

                _.forEach(study.samples, sampleId => {
                    if (mutationSamples[study.id] && mutationSamples[study.id][sampleId]) {
                        filteredMutationSamples[study.id][sampleId] = sampleId;
                    }
                    if (cnaSamples[study.id] && cnaSamples[study.id][sampleId]) {
                        filteredCnaSamples[study.id][sampleId] = sampleId;
                    }
                    if (mutationCnaSamples[study.id] && mutationCnaSamples[study.id][sampleId]) {
                        filteredMutationCnaSamples[study.id][sampleId] = sampleId;
                    }
                    if (allSamples[study.id] && allSamples[study.id][sampleId]) {
                        filteredallSamples[study.id][sampleId] = sampleId;
                    }
                });
            }
        });
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:26,代码来源:QueryStoreUtils.ts


注:本文中的lodash.includes函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。