本文整理汇总了TypeScript中util.promisify类的典型用法代码示例。如果您正苦于以下问题:TypeScript promisify类的具体用法?TypeScript promisify怎么用?TypeScript promisify使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了promisify类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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}`);
}
示例2: stop
async function stop() {
await promisify(server.close.bind(server))();
}
示例3: 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());
示例4: async
return async () => {
await promisify(wdmInst.close.bind(wdmInst))();
};
示例5: 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}`);