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

TypeScript lodash.defaultTo函数代码示例

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

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



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

示例1: stringify

	export function stringify( value: any, ...args: Array<any> ) {
		let options: {
			replacer?: ( key: string, value: any ) => any | Array<number | string>;
			space?: string | number;
			quote?: string;
		};

		if ( reflection.getType( args[ 0 ] ) === reflection.Type.object ) {
			options = args[ 0 ];
		} else {
			options = {
				replacer: args[ 0 ],
				space: _.defaultTo( args[ 1 ], "\t" ),
				quote: args[ 2 ],
			};
		}
		return json5.stringify( value, options );
	}
开发者ID:Novaleaf,项目名称:xlib,代码行数:18,代码来源:serialization.ts


示例2: function

    $scope.validateModel = function() {
      $scope.index = _.indexOf(bucketAggs, $scope.agg);
      $scope.isFirst = $scope.index === 0;
      $scope.bucketAggCount = bucketAggs.length;

      var settingsLinkText = '';
      var settings = $scope.agg.settings || {};

      switch ($scope.agg.type) {
        case 'terms': {
          settings.order = settings.order || 'desc';
          settings.size = settings.size || '10';
          settings.min_doc_count = settings.min_doc_count || 1;
          settings.orderBy = settings.orderBy || '_term';

          if (settings.size !== '0') {
            settingsLinkText = queryDef.describeOrder(settings.order) + ' ' + settings.size + ', ';
          }

          if (settings.min_doc_count > 0) {
            settingsLinkText += 'Min Doc Count: ' + settings.min_doc_count + ', ';
          }

          settingsLinkText += 'Order by: ' + queryDef.describeOrderBy(settings.orderBy, $scope.target);

          if (settings.size === '0') {
            settingsLinkText += ' (' + settings.order + ')';
          }

          break;
        }
        case 'filters': {
          settings.filters = settings.filters || [{ query: '*' }];
          settingsLinkText = _.reduce(
            settings.filters,
            function(memo, value, index) {
              memo += 'Q' + (index + 1) + '  = ' + value.query + ' ';
              return memo;
            },
            ''
          );
          if (settingsLinkText.length > 50) {
            settingsLinkText = settingsLinkText.substr(0, 50) + '...';
          }
          settingsLinkText = 'Filter Queries (' + settings.filters.length + ')';
          break;
        }
        case 'date_histogram': {
          settings.interval = settings.interval || 'auto';
          settings.min_doc_count = settings.min_doc_count || 0;
          $scope.agg.field = $scope.target.timeField;
          settingsLinkText = 'Interval: ' + settings.interval;

          if (settings.min_doc_count > 0) {
            settingsLinkText += ', Min Doc Count: ' + settings.min_doc_count;
          }

          if (settings.trimEdges === undefined || settings.trimEdges < 0) {
            settings.trimEdges = 0;
          }

          if (settings.trimEdges && settings.trimEdges > 0) {
            settingsLinkText += ', Trim edges: ' + settings.trimEdges;
          }
          break;
        }
        case 'histogram': {
          settings.interval = settings.interval || 1000;
          settings.min_doc_count = _.defaultTo(settings.min_doc_count, 1);
          settingsLinkText = 'Interval: ' + settings.interval;

          if (settings.min_doc_count > 0) {
            settingsLinkText += ', Min Doc Count: ' + settings.min_doc_count;
          }
          break;
        }
        case 'geohash_grid': {
          // limit precision to 7
          settings.precision = Math.max(Math.min(settings.precision, 7), 1);
          settingsLinkText = 'Precision: ' + settings.precision;
          break;
        }
      }

      $scope.settingsLinkText = settingsLinkText;
      $scope.agg.settings = settings;
      return true;
    };
开发者ID:cboggs,项目名称:grafana,代码行数:88,代码来源:bucket_agg.ts


示例3: defaultTo

export const typeId = (type: string): Type =>
  defaultTo(namesToTypes[type.trim().toLowerCase()], Type.CURSE);
开发者ID:Sulcata,项目名称:Sulcata-Damage-Calculator,代码行数:2,代码来源:info.ts


示例4: get

export const construct = (config: ServerConfig): {
  rootAppConfig: RootAppConfig,
  cmsConfig: CmsServerConfig,
  graphqlConfig: GqlifyConfig,
  authConfig: AuthConfig,
} => {
  // merge common config with default config
  const authMountPath = defaultConfig.authMountPath;
  const hostname = get(config, 'common.hostname');

  // cookieKeys will override auth & cms cookie config
  const cookieKeys = defaultTo(get(config, 'common.cookieKeys'), defaultConfig.cookieKeys);

  // Whether this cms is public access or not
  const publicAuth = defaultTo(get(config, 'common.public'), defaultConfig.public);

  // oidc clientId & clientSecret are shared between cms & auth services
  const clientId = defaultTo(get(config, 'common.clientId'), defaultConfig.clientId);
  const clientSecret = defaultTo(get(config, 'common.clientSecret'), defaultConfig.clientSecret);

  // oidc issuer
  const discoveryUrlFromHost = `${hostname}${authMountPath}/.well-known/openid-configuration`;
  const discoveryUrl = defaultTo(get(config, 'common.discoveryUrl'), discoveryUrlFromHost);
  const issuerConfig = get(config, 'common.issuerConfig');

  // graphql endpoint
  const graphqlEndpoint = `${hostname}/graphql`;

  // construct config for cms service
  const cmsConfig: CmsServerConfig = merge({
    cookieKeys,
    hostname,
    oidc: {
      discoveryUrl,
      clientId,
      clientSecret,
    },
    logger: jsonLogger,
  }, config.cms);

  // config for gqlify service
  const graphqlConfig: GqlifyConfig = {
    logger: jsonLogger,
    oidc: {
      discoveryUrl,
      issuerConfig,
    },
    ...config.graphql,
  };

  // config for auth service
  let authConfig: AuthConfig = {
    mountPath: defaultConfig.authMountPath,
    issuer: hostname,
    cookies: {
      long: { signed: true, maxAge: (1 * 24 * 60 * 60) * 1000 }, // 1 day in ms
      short: { signed: true },
      keys: cookieKeys,
    },
    redirectUris: [`${hostname}/auth/callback`],
    postLogoutRedirectUris: [`${hostname}/`],
    clientId,
    clientSecret,
    logger: jsonLogger,
    ...config.auth,
  };

  const rootAppConfig = {
    graphqlEndpoint,
    cookieKeys,
  };

  // if publicAuth is true, we make this cms public
  // mark cmsConfig.oidc as null to tell cmsServer we do not need oidc
  // mark graphqlConfig.oidc as null to tell graphql server we do not need auth
  // mark authConfig to null, so auth service won't start
  if (publicAuth) {
    cmsConfig.oidc = null;
    graphqlConfig.oidc = null;
    authConfig = null;
  }

  return {
    rootAppConfig,
    cmsConfig,
    graphqlConfig,
    authConfig,
  };
};
开发者ID:Canner,项目名称:canner,代码行数:89,代码来源:factory.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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