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


TypeScript lodash.defaultsDeep函数代码示例

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


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

示例1: mockRequest

// Exports
export default function mockRequest(
  requestProperties?: Partial<Koa.Request & { body: any }>,
  responseProperties?: Partial<Koa.Response>,
): { request: Koa.Request & { body?: any }; response: Koa.Response } {
  const app = new Koa();
  const req = {};
  const res = {};
  const request = defaultsDeep({ req, res }, requestProperties, {
    app,
    ctx: {},
    header: {
      'cache-control': 'no-cache',
    },
    query: {},
  });

  const response = defaultsDeep({ req, res }, responseProperties, {
    ctx: {},
    status: 200,
  });

  // Add references
  Object.defineProperty(request, 'response', { get: () => response });
  Object.defineProperty(request.ctx, 'response', { get: () => response });
  Object.defineProperty(request.ctx, 'request', { get: () => request });
  Object.defineProperty(response, 'request', { get: () => request });
  Object.defineProperty(response.ctx, 'request', { get: () => request });
  Object.defineProperty(response.ctx, 'response', { get: () => response });

  // Return mocked request response
  return { request, response };
}
开发者ID:komapijs,项目名称:komapi,代码行数:33,代码来源:mockRequest.ts

示例2: getSettingsFromFile

async function getSettingsFromFile(log: ToolingLog, path: string, settingOverrides: any) {
  const configModule = require(path); // eslint-disable-line @typescript-eslint/no-var-requires
  const configProvider = configModule.__esModule ? configModule.default : configModule;

  if (!cache.has(configProvider)) {
    log.debug('Loading config file from %j', path);
    cache.set(
      configProvider,
      configProvider({
        log,
        async readConfigFile(p: string, o: any) {
          return new Config({
            settings: await getSettingsFromFile(log, p, o),
            primary: false,
            path: p,
          });
        },
      })
    );
  }

  const settingsWithDefaults = defaultsDeep({}, settingOverrides, await cache.get(configProvider)!);

  const logDeprecation = (error: string | Error) => log.error(error);
  return transformDeprecations(settingsWithDefaults, logDeprecation);
}
开发者ID:elastic,项目名称:kibana,代码行数:26,代码来源:read_config_file.ts

示例3: createRootWithSettings

export function createRootWithSettings(
  settings: Record<string, any>,
  cliArgs: Partial<CliArgs> = {}
) {
  const env = Env.createDefault({
    configs: [],
    cliArgs: {
      dev: false,
      open: false,
      quiet: false,
      silent: false,
      watch: false,
      repl: false,
      basePath: false,
      optimize: false,
      ...cliArgs,
    },
    isDevClusterMaster: false,
  });

  return new Root(
    new BehaviorSubject(
      new LegacyObjectToConfigAdapter(defaultsDeep({}, settings, DEFAULTS_SETTINGS))
    ),
    env
  );
}
开发者ID:elastic,项目名称:kibana,代码行数:27,代码来源:kbn_server.ts

示例4: savePrimitiveValuesToLocalStorage

  //////////////////////////////////////////////////////////////////////////////////
  // DEPRECATED

  // DEPRECATED
  // NOT RECOMMENDED TO USE
  savePrimitiveValuesToLocalStorage(component: Object, ignores?: Object[]): void {
    let obj = {};
    let objGlobal = {};
    Object.keys(component).forEach(key => {
      if (key.includes('_global')) {
        objGlobal[key] = component[key];
      } else if (typeof component[key] === 'object') {
        const ctorName = component[key].constructor.name;
        const ignorable = ignores && ignores.length > 0 ? ignores.some(ignore => ctorName === ignore.constructor.name) : false;
        if (!ignorable) {
          obj[key] = component[key];
        }
      } else {
        obj[key] = component[key];
      }
    });
    try {
      const key = LOCAL_STORAGE_KEY + '-' + component.constructor.name;
      window.localStorage.setItem(key, JSON.stringify(obj));
    } catch (err) {
      console.error(err);
    }
    try {
      let ls = window.localStorage.getItem(GLOBAL_LOCAL_STORAGE_KEY);
      ls = ls ? JSON.parse(ls) : {};
      objGlobal = lodash.defaultsDeep(objGlobal, ls);
      window.localStorage.setItem(GLOBAL_LOCAL_STORAGE_KEY, JSON.stringify(objGlobal));
    } catch (err) {
      console.error(err);
    }
  }
开发者ID:ovrmrw,项目名称:shuttle-store-sample,代码行数:36,代码来源:store.controller.ts

示例5: constructor

  constructor(model) {
    this.events = new Emitter();

    // copy properties from persisted model
    for (const property in model) {
      this[property] = model[property];
    }

    // defaults
    _.defaultsDeep(this, _.cloneDeep(defaults));
  }
开发者ID:acedrew,项目名称:grafana,代码行数:11,代码来源:panel_model.ts

示例6: defaultsDeep

 initializationMethod: (command: IRedBlackCommand) => {
   defaultsDeep(command, {
     rollback: {
       onFailure: false,
     },
     maxRemainingAsgs: !command.strategy ? 2 : command.maxRemainingAsgs,
     delayBeforeDisableSec: 0,
     delayBeforeScaleDownSec: 0,
     scaleDown: false,
   });
 },
开发者ID:emjburns,项目名称:deck,代码行数:11,代码来源:redblack.strategy.ts

示例7: setRouteDefaults

export function setRouteDefaults(route: RouteConfig, specific?: Partial<RouteConfig>) {

	route = _.defaultsDeep(specific, defaultConfig, route);

	if (!route.title) {
		route.title = typeof route.route === "string"
			? _.startCase(route.route)
			: _.startCase(route.route[1]);
	}

	return route;
}
开发者ID:sketch7,项目名称:ssv-au-core,代码行数:12,代码来源:routing.util.ts

示例8: constructor

  constructor(model) {
    this.events = new Emitter();

    // copy properties from persisted model
    for (const property in model) {
      this[property] = model[property];
    }

    // defaults
    _.defaultsDeep(this, _.cloneDeep(defaults));
    // queries must have refId
    this.ensureQueryIds();
  }
开发者ID:gnydick,项目名称:grafana,代码行数:13,代码来源:PanelModel.ts

示例9: constructor

  constructor(model: any) {
    this.events = new Emitter();

    // copy properties from persisted model
    for (const property in model) {
      (this as any)[property] = model[property];
    }

    // defaults
    _.defaultsDeep(this, _.cloneDeep(defaults));

    // queries must have refId
    this.ensureQueryIds();
    this.restoreInfintyForThresholds();
  }
开发者ID:johntdyer,项目名称:grafana,代码行数:15,代码来源:PanelModel.ts

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


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