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


TypeScript ramda.replace函数代码示例

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


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

示例1: formatRemotes

export function formatRemotes(remotes: string[]) : string[] {
  const process = R.compose(
    R.uniq,
    R.map(R.replace(/\/$/, '')),
    R.reject(R.isEmpty),
    R.map(R.replace(/\n/, '')),
    R.map(R.trim),
    R.map(rem => rem.replace(/\/\/(.+)@github/, '//github')),
    R.map(rem =>
      rem.match(/github\.com/)
        ? rem.replace(/\.git(\b|$)/, '')
        : rem),
    R.reject(R.isNil),
    R.map(rem => {
      if (rem.match(/^https?:/)) {
        return rem.replace(/\.git(\b|$)/, '');
      } else if (rem.match(/@/)) {
        return 'https://' +
          rem
            .replace(/^.+@/, '')
            .replace(/\.git(\b|$)/, '')
            .replace(/:/g, '/');
      } else if (rem.match(/^ftps?:/)) {
        return rem.replace(/^ftp/, 'http');
      } else if (rem.match(/^ssh:/)) {
        return rem.replace(/^ssh/, 'https');
      } else if (rem.match(/^git:/)) {
        return rem.replace(/^git/, 'https');
      }
    })
  );

  return process(remotes);
}
开发者ID:d4rkr00t,项目名称:vscode-open-in-github,代码行数:34,代码来源:common.ts

