Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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,
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) {
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();
});
}
module.exports.convertFrameToBuffer = function(frame) {
var buffer = new sb.WritableStreamBuffer();
frames.writeFrame(frame, buffer);
return buffer.getContents();
};
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)
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,
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
}
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)
}
}
}
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() {
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
}