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


TypeScript pify.default函数代码示例

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


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

示例1: pify

import nodeResolve from 'resolve'
import pify from 'pify'

interface Options {
  cwd: string
}

const resolve = pify(nodeResolve)

const cache = new Map()

export default async function(id: string, options: Options) {
  const cacheId = `${id}::${options.cwd}`

  if (cache.has(cacheId)) return cache.get(cacheId)

  const res = await resolve(id, {
    basedir: options.cwd,
    extensions: ['.js', '.json', '.jsx', '.ts', '.tsx'],
    packageFilter(pkg: any) {
      if (pkg.module) {
        pkg.main = pkg.module
      }
      return pkg
    }
  })

  cache.set(cacheId, res)

  return res
}
开发者ID:egoist,项目名称:bubleup,代码行数:31,代码来源:resolve.ts

示例2: getPort

    return getPort().then(port => {
        const s = http.createServer((req, resp) => s.emit(req.url, req, resp));

        s.host = host;
        s.port = port;
        s.url = `http://${host}:${port}`;
        s.protocol = 'http';

        s.listen = pify(s.listen, Promise);
        s.close = pify(s.close, Promise);

        return s;
    });
开发者ID:cyounkins,项目名称:typed-got,代码行数:13,代码来源:server.ts

示例3: it

 it('should post progress for uploads', async () => {
   const scope =
       nock(Utils.baseUrl)
           .post(
               '/upload/youtube/v3/videos?part=id%2Csnippet&notifySubscribers=false&uploadType=multipart')
           .reply(200);
   const fileName = path.join(__dirname, '../../test/fixtures/mediabody.txt');
   const fileSize = (await pify(fs.stat)(fileName)).size;
   const google = new GoogleApis();
   const youtube = google.youtube('v3');
   const progressEvents = new Array<number>();
   await youtube.videos.insert(
       {
         part: 'id,snippet',
         notifySubscribers: false,
         requestBody: {
           snippet: {
             title: 'Node.js YouTube Upload Test',
             description:
                 'Testing YouTube upload via Google APIs Node.js Client'
           }
         },
         media: {body: fs.createReadStream(fileName)}
       },
       {
         onUploadProgress: (evt: {bytesRead: number}) => {
           progressEvents.push(evt.bytesRead);
         }
       });
   assert(progressEvents.length > 0);
   assert.equal(progressEvents[0], fileSize);
   scope.done();
 });
开发者ID:sheerun,项目名称:google-api-nodejs-client,代码行数:33,代码来源:test.media.ts

示例4: pify

 return [async (...args: any[]) => {
   const done = args[args.length - 1];
   const passedArgs = args.splice(0, args.length - 1);
   for (const hook of hooks) {
     await pify(hook)(...passedArgs);
   }
   done();
 }] as [(...args: any[]) => Promise<void>];
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:8,代码来源:package.ts

示例5: async

 async (buildPath, electronVersion, pPlatform, pArch, done) => {
   if (packagerSpinner) {
     packagerSpinner.succeed();
     prepareCounter += 1;
     prepareSpinner = ora(`Preparing to Package Application for arch: ${(prepareCounter === 2 ? 'armv7l' : 'x64').cyan}`).start();
   }
   const bins = await pify(glob)(path.join(buildPath, '**/.bin/**/*'));
   for (const bin of bins) {
     await fs.remove(bin);
   }
   done();
 }, async (buildPath, electronVersion, pPlatform, pArch, done) => {
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:12,代码来源:package.ts

示例6: moveApp

  async moveApp(appPath: string, targetApplicationPath: string, spinner: OraImpl, copyInstead = false) {
    let writeAccess = true;
    try {
      await fs.access('/Applications', fs.constants.W_OK);
    } catch (err) {
      writeAccess = false;
    }

    if (await fs.pathExists(targetApplicationPath)) {
      spinner.fail();
      throw `The application "${path.basename(targetApplicationPath)}" appears to already exist in /Applications.`;
    }

    const moveCommand = `${copyInstead ? 'cp -r' : 'mv'} "${appPath}" "${targetApplicationPath}"`;
    if (writeAccess) {
      await pify(exec)(moveCommand);
    } else {
      await pify(sudo.exec)(moveCommand, {
        name: 'Electron Forge',
      });
    }
  }
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:22,代码来源:InstallerDarwin.ts

示例7: async

	return async (): Promise<TestServer> => {
		const port = await getPort();
		const server = http.createServer(fn) as TestServer;

		server.host = host;
		server.port = port;
		server.url = `http://${host}:${port}`;
		server.protocol = 'http';
		server.listen(port);
		server.close = pify(server.close);

		return server;
	};
开发者ID:sindresorhus,项目名称:pageres,代码行数:13,代码来源:_server.ts

示例8: cookieTest

async function cookieTest(input, t): Promise<void> {
	const server = await createCookieServer();

	const screenshots = await new Pageres({cookies: [input]})
		.src(server.url, ['320x480'])
		.run();

	server.close();

	const png = new PNG(screenshots[0]);
	const {pixels} = await pify(png.parse.bind(png))();

	t.is(pixels[0], 0);
	t.is(pixels[1], 0);
	t.is(pixels[2], 0);
	t.is(pixels[3], 255);
}
开发者ID:sindresorhus,项目名称:pageres,代码行数:17,代码来源:cookie.ts

示例9: pify

//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import assert from 'assert';
import * as fs from 'fs';
import nock from 'nock';
import * as path from 'path';
import pify from 'pify';

import {Utils} from './../utils';
const fsp = pify(fs);

nock.disableNetConnect();

const samples = {
  jwt: require('../../../samples/jwt')
};

describe('Auth samples', () => {
  afterEach(() => {
    nock.cleanAll();
  });

  it('should support JWT', async () => {
    const scope = nock(Utils.baseUrl)
                      .get('/drive/v2/files')
开发者ID:sheerun,项目名称:google-api-nodejs-client,代码行数:31,代码来源:test.samples.auth.ts

示例10: workerFarm

import workerFarm from 'worker-farm';
import pify from 'pify';
import path from 'path';

const exportNames = [
  'copyFileWorker',
  'compressImageWorker',
  'writeFileWorker',
  'tinyPngWorker',
  'binPackerWorker',
];

const workerFarmWorkers = workerFarm(
  path.join(__dirname, 'workers.js'),
  exportNames,
) as any;

export const workers = pify(workerFarmWorkers);

export const workerFarmEnd = () => workerFarm.end(workerFarmWorkers);
开发者ID:igor-bezkrovny,项目名称:texturer,代码行数:20,代码来源:workers.ts


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