PHP 8.2.30
Preview: buffer-writer.js Size: 2.71 KB
/home/byroehnu/.trash/node_modules11/pg-protocol/dist/buffer-writer.js

"use strict";
//binary data writer tuned for encoding binary specific to the postgres binary protocol
Object.defineProperty(exports, "__esModule", { value: true });
exports.Writer = void 0;
class Writer {
    constructor(size = 256) {
        this.size = size;
        this.offset = 5;
        this.headerPosition = 0;
        this.buffer = Buffer.allocUnsafe(size);
    }
    ensure(size) {
        const remaining = this.buffer.length - this.offset;
        if (remaining < size) {
            const oldBuffer = this.buffer;
            // exponential growth factor of around ~ 1.5
            // https://stackoverflow.com/questions/2269063/buffer-growth-strategy
            const newSize = oldBuffer.length + (oldBuffer.length >> 1) + size;
            this.buffer = Buffer.allocUnsafe(newSize);
            oldBuffer.copy(this.buffer);
        }
    }
    addInt32(num) {
        this.ensure(4);
        this.buffer[this.offset++] = (num >>> 24) & 0xff;
        this.buffer[this.offset++] = (num >>> 16) & 0xff;
        this.buffer[this.offset++] = (num >>> 8) & 0xff;
        this.buffer[this.offset++] = (num >>> 0) & 0xff;
        return this;
    }
    addInt16(num) {
        this.ensure(2);
        this.buffer[this.offset++] = (num >>> 8) & 0xff;
        this.buffer[this.offset++] = (num >>> 0) & 0xff;
        return this;
    }
    addCString(string) {
        if (!string) {
            this.ensure(1);
        }
        else {
            const len = Buffer.byteLength(string);
            this.ensure(len + 1); // +1 for null terminator
            this.buffer.write(string, this.offset, 'utf-8');
            this.offset += len;
        }
        this.buffer[this.offset++] = 0; // null terminator
        return this;
    }
    addString(string = '') {
        const len = Buffer.byteLength(string);
        this.ensure(len);
        this.buffer.write(string, this.offset);
        this.offset += len;
        return this;
    }
    add(otherBuffer) {
        this.ensure(otherBuffer.length);
        otherBuffer.copy(this.buffer, this.offset);
        this.offset += otherBuffer.length;
        return this;
    }
    join(code) {
        if (code) {
            this.buffer[this.headerPosition] = code;
            //length is everything in this packet minus the code
            const length = this.offset - (this.headerPosition + 1);
            this.buffer.writeInt32BE(length, this.headerPosition + 1);
        }
        return this.buffer.slice(code ? 0 : 5, this.offset);
    }
    flush(code) {
        const result = this.join(code);
        this.offset = 5;
        this.headerPosition = 0;
        this.buffer = Buffer.allocUnsafe(this.size);
        return result;
    }
}
exports.Writer = Writer;
//# sourceMappingURL=buffer-writer.js.map

Directory Contents

Dirs: 0 × Files: 27

Name Size Perms Modified Actions
11 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
636 B lrw-r--r-- 2026-02-03 15:06:12
Edit Download
792 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
396 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
1.60 KB lrw-r--r-- 2026-02-03 15:06:14
Edit Download
1.71 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
441 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
2.71 KB lrw-r--r-- 2026-02-03 15:06:14
Edit Download
3.01 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
11 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
19.06 KB lrw-r--r-- 2026-02-03 15:06:14
Edit Download
14.59 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
302 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
791 B lrw-r--r-- 2026-02-03 15:06:14
Edit Download
522 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
5.96 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
4.86 KB lrw-r--r-- 2026-02-03 15:06:16
Edit Download
3.30 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
11 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
10.81 KB lrw-r--r-- 2026-02-03 15:06:16
Edit Download
10.04 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
669 B lrw-r--r-- 2026-02-03 15:06:18
Edit Download
13.13 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
10.23 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
1.24 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
6.77 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download
6.96 KB lrw-r--r-- 2026-02-03 15:06:18
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).