• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript util.promisify函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中util.promisify函数的典型用法代码示例。如果您正苦于以下问题:TypeScript promisify函数的具体用法?TypeScript promisify怎么用?TypeScript promisify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了promisify函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: promisify

		.then(_ => promisify(fs.readFile)(OUT_FILE))
开发者ID:calebsander,项目名称:structure-bytes,代码行数:1,代码来源:type.ts


示例2: truncate

export function truncate(path: string, len: number): Promise<void> {
	return promisify(fs.truncate)(path, len);
}
开发者ID:PKRoma,项目名称:vscode,代码行数:3,代码来源:pfs.ts


示例3: debug

import SteamCommunity from 'steamcommunity';
import { promisify } from 'util';
import debug from 'debug';
import config from 'config';

const log = debug('TF2Pickup:utils:steam-community');
const steamCommunity = new SteamCommunity();
const login = promisify(steamCommunity.login.bind(steamCommunity));
const username = config.get<string | null>('services.steam.username');
const password = config.get<string | null>('services.steam.password');

export async function setupSteam() {
  if (password === null || username === null) {
    return;
  }

  try {
    await login({
      accountName: username,
      password,
    });

    log('Successfully logged into steam');
  } catch (error) {
    log('Error while logging into steam', { error });
  }
}

export default steamCommunity;
开发者ID:TF2PickupNET,项目名称:TF2Pickup,代码行数:29,代码来源:steam-community.ts


示例4: lstat

export function lstat(path: string): Promise<fs.Stats> {
	return promisify(fs.lstat)(path);
}
开发者ID:PKRoma,项目名称:vscode,代码行数:3,代码来源:pfs.ts


示例5: unlink

export function unlink(path: string): Promise<void> {
	return promisify(fs.unlink)(path);
}
开发者ID:PKRoma,项目名称:vscode,代码行数:3,代码来源:pfs.ts


示例6: promisify

import getRes from 'get-res';
import logSymbols from 'log-symbols';
import mem from 'mem';
import makeDir from 'make-dir';
import captureWebsite from 'capture-website';
import viewportList from 'viewport-list';
import filenamify from 'filenamify';
import filenamifyUrl from 'filenamify-url';
import template from 'lodash.template';
import plur from 'plur';
import unusedFilename from 'unused-filename';

// TODO: Move this to `type-fest`
type Mutable<ObjectType> = {-readonly [KeyType in keyof ObjectType]: ObjectType[KeyType]};

const writeFile = promisify(fs.writeFile);

export interface Options {
	readonly delay?: number;
	readonly timeout?: number;
	readonly crop?: boolean;
	readonly css?: string;
	readonly script?: string;
	readonly cookies?: readonly (string | {[key: string]: string})[];
	readonly filename?: string;
	readonly incrementalName?: boolean;
	readonly selector?: string;
	readonly hide?: readonly string[];
	readonly username?: string;
	readonly password?: string;
	readonly scale?: number;
开发者ID:sindresorhus,项目名称:pageres,代码行数:31,代码来源:index.ts


示例7: exists

export function exists(path: string): Promise<boolean> {
	return promisify(fs.exists)(path);
}
开发者ID:PKRoma,项目名称:vscode,代码行数:3,代码来源:pfs.ts


示例8: promisify

'use strict';

import { conn, Product, User } from '../models';
import { promisify } from 'util';
const readFile = promisify(require('fs').readFile);

conn.once('open', () => {
    main().then(() => conn.close());
});

async function main() {
    try {

        let users = JSON.parse(await readFile('./initial_data/userMocks.json', 'utf8'));
        console.log(`Read ${users.length} users.`);
        for (let userData of users) {
            const newUser = new User(userData);
            let user = await newUser.save();
            console.log(`Saved "${user.name}" (${user._id})`);
        }
        console.log('Users loaded!');

        let products = JSON.parse(await readFile('./initial_data/productMocks.json', 'utf8'));
        console.log(`Read ${products.length} products.`);
        for (let productData of products) {
            let newProduct = new Product(productData);
            let product = await newProduct.save();
            console.log(`Saved "${product.name}" (${product._id})`);
        }
        console.log('Products loaded!');
开发者ID:jamg44,项目名称:NodeTyped,代码行数:30,代码来源:loadMocks.ts


示例9: make_debugLog

// tslint:disable:no-console
import * as fs from "fs";
import * as path from "path";
import * as ts from "typescript";
import { promisify } from "util";

import { assert } from "node-opcua-assert";
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
import { ConstructorFunc } from "node-opcua-factory";

import { get_class_tscript_filename, produce_tscript_code } from "./factory_code_generator";

const debugLog = make_debugLog(__filename);
const doDebug = checkDebugFlag(__filename);

const fileExists = promisify(fs.exists);
const mkdir = promisify(fs.mkdir);

/**
 * @module opcua.miscellaneous
 * @class Factory
 * @static
 */

function compileTscriptCode(typescriptFilename: string): string {

    const content = fs.readFileSync(typescriptFilename, "ascii");

    const compilerOptions = {
        module: ts.ModuleKind.CommonJS,
        target: ts.ScriptTarget.ES2016,
开发者ID:node-opcua,项目名称:node-opcua,代码行数:31,代码来源:generator.ts


示例10: promisify

import { writeFile, writeFileSync } from 'fs';
import { extname } from 'path';
import { promisify } from 'util';

import { Image } from '../Image';

import {
  encode,
  ImageFormat,
  IEncodeOptionsPng,
  IEncodeOptionsJpeg
} from './encode';

const writeFilePromise = promisify(writeFile);

/**
 * Write an image to the disk.
 * The file format is determined automatically from the file's extension.
 * If the extension is not supported, an error will be thrown.
 */
export async function write(path: string, image: Image): Promise<void>;
/**
 * Write an image to the disk as PNG.
 * When the `png` format is specified, the file's extension doesn't matter.
 */
export async function write(
  path: string,
  image: Image,
  options: IEncodeOptionsPng
): Promise<void>;
/**
开发者ID:image-js,项目名称:core,代码行数:31,代码来源:write.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript util.TextDecoder类代码示例发布时间:2022-05-25
下一篇:
TypeScript util.log函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap