• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript object-hash类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1:

 let indexOf = (array: any[], value: any, fromIndex?: number): number => {
     let startIndex: number = fromIndex ? fromIndex : 0;
     for (var i = startIndex; i < array.length; i++) {
         if (hash(array[i]) === hash(value)) {
             return i;
         }
     }
     return -1;
 };
开发者ID:hydra-newmedia,项目名称:chrobject,代码行数:9,代码来源:DeepDiff.ts


示例2: 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


示例3: getStoreId

function getStoreId(
  resolvedUrl: string|null,
  selectorFilters: ISelectorFilter[]|null = null,
  nodeFilters: string[]|null = null,
) {
  return hash({
    resolvedUrl,
    selectorFilters,
    nodeFilters,
  }, { unorderedArrays: true });
}
开发者ID:maoberlehner,项目名称:node-sass-magic-importer,代码行数:11,代码来源:index.ts


示例4: it

 it('should force global scope when it is not set', () => {
   const scope = 'global';
   const token = factory.create(Module as any, [Module], undefined);
   expect(token).to.be.deep.eq(
     hash({
       module: Module.name,
       dynamic: '',
       scope,
     }),
   );
 });
开发者ID:SARAVANA1501,项目名称:nest,代码行数:11,代码来源:module-token-factory.spec.ts


示例5: validateAll

 validateAll(): void {
   if (!this.objects) { return; }
   for (let object of this.objects) {
     for (let field of object.metadata) {
       field.valid = this.validFieldValues(field);
     }
     /**
      * Taking advantage of a metadata hash bug
      * Update the hash to get status colors to update
      */
     object.metadataHash = hash(object.metadata);
   }
 }
开发者ID:uhlibraries-digital,项目名称:brays,代码行数:13,代码来源:valication.service.ts


示例6: create

 public create(
   metatype: Type<any>,
   scope: Type<any>[],
   dynamicModuleMetadata?: Partial<DynamicModule> | undefined,
 ): string {
   const reflectedScope = this.reflectScope(metatype);
   const isSingleScoped = reflectedScope === true;
   const opaqueToken = {
     module: this.getModuleName(metatype),
     dynamic: this.getDynamicMetadataToken(dynamicModuleMetadata),
     scope: isSingleScoped ? this.getScopeStack(scope) : reflectedScope,
   };
   return hash(opaqueToken);
 }
开发者ID:SARAVANA1501,项目名称:nest,代码行数:14,代码来源:module-token-factory.ts


示例7: setArrayDiffs

    setArrayDiffs(one: any[], two: any[]): void {
        this.arrayDiffs = [];

        let processedItems: { [key: string]: number[] } = {};

        let addToProcessed = (alreadyDoneMap: { [key: string]: number[] }, valHash: string, idx: number) => {
            if (_.has(alreadyDoneMap, valHash)) {
                alreadyDoneMap[valHash].push(idx);
            } else {
                alreadyDoneMap[valHash] = [idx];
            }
        };

        // indexOf function which checks for object hash equality instead of using SameValueZero
        let indexOf = (array: any[], value: any, fromIndex?: number): number => {
            let startIndex: number = fromIndex ? fromIndex : 0;
            for (var i = startIndex; i < array.length; i++) {
                if (hash(array[i]) === hash(value)) {
                    return i;
                }
            }
            return -1;
        };

        // loop through first array to find deletions and index changes
        for (var idxInOne = 0; idxInOne < one.length; idxInOne++) {
            let val: any = one[idxInOne];
            // check whether item is in second array
            if (indexOf(two, val) >= 0) {
                // check whether already processed a similar item
                let valHash: string = hash(val);
                // get idx in second array where the last processed item was moved to
                let idxLastMovedTo: number = _.has(processedItems, valHash) ? _.last<number>(processedItems[valHash]) + 1 : undefined;
                // search from there on
                let idxMovedTo: number = indexOf(two, val, idxLastMovedTo);
                if (idxInOne === idxMovedTo) {
                    // if element stayed, just add it to processed elements
                    addToProcessed(processedItems, valHash, idxInOne);
                } else if (idxMovedTo >= 0) {
                    // if moved, add it to processed elements and output change
                    addToProcessed(processedItems, valHash, idxMovedTo);
                    this.arrayDiffs.push(new ArrayDiff('moved', idxInOne, val, idxMovedTo));
                } else {
                    // if no such element found, output deletion
                    this.arrayDiffs.push(new ArrayDiff('removed', idxInOne, val));
                }
            } else {
                // if not found at all, output deletion
                this.arrayDiffs.push(new ArrayDiff('removed', idxInOne, val));
            }
        }

        // loop through second array to find additions in comparison to first array
        for (var idxInTwo = 0; idxInTwo < two.length; idxInTwo++) {
            let val: any = two[idxInTwo];
            let valHash: string = hash(val);
            // check if element is not in processed elements map or if it is, then not at the same position
            if (!_.has(processedItems, valHash) || _.indexOf(processedItems[valHash], idxInTwo) < 0) {
                // output additions
                this.arrayDiffs.push(new ArrayDiff('added', idxInTwo, val));
            }
        }
    }
开发者ID:hydra-newmedia,项目名称:chrobject,代码行数:63,代码来源:DeepDiff.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript on-finished类代码示例发布时间:2022-05-28
下一篇:
TypeScript object-assign类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap