当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript util.promisify类代码示例

本文整理汇总了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}`);
  }
开发者ID:skidding,项目名称:cosmos,代码行数:7,代码来源:httpServer.ts

示例2: stop

 async function stop() {
   await promisify(server.close.bind(server))();
 }
开发者ID:skidding,项目名称:cosmos,代码行数:3,代码来源:httpServer.ts

示例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());
开发者ID:skidding,项目名称:cosmos,代码行数:31,代码来源:findUserModulePaths.ts

示例4: async

 return async () => {
   await promisify(wdmInst.close.bind(wdmInst))();
 };
开发者ID:skidding,项目名称:cosmos,代码行数:3,代码来源:devServer.ts

示例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}`);
开发者ID:doomsower,项目名称:react-native-vkontakte-login,代码行数:31,代码来源:postinstall.ts


注:本文中的util.promisify类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。