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

TypeScript lodash.defaultsDeep函数代码示例

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

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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.defer函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.defaults函数代码示例发布时间: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