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

TypeScript lodash.trimEnd函数代码示例

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

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



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

示例1: trimAndRemoveQuotes

export const csvToMap = (csv: string): MapResult => {
  let errors = []
  const trimmed = _.trimEnd(csv, '\n')
  const parsedTVS = Papa.parse(trimmed)
  const templateValuesData: string[][] = _.get(parsedTVS, 'data', [[]])

  if (templateValuesData.length === 0) {
    return {values: {}, errors}
  }

  const keys = new Set<string>()
  let values = {}

  for (const arr of templateValuesData) {
    if (arr.length === 2 || (arr.length === 3 && arr[2] === '')) {
      const key = trimAndRemoveQuotes(arr[0])
      const value = trimAndRemoveQuotes(arr[1])

      if (!keys.has(key) && key !== '') {
        values[key] = value
        keys.add(key)
      }
    } else {
      errors = [...errors, arr[0]]
    }
  }

  return {values, errors}
}
开发者ID:influxdata,项目名称:influxdb,代码行数:29,代码来源:mapBuilder.ts


示例2: getSymmetryName

export function getSymmetryName({ group, sub }: Symmetry) {
  if ('TOI'.includes(group)) {
    const prefix = sub === 'h' ? 'full' : 'chiral';
    const base = (() => {
      switch (group) {
        case 'T':
          return 'tetrahedral';
        case 'O':
          return 'octahedral';
        case 'I':
          return 'icosahedral';
        default:
          return '';
      }
    })();
    return `${prefix} ${base}`;
  }
  if (group === 'C') {
    if (sub === 's') {
      return 'bilateral';
    }
    if (sub === '2v') {
      return 'biradial';
    }
    const n = parseInt(_.trimEnd(sub, 'v'), 10);
    return polygonPrefixes.get(n) + ' pyramidal';
  }
  if (group === 'D') {
    const last = sub.substr(sub.length - 1);
    if (last === 'h') {
      const n = parseInt(_.trimEnd(sub, 'h'), 10);
      return polygonPrefixes.get(n) + ' prismatic';
    }
    if (last === 'd') {
      const n = parseInt(_.trimEnd(sub, 'd'), 10);
      return polygonPrefixes.get(n) + ' antiprismatic';
    }

    const n = parseInt(sub, 10);
    return polygonPrefixes.get(n) + ' dihedral';
  }
  throw new Error('invalid group');
}
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:43,代码来源:symmetry.ts


示例3: getOrder

export function getOrder(name: string) {
  const { group, sub } = getSymmetry(name);
  if ('TOI'.includes(group)) {
    const mult = sub === 'h' ? 2 : 1;
    const base = (() => {
      switch (group) {
        case 'T':
          return 12;
        case 'O':
          return 24;
        case 'I':
          return 60;
        default:
          return 0;
      }
    })();
    return base * mult;
  }
  if (group === 'C') {
    if (sub === 's') {
      return 2;
    }
    const n = parseInt(_.trimEnd(sub, 'v'), 10);
    return 2 * n;
  }
  if (group === 'D') {
    const last = sub.substr(sub.length - 1);
    if (last === 'h') {
      const n = parseInt(_.trimEnd(sub, 'h'), 10);
      return 4 * n;
    }
    if (last === 'd') {
      const n = parseInt(_.trimEnd(sub, 'd'), 10);
      return 4 * n;
    }

    const n = parseInt(sub, 10);
    return 2 * n;
  }
  throw new Error('invalid group');
}
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:41,代码来源:symmetry.ts


示例4: to

export const addDestinationToFluxScript = (
  script: string,
  options: TaskOptions
): string => {
  const {toOrgName, toBucketName} = options

  if (toOrgName && toBucketName) {
    const trimmedScript = _.trimEnd(script)
    const trimmedOrgName = toOrgName.trim()
    const trimmedBucketName = toBucketName.trim()
    return `${trimmedScript}\n  |> to(bucket: "${trimmedBucketName}", org: "${trimmedOrgName}")`
  }

  return script
}
开发者ID:influxdata,项目名称:influxdb,代码行数:15,代码来源:taskOptionsToFluxScript.ts


示例5: getLogger

export function getLogger(name: string): Logger {
  if (!options.enabled) {
    return new Proxy({}, { get: () => _.noop }) as Logger;
  }
  const label = _.trimEnd(name, 'Impl');
  if (cache.has(label)) {
    return cache.get(label);
  }
  const childLogger = logger.child({ label });
  const wrappedLogger = {
    debug: (s: string, ...args) => childLogger.debug(util.format(s, ...args)),
    info: (s: string, ...args) => childLogger.info(util.format(s, ...args)),
    warn: (s: string, ...args) => childLogger.warn(util.format(s, ...args)),
    error: (s: string, ...args) => childLogger.error(util.format(s, ...args))
  };
  cache.set(label, wrappedLogger);
  return wrappedLogger;
}
开发者ID:HarryTmetic,项目名称:r2,代码行数:18,代码来源:index.ts


示例6: trimStart

import {trim, trimStart, trimEnd, pad, padStart, padEnd} from "lodash";

