function BufferRW()

in base.js [31:71]


function BufferRW(byteLength, readFrom, writeInto, isPooled) {
    if (!(this instanceof BufferRW)) {
        return new BufferRW(byteLength, readFrom, writeInto, isPooled);
    }

    // istanbul ignore else
    if (byteLength && readFrom && writeInto) {
        assert(typeof byteLength === 'function', 'expected byteLength to be function');
        assert(typeof readFrom === 'function', 'expected readFrom to be function');
        assert(typeof writeInto === 'function', 'expected writeInto to be function');
        // istanbul ignore else
        if (isPooled) {
            this.poolByteLength = byteLength;
            this.poolReadFrom = readFrom;
            this.poolWriteInto = writeInto;
        } else {
            this.byteLength = byteLength;
            this.readFrom = readFrom;
            this.writeInto = writeInto;
        }
    } else {
        // Args weren't specified. Expect either pool methods or regular
        // methods to be overriden.

        assert(
            this.poolReadFrom !== BufferRW.prototype.poolReadFrom ||
            this.readFrom !== BufferRW.prototype.readFrom,
            'expected either poolReadFrom or readFrom to be overriden'
        );
        assert(
            this.poolWriteInto !== BufferRW.prototype.poolWriteInto ||
            this.writeInto !== BufferRW.prototype.writeInto,
            'expected either poolWriteInto or writeInto to be overriden'
        );
        assert(
            this.poolByteLength !== BufferRW.prototype.poolByteLength ||
            this.byteLength !== BufferRW.prototype.byteLength,
            'expected either poolByteLength or byteLength to be overriden'
        );
    }
}