本文整理匯總了TypeScript中util.promisify.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript promisify.default方法的具體用法?TypeScript promisify.default怎麽用?TypeScript promisify.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類util.promisify
的用法示例。
在下文中一共展示了promisify.default方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: promisify
import axios from 'axios';
import extractSync from 'extract-zip';
import fs from 'fs-extra';
import promisify from 'util.promisify';
const extract: any = promisify(extractSync);
interface GithubRelease {
tarball_url: string;
zipball_url: string;
}
const SDK_ZIP = 'vk-ios-sdk.zip';
const SDK_DIR = 'ios/vk-ios-sdk/';
export default async function downloadSdk() {
const alreadyDownloaded = await fs.pathExistsSync(SDK_DIR);
if (alreadyDownloaded) {
console.log('VK iOS SDK already downloaded');
return;
}
console.log(`Downloading VK iOS SDK as ${SDK_ZIP}`);
const response = await axios.get(`https://api.github.com/repos/VKCOM/vk-ios-sdk/releases`);
const data: GithubRelease[] = response.data;
const zip = await axios.get(data[0].zipball_url, { responseType: 'arraybuffer' });
await fs.writeFile(SDK_ZIP, zip.data);
let sdkDir = '';
console.log(`\nExtracting VK iOS SDK to ${SDK_DIR}`);
示例2: start
async function start() {
const listen = promisify(server.listen.bind(server));
await listen(port, hostname);
const hostnameDisplay = hostname || 'localhost';
console.log(`[Cosmos] See you at http://${hostnameDisplay}:${port}`);
}
示例3: stop
async function stop() {
await promisify(server.close.bind(server))();
}
示例4: promisify
getDecoratorPatterns,
getIgnorePatterns
} from './shared';
type FindUserModulePathsArgs = {
rootDir: string;
fixturesDir: string;
fixtureFileSuffix: string;
};
type UserModulePaths = {
fixturePaths: string[];
decoratorPaths: string[];
};
const globAsync = promisify(glob);
export async function findUserModulePaths({
rootDir,
fixturesDir,
fixtureFileSuffix
}: FindUserModulePathsArgs): Promise<UserModulePaths> {
const paths = await globAsync('**/*', {
cwd: rootDir,
absolute: true,
ignore: getIgnorePatterns()
});
const fixturePatterns = getFixturePatterns(fixturesDir, fixtureFileSuffix);
const fixturePaths = getMatchingPaths(paths, fixturePatterns);
const decoratorPaths = getMatchingPaths(paths, getDecoratorPatterns());
示例5: async
return async () => {
await promisify(wdmInst.close.bind(wdmInst))();
};