How to use the already.tap function in already

To help you get started, we’ve selected a few already 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 grantila / fetch-h2 / dist / lib / body.js View on Github external
async json() {
        this._ensureUnused();
        if (this._body == null)
            return Promise.resolve(this.validateIntegrity(emptyBuffer, false))
                .then(() => this._body);
        else if (isStream(this._body))
            return get_stream_1.buffer(this._body)
                .then(already_1.tap(buffer => this.validateIntegrity(buffer, false)))
                .then(buffer => JSON.parse(buffer.toString()));
        else if (isBuffer(this._body))
            return Promise.resolve(this._body)
                .then(already_1.tap(buffer => this.validateIntegrity(buffer, false)))
                .then(buffer => JSON.parse(buffer.toString()));
        else
            throwUnknownData();
    }
    async text(allowIncomplete = false) {
github grantila / fetch-h2 / dist / lib / body.js View on Github external
async text(allowIncomplete = false) {
        this._ensureUnused();
        if (this._body == null)
            return Promise.resolve(this.validateIntegrity(emptyBuffer, allowIncomplete))
                .then(() => this._body);
        else if (isStream(this._body))
            return get_stream_1.buffer(this._body)
                .then(already_1.tap(buffer => this.validateIntegrity(buffer, allowIncomplete)))
                .then(buffer => buffer.toString());
        else if (isBuffer(this._body))
            return Promise.resolve(this._body)
                .then(already_1.tap(buffer => this.validateIntegrity(buffer, allowIncomplete)))
                .then(buffer => buffer.toString());
        else
            return throwUnknownData();
    }
    async readable() {

already

Promise extensions; map, filter, etc

MIT
Latest version published 2 years ago

Package Health Score

47 / 100
Full package analysis