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

TypeScript ramda.partial函数代码示例

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

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



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

示例1: listMigrations

export function listMigrations(directory: string): Promise<Migration[]> {
  return fs.readdirAsync(directory)
    .map(R.match(MIGRATION_FILE_REGEXP))
    .filter(R.identity)
    .then(R.groupBy(R.nth<string>(1)))
    .then(R.mapObj(R.partial(matchesToMigration, directory)))
    .then(R.values)
    .then(R.sortBy((migration: Migration) => migration.id));
}
开发者ID:programble,项目名称:careen,代码行数:9,代码来源:files.ts


示例2: readDownSQL

export function readDownSQL(migration: Migration): Promise<string> {
  if (migration.split) {
    return fs.readFileAsync(migration.downPath, {encoding: 'utf8'})
      .then(R.trim);
  }
  return fs.readFileAsync(migration.path, {encoding: 'utf8'})
    .then(R.split(MIGRATION_SQL_SPLIT_REGEXP))
    .tap(R.partial(assertSQLSections, migration))
    .then(R.nth(1))
    .then(R.trim);
}
开发者ID:programble,项目名称:careen,代码行数:11,代码来源:files.ts


示例3: merge


//.........这里部分代码省略.........
          await transform(axiosRequestConfig)
        }
      }
    }

    // after the call, convert the axios response, then execute our monitors
    const chain = pipe(
      convertResponse(toNumber(new Date())),
      // partial(convertResponse, [toNumber(new Date())]),
      runMonitors,
    )

    return instance
      .request(axiosRequestConfig)
      .then(chain)
      .catch(chain)
  }

  /**
   * Fires after we convert from axios' response into our response.  Exceptions
   * raised for each monitor will be ignored.
   */
  const runMonitors = ourResponse => {
    monitors.forEach(monitor => {
      try {
        monitor(ourResponse)
      } catch (error) {
        // all monitor complaints will be ignored
      }
    })
    return ourResponse
  }

  /**
   * Converts an axios response/error into our response.
   */
  const convertResponse = curry((startedAt: number, axiosResult: AxiosResponse | AxiosError) => {
    const end: number = toNumber(new Date())
    const duration: number = end - startedAt

    // new in Axios 0.13 -- some data could be buried 1 level now
    const isError = axiosResult instanceof Error || axios.isCancel(axiosResult)
    const axiosResponse = axiosResult as AxiosResponse
    const axiosError = axiosResult as AxiosError
    const response = isError ? axiosError.response : axiosResponse
    const status = (response && response.status) || null
    const problem = isError ? getProblemFromError(axiosResult) : getProblemFromStatus(status)
    const originalError = isError ? axiosError : null
    const ok = in200s(status)
    const config = axiosResult.config || null
    const headers = (response && response.headers) || null
    let data = (response && response.data) || null

    // give an opportunity for anything to the response transforms to change stuff along the way
    let transformedResponse = {
      duration,
      problem,
      originalError,
      ok,
      status,
      headers,
      config,
      data,
    }
    if (responseTransforms.length > 0) {
      forEach(transform => transform(transformedResponse), responseTransforms)
    }

    return transformedResponse
  })

  // create the base object
  const sauce = {
    axiosInstance: instance,
    monitors,
    addMonitor,
    requestTransforms,
    asyncRequestTransforms,
    responseTransforms,
    addRequestTransform,
    addAsyncRequestTransform,
    addResponseTransform,
    setHeader,
    setHeaders,
    deleteHeader,
    headers,
    setBaseURL,
    getBaseURL,
    get: partial(doRequestWithoutBody, ['get']),
    delete: partial(doRequestWithoutBody, ['delete']),
    head: partial(doRequestWithoutBody, ['head']),
    post: partial(doRequestWithBody, ['post']),
    put: partial(doRequestWithBody, ['put']),
    patch: partial(doRequestWithBody, ['patch']),
    link: partial(doRequestWithoutBody, ['link']),
    unlink: partial(doRequestWithoutBody, ['unlink']),
  }
  // send back the sauce
  return sauce
}
开发者ID:skellock,项目名称:apisauce,代码行数:101,代码来源:apisauce.ts


示例4: partial

import { findApp } from './util'
import { FoundBrowser, Browser } from '../types'
import * as linuxHelper from '../linux'
import { log } from '../log'
import { merge, partial } from 'ramda'

const detectCanary = partial(findApp, [
  'Contents/MacOS/Google Chrome Canary',
  'com.google.Chrome.canary',
  'KSVersion'
])
const detectChrome = partial(findApp, [
  'Contents/MacOS/Google Chrome',
  'com.google.Chrome',
  'KSVersion'
])
const detectChromium = partial(findApp, [
  'Contents/MacOS/Chromium',
  'org.chromium.Chromium',
  'CFBundleShortVersionString'
])

type Detectors = {
  [index: string]: Function
}

const browsers: Detectors = {
  chrome: detectChrome,
  canary: detectCanary,
  chromium: detectChromium
}
开发者ID:YOU54F,项目名称:cypress,代码行数:31,代码来源:index.ts


示例5: dissoc

 * @param secure - True if sanitization is required
 * @param data - Object representing a user model
 */
const respond = (secure: boolean, data: User.UserData): User.UserData =>
    secure ? dissoc('password', data) : data;

/**
 * Prepares a user object for database insertion
 */
export const cleanUserData = formatter(format);

/**
 * Returns a sanitised object representing a user, removing private properties
 * @param data - A database record representing a user
 */
export const sanitizedResponse = partial(respond, [true]);

/**
 * Returns a clone of an object representing a user
 * @param data - A database record representing a user
 */
export const unsanitizedResponse = partial(respond, [false]);

/**
 * Get a list of active users
 * @param limit - The number of records to fetch
 * @param offset - The number of records to skip
 */
export const get = async (limit: number = 10, offset: number = 0): Promise<User.UserData[]> => {
    const users = await db.getActiveUsers(limit, offset);
    return users.map(sanitizedResponse);
开发者ID:benjambles,项目名称:my-own-world,代码行数:31,代码来源:users.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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