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