本文整理汇总了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)
})
})
})
示例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))
}
示例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))
}
示例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))
})
}