當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。