How to use the stream-buffers.WritableStreamBuffer function in stream-buffers

To help you get started, we’ve selected a few stream-buffers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bigcompany / hook.io-vfs / lib / vfs.js View on Github external
// since pkgcloud offers no readFile or writeFile API methods
  if (typeof self.client.readFile === "function") {
    return self.client.readFile(readPath, function (err, file) {
      var vFile = new File({
        cwd: "/",
        base: "/",
        path: path,
        contents: file
      });
      cb(null, new Buffer(file.contents), vFile);
    });
  }

  // create a new buffer and output stream for capturing the hook.res.write and hook.res.end calls from inside the hook
  // this is used as an intermediary to pipe hook output to other streams ( such as another hook )
  var buffer = new streamBuffers.WritableStreamBuffer({
      initialSize: (100 * 1024),        // start as 100 kilobytes.
      incrementAmount: (10 * 1024)    // grow by 10 kilobytes each time buffer overflows.
  });

  var _remote;

  if (self.adapter === "google") {
    _remote = encodeURIComponent(self.root + "/" + path);
  } else {
    _remote = self.root + "/" + path;
  }

  // console.log('vfs.readFile'.green, _remote);

  var readStream =  self.client.download({
    container: self.bucket,
github justindujardin / mathy / tools / set-build-version.ts View on Github external
const fs = require("fs")
const path = require("path")
const semanticRelease = require("semantic-release")
const { WritableStreamBuffer } = require("stream-buffers")

const stdoutBuffer = new WritableStreamBuffer()
const stderrBuffer = new WritableStreamBuffer()

function getBuildVersion() {
  return semanticRelease(
    {
      // Core options
      dryRun: true,
      branch: "master",
      repositoryUrl: "https://github.com/justindujardin/mathy.git",
    },
    {
      cwd: "./",
      stdout: stdoutBuffer,
      stderr: stderrBuffer,
    }
  ).then((result: any) => {
    if (result) {
github olegabu / fabric-starter-rest / gost-deps / fabric-client / lib / packager / Golang.js View on Github external
package (chaincodePath, metadataPath) {
		logger.debug('packaging GOLANG from %s', chaincodePath);

		// Determine the user's $GOPATH
		const goPath = process.env.GOPATH;

		// Compose the path to the chaincode project directory
		const projDir = path.join(goPath, 'src', chaincodePath);

		// We generate the tar in two phases: First grab a list of descriptors,
		// and then pack them into an archive.  While the two phases aren't
		// strictly necessary yet, they pave the way for the future where we
		// will need to assemble sources from multiple packages

		const buffer = new sbuf.WritableStreamBuffer();

		return this.findSource(goPath, projDir).then((srcDescriptors) => {
			if (metadataPath) {
				return super.findMetadataDescriptors(metadataPath)
					.then((metaDescriptors) => {
						return srcDescriptors.concat(metaDescriptors);
					});
			} else {
				return srcDescriptors;
			}
		}).then((descriptors) => {
			return super.generateTarGz(descriptors, buffer);
		}).then(() => {
			return buffer.getContents();
		});
	}
github noodlefrenzy / node-amqp10 / test / testing_utils.js View on Github external
module.exports.convertFrameToBuffer = function(frame) {
  var buffer = new sb.WritableStreamBuffer();
  frames.writeFrame(frame, buffer);
  return buffer.getContents();
};
github L-Leite / cso2-master-server / src / packets / outgoing / room.ts View on Github external
public createAndJoinRoom(roomId: number, roomName: string, hostId: number,
                             gameModeId: number, mapId: number, winLimit: number,
                             killLimit: number, players: UserData[]): Buffer {
        const outStream: WritableStreamBuffer = new WritableStreamBuffer(
            { initialSize: 100, incrementAmount: 20 })

        this.buildHeader(outStream)

        this.type = RoomPacketType.CreateAndJoinRoom

        outStream.write(ValToBuffer(this.id, 1))
        outStream.write(ValToBuffer(this.type, 1))

        const newRoomData = new RoomCreateRoom(roomId, roomName, hostId,
            gameModeId, mapId, winLimit, killLimit, players)

        newRoomData.build(outStream)

        const resBuffer: Buffer = outStream.getContents()
        this.setPacketLength(resBuffer)
github lalcmellkmal / doushio / make_client.js View on Github external
function make_minified(files, out, cb) {
	var buf = new streamBuffers.WritableStreamBuffer();
	buf.once('error', cb);
	make_client(files, buf, function (err) {
		if (err)
			return cb(err);
		var src = buf.getContentsAsString('utf-8');
		if (!src || !src.length)
			return cb('make_minified: no client JS was generated');
		minify(src);
	});

	function minify(src) {
		var UglifyJS = require('uglify-es');
		var ugly;
		try {
			ugly = UglifyJS.minify(src, {
				mangle: false,
github L-Leite / cso2-master-server / src / packets / out / room.ts View on Github external
public static stopCountdown(): OutRoomPacket {
        const packet: OutRoomPacket = new OutRoomPacket()

        packet.outStream = new WritableStreamBuffer(
            { initialSize: 20, incrementAmount: 15 })

        packet.buildHeader()
        packet.writeUInt8(OutRoomPacketType.Countdown)

        OutRoomCountdown.build(false, null, packet)

        return packet
    }
github L-Leite / cso2-master-server / src / packets / out / serverlist.ts View on Github external
constructor(channelServers: ChannelServer[]) {
        super(PacketId.ServerList)

        this.outStream = new WritableStreamBuffer(
            { initialSize: 60, incrementAmount: 12 })

        this.buildHeader()
        this.writeUInt8(channelServers.length)
        for (const server of channelServers) {
            new OutChannelServerItem(server).build(this)
        }
    }
}
github L-Leite / cso2-master-server / src / packets / out / inventory.ts View on Github external
public static addInventory(items: UserInventoryItem[]): OutInventoryPacket {
        const packet: OutInventoryPacket = new OutInventoryPacket()

        packet.outStream = new WritableStreamBuffer(
            { initialSize: 80, incrementAmount: 20 })

        packet.id = PacketId.Inventory_Add
        packet.buildHeader()

        OutInventoryAdd.build(items, packet)

        return packet
    }
    constructor() {
github L-Leite / cso2-master-server / src / packets / out / userinfo.ts View on Github external
public static async fullUserUpdate(userId: number): Promise {
        const packet: OutUserInfoPacket = new OutUserInfoPacket()

        packet.outStream = new WritableStreamBuffer(
            { initialSize: 100, incrementAmount: 20 })

        packet.buildHeader()
        packet.writeUInt32(userId)

        await UserInfoFullUpdate.build(userId, packet)

        return packet
    }

stream-buffers

Buffer-backed Streams for reading and writing.

Unlicense
Latest version published 6 months ago

Package Health Score

76 / 100
Full package analysis