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


TypeScript lodash.mergeWith函数代码示例

本文整理汇总了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;未经允许,请勿转载。