const trimStr: string = "     trim        ";
console.log("trimStart()");
console.log("*" + trimStart(trimStr) + "*");
console.log("trimEnd()");
console.log("*" + trimEnd(trimStr) + "*");
console.log("trim()");
console.log("*" + trim(trimStr) + "*");


const padStr: string = "pad";
console.log("padStart()");
console.log(padStart(padStr, 10, "_"));
console.log("padEnd()");
console.log(padEnd(padStr, 10, "_"));
console.log("pad()");
console.log(pad(padStr, 10, "_"));

开发者ID:kwpeters,项目名称:node-sandbox,代码行数:18,代码来源:lodashTest.ts


示例7: BaseUrl

 public set BaseUrl(value) {
     if (!value) { throw new Error('BaseUrlMissing'); }
     
     //this.baseUrl = value.TrimEnd('/');
     this.baseUrl = _.trimEnd(value, '/');
 }
开发者ID:alexziskind1,项目名称:msgraphtests,代码行数:6,代码来源:BaseClient.ts


示例8: getFrequency

  public async getFrequency(response, url) {
    const words: any = {};
    if (response.text) {
      for (const t of response.text) {
        this.getFrequencyByText(t, words);
      }
    }

    if (response.links) {
      for (const link of response.links) {
        if (!link.content.text) {
          console.log('content not found for line ', link);
        }

        for (const t of link.content.text) {
          this.getFrequencyByText(t, words);
        }
      }
    }

    const wordsList: any[] = [];

    Object.keys(words).forEach(key => {
      wordsList.push({
        ideogram: key,
        total: words[key],
      });
    });

    const publicationCode = trimEnd(url, '/')
      .split('/')
      .pop();

    for (const word of wordsList) {
      const publicationFrequency = await knex('publication_frequency').where({
        code: publicationCode,
        ideogram: ideogramConverter.convertIdeogramsToUtf16(word.ideogram),
      });

      if (publicationFrequency.length) {
        continue;
      }

      await knex('publication_frequency').insert({
        code: publicationCode,
        ideogram: ideogramConverter.convertIdeogramsToUtf16(word.ideogram),
        total: word.total,
        created_at: new Date(),
      });
    }

    await knex.raw(`UPDATE (
      SELECT ideogram, SUM(total) total
      FROM publication_frequency
      GROUP BY ideogram
    ) a
    JOIN cjk c ON c.ideogram = a.ideogram
    SET c.usage = a.total`);

    return orderBy(wordsList, ['total'], ['desc']);
  }
开发者ID:pierophp,项目名称:pinyin,代码行数:61,代码来源:frequency.ts


示例9: getName

 public getName (lb: IGceLoadBalancer, application: Application): string {
   const loadBalancerName = [application.name, (lb.stack || ''), (lb.detail || '')].join('-');
   return trimEnd(loadBalancerName, '-');
 }
开发者ID:jcwest,项目名称:deck,代码行数:4,代码来源:commonLoadBalancer.controller.ts


示例10: each

    /**
     * @param request
     * @returns {Promise<T>}
     */
    send<T>( request: HttpRequest ): Promise<HttpResponse<T>> {

        let requestConfig: RequestInit = {
            cache : "no-cache",
            method: request.getMethod() as any,
        };

        let url: string = request.getPath();

        let timeout = request.getTimeout();

        if ( request.getBodyParams() ) {
            requestConfig.body = request.getBodyParams();
        }

        if ( !isEmpty(request.getHeaderParams()) ) {
            if ( !requestConfig.headers ) {
                requestConfig.headers = {};
            }
            each(request.getHeaderParams(), ( value, name ) => {
                requestConfig.headers[name] = value;
            });
        }

        if ( !isEmpty(request.getQueryParams()) ) {
            url += '?';
            each(request.getQueryParams(), ( param, name ) => {
                if ( isArray(param) ) {
                    param.forEach(value => {
                        url += `${name}[]=${value}&`;
                    })
                } else {
                    url += `${name}=${param}&`;
                }
            });
            url = trimEnd(url, '&');
        }

        return new Promise(( resolve, reject ) => {
            let rejected = false;

            let timeoutInterval: any = setTimeout(
                () => {
                    rejected = true;
                    reject(new HttpResponse(0, 'Application error', request, 'Timeout of ' + timeout + 'ms exceeded for ' + url, {}));
                },
                timeout
            );

            function returnAsJSON( response, request: HttpRequest, callback: Function ) {
                const cloned = response.clone();

                cloned
                    .text()
                    .then(data => {
                        let responseData = data;
                        try {
                            responseData = JSON.parse(data);
                        } catch (error) {
                        }

                        callback(new HttpResponse(response.status, response.statusText, request, responseData, response.headers))
                    });
            }

            fetch(url, requestConfig).then(
                response => {
                    if ( rejected ) {
                        return;
                    }
                    clearTimeout(timeoutInterval);

                    if ( response.status >= 200 && response.status < 300 ) {
                        returnAsJSON(response, request, resolve);
                        return;
                    }

                    returnAsJSON(response, request, reject);
                    return;
                },
                error => {
                    if ( !rejected ) {
                        reject(new HttpResponse(0, 'Fetch error', request, error, {}));
                    }
                }
            );
        });
    }
开发者ID:middleout,项目名称:stejar-http,代码行数:92,代码来源:FetchAdapter.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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