示例2: addMiddleware

      addMiddleware(node, (call, next) => {
        // only actions for now
        const skip = call.type !== "action"

        // skip this middleware?
        if (skip) {
          return next(call)
        }

        // userland opt-out
        const shouldSend = mstFilter(call)
        if (!shouldSend) {
          return next(call)
        }

        // grab the arguments
        const args = convertUnsafeArguments(call.args)
        const path = getPath(call.context)

        // action related data
        const action = { args: args, name: call.name, path }

        // mst internal data
        const mstPayload = {
          id: call.id,
          parentId: call.parentId,
          rootId: call.rootId,
          type: call.type,
          modelType: getType(node),
          alive: isAlive(node),
          root: isRoot(node),
          protected: isProtected(node),
        }

        // start a timer
        const elapsed = reactotron.startTimer()

        // chain off to the next middleware
        const result = next(call)

        // measure the speed
        const ms = elapsed()

        // add nice display name
        const displayPath = replace(/^\./, "", replace(/\//g, ".", path))
        let name = replace(/^\./, "", `${nodeName ? nodeName : ""}${displayPath}.${call.name}()`)
        name = replace("/", ".", name)
        // fire this off to reactotron
        if (!restoring) {
          reactotron.send("state.action.complete", {
            name,
            action,
            mst: mstPayload,
            ms,
          })
        }

        // return the result of the next middlware
        return result
      })
开发者ID:TheIdhem,项目名称:reactotron,代码行数:60,代码来源:reactotron-mst.ts

示例3: exec

    exec('git branch --no-color -a', options, (error, stdout, stderr) => {
      if (stderr || error) return reject(stderr || error);

      const getCurrentBranch = R.compose(
        R.trim,
        R.replace('*', ''),
        R.find(line => line.startsWith('*')),
        R.split('\n')
      );

      const processBranches = R.compose(
        R.filter(br => stdout.match(new RegExp(`remotes\/.*\/${br}`))),
        R.uniq
      );

      const currentBranch = getCurrentBranch(stdout);
      const branches = processBranches([currentBranch, defaultBranch]);

      return excludeCurrentRevision
        ? resolve(branches)
        : getCurrentRevision(exec, projectPath)
            .then((currentRevision) => {
              return resolve(branches.concat(currentRevision));
            });
    });
开发者ID:d4rkr00t,项目名称:vscode-open-in-github,代码行数:25,代码来源:common.ts

示例4:

import * as R from 'ramda'

const someSymbolsDelete = R.replace(/[(!?.,)]/g, '')
const fixDoubleSpaces = R.replace(/ {2}/g, ' ')
const someSymbolsToHyphens = R.replace(/[/ ’]/g, '-')

const composeQuery = (word: string) => {
    const escapedWord = R.pipe(
        R.toLower,
        someSymbolsDelete,
        R.trim,
        fixDoubleSpaces,
        someSymbolsToHyphens
    )(word)

    const dictionaryUrl = `https://www.ldoceonline.com/dictionary/${escapedWord}`

    const queryUrl = `https://cors-anywhere.herokuapp.com/${dictionaryUrl}`

    return queryUrl
}

export default composeQuery
开发者ID:yakhinvadim,项目名称:longman-to-anki,代码行数:23,代码来源:composeQuery.ts

示例5:

const replaceLastSpace = s => R.reverse(R.replace(SPACE, NEW_LINE, R.reverse(s)));
开发者ID:paucls,项目名称:katas,代码行数:1,代码来源:wrapper.ts

示例6: pipe

import * as sauce from 'reduxsauce';
import { pipe, replace, toUpper } from 'ramda';

const RX_CAPS = /(?!^)([A-Z])/g;

const camelToScreamingSnake = pipe(
  replace(RX_CAPS, '_$1'),
  toUpper
);

export const createReducer = sauce.createReducer;

export const createActions = (actions) => {
  const { Creators: Actions } = sauce.createActions(actions);

  Object.keys(actions).forEach((key) => {
    Actions[key].toString = () => camelToScreamingSnake(key);
  });

  return Actions;
};
开发者ID:zanjs,项目名称:wxapp-typescript,代码行数:21,代码来源:createActions.ts

示例7: any

const anyPrivate = (hints: CacheControlHintsFormat): boolean => compose<CacheControlHintsFormat, MaybeCacheScope[], boolean>(
  any(equals('PRIVATE')) as any,
  pluck('scope')
)(hints)

const anySegment = (hints: CacheControlHintsFormat): boolean => compose<CacheControlHintsFormat, MaybeCacheScope[], boolean>(
  any(equals('SEGMENT')) as any,
  pluck('scope')
)(hints)

const isPrivateRoute = ({request: {headers}}: GraphQLServiceContext) => test(/_v\/graphql\/private\/v*/, headers['x-forwarded-path'] || '')

const publicRegExp = compose(
  (exp: string) => new RegExp(exp),
  (exp: string) => `.*${exp}.*`,
  replace('.', '\\.')
)(VTEX_PUBLIC_ENDPOINT)

const isPublicEndpoint = ({request: {headers}}: GraphQLServiceContext) => headers.origin
  ? false
  : test(publicRegExp, headers['x-forwarded-host'] || '')

export const cacheControl = (response: GraphQLResponse, ctx: GraphQLServiceContext) => {
  const {vtex: {production}} = ctx
  const hints = response && pickCacheControlHints(response)
  const age = hints && minMaxAge(hints)
  const isPrivate = hints && anyPrivate(hints)
  const segment = hints && anySegment(hints)
  return {
    maxAge: (age === 0 || isPublicEndpoint(ctx) || !production) ? 'no-cache, no-store' : `max-age=${age}`,
    scope: (isPrivate || isPrivateRoute(ctx)) ? 'private' : 'public',
开发者ID:vtex,项目名称:apps-client-node,代码行数:31,代码来源:cacheControl.ts

示例8: removeSpaceFromModule

function removeSpaceFromModule(string: string) {
  return string.replace(moduleWithDelimiterRegex, R.replace(/\W/, ''));
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:3,代码来源:normalizeString.ts

示例9: extractHeadword

import * as R from 'ramda'
import composeQuery from '../composeQuery/composeQuery'
import composeWordData from '../../core/composeWordData/composeWordData'
import extractHeadword from '../../core/extractHeadword/extractHeadword'
import { WordFetchError } from '../../types.d'

const removeDoubleSpace = R.replace(/ {2}/gm, '')
const removeNewLines = R.replace(/\n/gm, '')
const normalizeMarkup = R.pipe(
    removeDoubleSpace,
    removeNewLines
)

const wordNotFound = (markup: string) => extractHeadword(markup) === ''

const wordToData = async (word: string) => {
    let escapedMarkup

    try {
        const query = composeQuery(word)
        escapedMarkup = await fetch(query).then(response => response.text())
    } catch (error) {
        return { status: WordFetchError.Offline }
    }

    const markup = normalizeMarkup(escapedMarkup)

    if (wordNotFound(markup)) {
        return { status: WordFetchError.NotFound }
    } else {
        const wordData = composeWordData(markup)
开发者ID:yakhinvadim,项目名称:longman-to-anki,代码行数:31,代码来源:wordToData.ts

示例10: getCurrency

 /**
  * Return a string for currency
  * @param num The currency to format to string
  */
 static getCurrency(num: any): string {
   return R.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,")(num.toFixed(2));
 }
开发者ID:simbiosis-group,项目名称:ion2-helper,代码行数:7,代码来源:formatter.ts


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