How to use @hapi/nigel - 2 common examples

To help you get started, we’ve selected a few @hapi/nigel 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 hapijs / pez / lib / index.js View on Github external
const settings = Hoek.applyToDefaults(internals.defaults, options);

        this._boundary = settings.boundary;
        this._state = internals.state.preamble;
        this._held = '';

        this._stream = null;
        this._headers = {};
        this._name = '';
        this._pendingHeader = '';
        this._error = null;
        this._bytes = 0;
        this._maxBytes = settings.maxBytes;

        this._parts = new Nigel.Stream(Buffer.from('--' + settings.boundary));
        this._lines = new Nigel.Stream(Buffer.from('\r\n'));

        this._parts.on('needle', () => this._onPartEnd());
        this._parts.on('haystack', (chunk) => this._onPart(chunk));
        this._lines.on('needle', () => this._onLineEnd());
        this._lines.on('haystack', (chunk) => this._onLine(chunk));
        this.once('finish', () => this._parts.end());
        this._parts.once('close', () => this._lines.end());

        let piper = null;
        let finish = (err) => {

            if (piper) {
                piper.removeListener('data', onReqData);
                piper.removeListener('error', finish);
                piper.removeListener('aborted', onReqAborted);
            }
github hapijs / pez / lib / index.js View on Github external
Hoek.assert(options !== null && typeof options === 'object', 'options must be an object');
        const settings = Hoek.applyToDefaults(internals.defaults, options);

        this._boundary = settings.boundary;
        this._state = internals.state.preamble;
        this._held = '';

        this._stream = null;
        this._headers = {};
        this._name = '';
        this._pendingHeader = '';
        this._error = null;
        this._bytes = 0;
        this._maxBytes = settings.maxBytes;

        this._parts = new Nigel.Stream(Buffer.from('--' + settings.boundary));
        this._lines = new Nigel.Stream(Buffer.from('\r\n'));

        this._parts.on('needle', () => this._onPartEnd());
        this._parts.on('haystack', (chunk) => this._onPart(chunk));
        this._lines.on('needle', () => this._onLineEnd());
        this._lines.on('haystack', (chunk) => this._onLine(chunk));
        this.once('finish', () => this._parts.end());
        this._parts.once('close', () => this._lines.end());

        let piper = null;
        let finish = (err) => {

            if (piper) {
                piper.removeListener('data', onReqData);
                piper.removeListener('error', finish);
                piper.removeListener('aborted', onReqAborted);

@hapi/nigel

Boyer-Moore-Horspool algorithms

BSD-3-Clause
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis

Popular @hapi/nigel functions