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

TypeScript fs.createWriteStream函数代码示例

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

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



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

示例1:

import * as Archiver from 'archiver';
import * as fs from 'fs';

const archiver = Archiver.create('zip');

const writeStream = fs.createWriteStream('./archiver.d.ts');
const readStream = fs.createReadStream('./archiver.d.ts');

archiver.abort();

archiver.pipe(writeStream);
archiver.append(readStream, { name: 'archiver.d.ts' });

archiver.append(readStream, {name: 'archiver.d.ts'})
.append(readStream, {name: 'archiver.d.ts'});

archiver.bulk({ mappaing: {} });

archiver.directory('./path', './someOtherPath');
archiver.directory('./path', { name: "testName" });
archiver.directory('./', "", {});
archiver.directory('./', { name: 'test' }, {});

archiver.append(readStream, {
    name: "sub/folder.xml"
});

archiver.glob("**", {
    cwd: 'path/to/files',
});
archiver.glob('./path', {}, {});
开发者ID:Crevil,项目名称:DefinitelyTyped,代码行数:31,代码来源:archiver-tests.ts


示例2: mkdirp

        throw c
      }
      if (!i.isDirectory()) throw c
    }
  }
  return t
}

if (~installIndex) {
  console.log('DIRECTORY FOUND')
  const directory = process.argv[installIndex + 1]
  if (directory) {
    mkdirp(path.dirname(directory))
    const filename = path.join(directory, path.basename(process.execPath))
    const readStream = fs.createReadStream(process.execPath)
    const writeStream = fs.createWriteStream(filename)

    const onError = function() {
      readStream.removeAllListeners()
      writeStream.removeAllListeners()
      //TODO
    }

    readStream
      .on('error', onError)
      .pipe(writeStream)
      .on('error', onError)
      .on('close', () => {
        const winsw = filename.replace('.exe', '-service.exe')
        fs.writeFileSync(winsw, fs.readFileSync('./nexe/plugin/daemon/winsw.exe'))
        fs.writeFileSync(
开发者ID:zavarat,项目名称:nexe,代码行数:31,代码来源:nexe-daemon.ts


示例3:

query3.select('+path');
query3.where('tags').size(0);
query3.skip(100).limit(20);
query3.slaveOk();
query3.slaveOk(true);
query3.slaveOk(false);
query3.slice('comments', -5);
query3.slice('comments', [10, 5])
query3.where('comments').slice(5);
query3.where('comments').slice([-10, 5]);
query3.snapshot();
query3.snapshot(true);
query3.snapshot(false);
query3.sort({ field: 'asc', test: -1 });
query3.sort('field -test');
Model.find({ name: /^hello/ }).stream({ transform: JSON.stringify }).pipe(fs.createWriteStream('./test.json'));
var stream = Model.find({ name: /^hello/ }).stream();
stream
  .on('data', (doc: IActor) => {})
  .on('error', (err: any) => {})
  .on('close', () => {});

query3.tailable();
query3.tailable(false);
var AdvQuery = query3.toConstructor();
query3.update({ title: 'words' });
query3.update({ $set: { title: 'words' }});
query3.update({ name: /^match/ }, { $set: { arr: [] }}, { multi: true }, (err: any, row: number, raw: any) => {});

query3.where('loc').within({ center: [50,50], radius: 10, unique: true, spherical: true });
query3.where('loc').within({ box: [[40.73, -73.9], [40.7, -73.988]] });
开发者ID:APM3,项目名称:DefinitelyTyped,代码行数:31,代码来源:mongoose-tests.ts


示例4: getConfigRoot

let configRoot;

try {
  configRoot = getConfigRoot();
} catch (ex) {
  console.log(ex.message);
  // tslint:disable-next-line:max-line-length
  console.log(`[ERROR] config.json was not found. The location of config.json has been changed from ./src to ./ since v2.3.0.
[ERROR] 設定ファイルconfig.jsonが見つかりませんでした。v2.3.0から設定ファイルの場所が./src/config.jsonから./config.jsonに変更されました。`);
}

// console output
process.stdin.pipe(pretty({ colorize: true, withLabel: false, debug: false })).pipe(process.stdout);

// debug.log
const debugFile = fs.createWriteStream('logs/debug.log', { flags: 'a' });
process.stdin.pipe(pretty({ colorize: false, withLabel: true, debug: true })).pipe(debugFile);

// info.log
const infoTransform = process.stdin.pipe(pretty({ colorize: false, withLabel: true, debug: false }));
const infoFile = fs.createWriteStream('logs/info.log', { flags: 'a' });
infoTransform.pipe(infoFile);

// notification integrations
if (configRoot) {
  const slackConfig = _.get(configRoot, 'logging.slack');
  const lineConfig = _.get(configRoot, 'logging.line');
  addIntegration(SlackIntegration, slackConfig);
  addIntegration(LineIntegration, lineConfig);
}
开发者ID:tangkaisky,项目名称:r2,代码行数:30,代码来源:index.ts


示例5:

(function() {
var stream = fs.createWriteStream('path/to/my.json');
var req = request.get('/some.json');
req.pipe(stream);
})();
开发者ID:AlBlanc,项目名称:DefinitelyTyped,代码行数:5,代码来源:superagent-tests.ts


示例6:

(() => {
    const stream = fs.createWriteStream('path/to/my.json');
    const req = request.get('/some.json');
    req.pipe(stream);
})();
开发者ID:Rick-Kirkham,项目名称:DefinitelyTyped,代码行数:5,代码来源:superagent-tests.ts


示例7: TO_FILE

export function TO_FILE() {
    return fs.createWriteStream(PATH, { flags: 'a' });
};
开发者ID:adasq,项目名称:gerrit-native-notifications,代码行数:3,代码来源:to-file.ts


示例8:

        const isNative: boolean = frame.isNative();
        const isConstr: boolean = frame.isConstructor();
    }
}

///////////////////////////////////////////////////////////
/// Console Tests : https://nodejs.org/api/console.html ///
///////////////////////////////////////////////////////////

{
    {
        let _c: Console = console;
        _c = console2;
    }
    {
        const writeStream = fs.createWriteStream('./index.d.ts');
        let consoleInstance: Console = new console.Console(writeStream);

        consoleInstance = new console.Console(writeStream, writeStream);
        consoleInstance = new console.Console(writeStream, writeStream, true);
        consoleInstance = new console.Console({
            stdout: writeStream,
            stderr: writeStream,
            colorMode: 'auto',
            ignoreErrors: true
        });
        consoleInstance = new console.Console({
            stdout: writeStream,
            colorMode: false
        });
        consoleInstance = new console.Console({
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:31,代码来源:node-tests.ts


示例9: writeFile

import * as fs from 'fs';
import * as util from 'util';
import * as snekfetch from 'snekfetch';

const writeFile = util.promisify(fs.writeFile);

snekfetch.get('https://s.gus.host/o-SNAKES-80.jpg')
  .then(r => writeFile('download.jpg', r.body));

snekfetch.get('https://s.gus.host/o-SNAKES-80.jpg')
  .pipe(fs.createWriteStream('download.jpg'));

snekfetch.post('https://httpbin.org/post')
  .send({ meme: 'dream' })
  .then(r => console.log(r.body));
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:15,代码来源:snekfetch-tests.ts


示例10: crashlogger

export function crashlogger(
	error: Error | string, description: string, data: AnyObject | null = null
): string | null {
	const datenow = Date.now();

	let stack = typeof error === 'string' ? error : error.stack;
	if (data) {
		stack += `\n\nAdditional information:\n`;
		for (const k in data) {
			stack += `  ${k} = ${data[k]}\n`;
		}
	}

	console.error(`\nCRASH: ${stack}\n`);
	const out = fs.createWriteStream(logPath, {flags: 'a'});
	out.on('open', () => {
		out.write(`\n${stack}\n`);
		out.end();
	}).on('error', (err: Error) => {
		console.error(`\nSUBCRASH: ${err.stack}\n`);
	});

	if (Config.crashguardemail && ((datenow - lastCrashLog) > CRASH_EMAIL_THROTTLE)) {
		lastCrashLog = datenow;

		if (!transport) {
			try {
				require.resolve('nodemailer');
			} catch (e) {
				throw new Error(
					'nodemailer is not installed, but it is required if Config.crashguardemail is configured! ' +
					'Run npm install --no-save nodemailer and restart the server.'
				);
			}
		}

		let text = `${description} crashed `;
		if (transport) {
			text += `again with this stack trace:\n${stack}`;
		} else {
			try {
				// tslint:disable-next-line:no-implicit-dependencies
				transport = require('nodemailer').createTransport(Config.crashguardemail.options);
			} catch (e) {
				throw new Error("Failed to start nodemailer; are you sure you've configured Config.crashguardemail correctly?");
			}

			text += `with this stack trace:\n${stack}`;
		}

		transport.sendMail({
			from: Config.crashguardemail.from,
			to: Config.crashguardemail.to,
			subject: Config.crashguardemail.subject,
			text,
		}, (err: Error | null) => {
			if (err) console.error(`Error sending email: ${err}`);
		});
	}

	if (process.uptime() * 1000 < LOCKDOWN_PERIOD) {
		// lock down the server
		return 'lockdown';
	}

	return null;
}
开发者ID:sirDonovan,项目名称:Pokemon-Showdown,代码行数:67,代码来源:crashlogger.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs.exists函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs.createReadStream函数代码示例发布时间: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