本文整理匯總了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))
})
}