當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。