當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript promise-finally.default函數代碼示例

本文整理匯總了TypeScript中promise-finally.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: promiseFinally

      .then(exists => {
        if (!exists) {
          options.emitter.emit('enoent', { path })
        }

        return promiseFinally(rimraf(dir), () => {
          return transformDtsFile(dtsPath, (typings) => {
            return typings.filter(x => x !== path)
          })
        })
      })
開發者ID:abouthiroppy,項目名稱:core,代碼行數:11,代碼來源:uninstall.ts

示例2: promiseFinally

export function loader <T> (promise: T | Promise<T>, options: PrintOptions): Promise<T> {
  let end: () => void = () => undefined

  if ((process.stdout as any).isTTY) {
    const frame = spinner()
    const update = () => logUpdate.stderr(frame())
    const interval = setInterval(update, 50)

    end = () => {
      clearInterval(interval)
      logUpdate.stderr.clear()
      logUpdate.stderr.done()
    }
  }

  return promiseFinally(Promise.resolve(promise), end)
    .catch(err => handleError(err, options))
}
開發者ID:bitjson,項目名稱:typings,代碼行數:18,代碼來源:cli.ts

示例3: transformFile

export function transformFile (path: string, transform: (contents: string) => string | Promise<string>): Promise<void> {
  function handle (contents: string) {
    return Promise.resolve(transform(contents))
      .then(contents => writeFile(path, contents))
  }

  const lockfile = `${path}.lock`
  const lockOptions = { wait: 250, retries: 25, stale: 60000 }

  const result = lock(lockfile, lockOptions)
    .then(() => {
      return readFile(path, 'utf8')
    })
    .then(
      (contents) => handle(contents),
      () => handle(undefined)
    )

  return promiseFinally(result, () => unlock(lockfile))
}
開發者ID:mitermayer,項目名稱:core,代碼行數:20,代碼來源:fs.ts

示例4: remove

 // Remove the dependency from typings.
 function remove (path: string, file: string, dtsFile: string) {
   return promiseFinally(rimraf(path), () => {
     return transformDtsFile(dtsFile, typings => typings.filter(x => x !== file))
   })
 }
開發者ID:bitjson,項目名稱:typings,代碼行數:6,代碼來源:fs.ts


注:本文中的promise-finally.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。