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

TypeScript lodash.mergeWith函数代码示例

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

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



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

示例1: glob

 glob(join(config.APP_SRC, '*', 'client', 'angular.json'), {}, (err2: Error, packageFiles: string[]) => {
   for (const filename of packageFiles) {
     const configuration = JSON.parse(readFileSync(filename, 'utf-8'));
     content = mergeWith(content, configuration, merger);
   }
   writeFileSync('angular.json', JSON.stringify(content, null, 2));
 });
开发者ID:our-city-app,项目名称:gae-plugin-framework,代码行数:7,代码来源:build.angular-json.ts


示例2: immutableMergeWithConcattingArrays

export function immutableMergeWithConcattingArrays(destObject: object, ...sources: object[]): object {
  const clonedDestObject = cloneDeep(destObject);
  return mergeWith(clonedDestObject, ...sources, (objValue, srcValue) => {
    if (Array.isArray(objValue) && Array.isArray(srcValue)) {
      return objValue.concat(srcValue);
    }
  });
}
开发者ID:inspirehep,项目名称:record-editor,代码行数:8,代码来源:utils.ts


示例3: getBabelConfig

export function getBabelConfig (babel) {
  if (!babelConfig) {
    babelConfig = mergeWith({}, defaultBabelConfig, babel, (objValue, srcValue) => {
      if (Array.isArray(objValue)) {
        return Array.from(new Set(srcValue.concat(objValue)))
      }
    })
  }
  return babelConfig
}
开发者ID:YangShaoQun,项目名称:taro,代码行数:10,代码来源:index.ts


示例4:

function asPlainObjectDeep<T>(origianl: T) {
    const removePrototype = (srcVal: any, objVal: any) => {
        if (ng1.isObject(objVal) && !ng1.isArray(objVal)) {
            return _.toPlainObject(objVal);
        } else {
            return objVal;
        }
    };
    return _.mergeWith<T>(Object.create(null), origianl, removePrototype);
}
开发者ID:QuBaR,项目名称:ng-table,代码行数:10,代码来源:jasmine-extensions.ts


示例5: String

    src.forEach((v: webpack.Rule, _i: number) => {
      const existingTest = (obj as webpack.Rule[]).find(
        rule => String(rule.test) === String(v.test)
      );

      if (existingTest) {
        lodash.mergeWith(existingTest, v, defaultMerger);
      } else {
        obj.push(v);
      }
    });
开发者ID:leebenson,项目名称:cli,代码行数:11,代码来源:common.ts


示例6: function

const Config = function(): ConfigType {
  let config: ConfigType = {
    maxPoolSize: 50,
    port: 3000,
    dbHost: process.env.DB_HOST || '127.0.0.1',
    dbName: process.env.DB_NAME || 'bitcore',
    dbPort: process.env.DB_PORT || '27017',
    dbUser: process.env.DB_USER || '',
    dbPass: process.env.DB_PASS || '',
    numWorkers: cpus().length,
    chains: {},
    services: {
      api: {
        rateLimiter: {
          disabled: false,
          whitelist: ['::ffff:127.0.0.1', '::1']
        },
        wallets: {
          allowCreationBeforeCompleteSync: false,
          allowUnauthenticatedCalls: true
        }
      },
      event: {
        onlyWalletEvents: false
      },
      p2p: {},
      socket: {},
      storage: {}
    }
  };

  let foundConfig = findConfig();
  const mergeCopyArray = (objVal, srcVal) => (objVal instanceof Array ? srcVal : undefined);
  config = _.mergeWith(config, foundConfig, mergeCopyArray);
  if (!Object.keys(config.chains).length) {
    Object.assign(config.chains, {
      BTC: {
        mainnet: {
          chainSource: 'p2p',
          trustedPeers: [{ host: '127.0.0.1', port: 8333 }],
          rpc: {
            host: '127.0.0.1',
            port: 8332,
            username: 'bitcoin',
            password: 'bitcoin'
          }
        }
      }
    });
  }
  config = setTrustedPeers(config);
  return config;
};
开发者ID:bitpay,项目名称:bitcore,代码行数:53,代码来源:config.ts


示例7: mergeWith

const recursiveMerge = (src, ...args) => {
  return mergeWith(src, ...args, (value, srcValue, key, obj, source) => {
    const typeValue = typeof value
    const typeSrcValue = typeof srcValue
    if (typeValue !== typeSrcValue) return
    if (Array.isArray(value) && Array.isArray(srcValue)) {
      return value.concat(srcValue)
    }
    if (typeValue === 'object') {
      return recursiveMerge(value, srcValue)
    }
  })
}
开发者ID:YangShaoQun,项目名称:taro,代码行数:13,代码来源:index.ts


示例8: mergeAliases

export function mergeAliases(aliases: ModuleAliases[]): { [moduleCode: string]: ModuleCode[] } {
  // Returning undefined causes mergeWith to use the original merge

  /* eslint-disable consistent-return */
  // @ts-ignore mergeWith allows multiple objects to be merged, but the libdef doesn't
  const merged: ModuleAliases = mergeWith(...aliases, (src, dest) => {
    if (src && dest) return union(src, dest);
  });
  /* eslint-enable */

  // Convert the set to an array to make it easier to output since JSON doesn't
  // encode Sets by default
  return mapValues(merged, (set) => Array.from(set));
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:14,代码来源:CollateModules.ts


示例9: resolveAllOf

function resolveAllOf(inputSpec: any): any {
    if (inputSpec && typeof inputSpec === 'object'
        && Object.keys(inputSpec).length > 0
    ) {
        if (inputSpec.allOf) {
            const allOf = inputSpec.allOf;
            delete inputSpec.allOf;
            const nested = _.mergeWith({}, ...allOf, customizer);
            inputSpec = _.defaultsDeep(inputSpec, nested, customizer);
        }
        Object.keys(inputSpec).forEach((key: string) => {
            inputSpec[key] = resolveAllOf(inputSpec[key]);
        });
    }
    return inputSpec;
}
开发者ID:loganvolkers,项目名称:json-schema-resolve-allof,代码行数:16,代码来源:index.ts


示例10: getAlterationCountsForCancerTypesForAllGenes

export function getAlterationCountsForCancerTypesForAllGenes(alterationsByGeneBySampleKey:{ [geneName:string]: {[sampleId: string]: ExtendedAlteration[]} },
                                                             samplesExtendedWithClinicalData:ExtendedSample[],
                                                             groupByProperty: keyof ExtendedSample){

    const samplesByCancerType = _.groupBy(samplesExtendedWithClinicalData,(sample:ExtendedSample)=>{
        return sample[groupByProperty];
    });
    const flattened = _.flatMap(alterationsByGeneBySampleKey, (map) => map);

    // NEED TO FLATTEN and then merge this to get all alteration by sampleId
    function customizer(objValue: any, srcValue: any) {
        if (_.isArray(objValue)) {
            return objValue.concat(srcValue);
        }
    }
    const merged: { [uniqueSampleKey: string]: ExtendedAlteration[] } =
        (_.mergeWith({}, ...flattened, customizer) as { [uniqueSampleKey: string]: ExtendedAlteration[] });
    return countAlterationOccurences(samplesByCancerType, merged);

}
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:20,代码来源:alterationCountHelpers.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.min函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.merge函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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