lib/index.js
function parse(opts, callback) {
    assert.object(opts, 'opts');
    assert.string(opts.body, 'opts.body');
    assert.func(callback, 'callback');

    const sourceStream = intoStream(opts.body);
    const parseStream = createParseStream();
    const cb = once(callback);

    parseStream.on('data', function(data) {
        return cb(null, data);
    });

    parseStream.on('error', function(err) {
        return cb(err);
    });

    sourceStream.pipe(parseStream);
}
function parse(opts, callback) {
    assert.object(opts, 'opts');
    assert.string(opts.body, 'opts.body');
    assert.func(callback, 'callback');

    const sourceStream = intoStream(opts.body);
    const parseStream = createParseStream();
    const cb = once(callback);

    parseStream.on('data', function(data) {
        return cb(null, data);
    });

    parseStream.on('error', function(err) {
        return cb(err);
    });

    sourceStream.pipe(parseStream);
}
function parse ( opts , callback ) { assert . object ( opts , 'opts' ) ; assert . string ( opts . body , 'opts.body' ) ; assert . func ( callback , 'callback' ) ; const sourceStream = intoStream ( opts . body ) ; const parseStream = createParseStream ( ) ; const cb = once ( callback ) ; parseStream . on ( 'data' , function ( data ) { return cb ( null , data ) ; } ) ; parseStream . on ( 'error' , function ( err ) { return cb ( err ) ; } ) ; sourceStream . pipe ( parseStream ) ; }
stream based JSON.parse. async function signature to abstract over streams.
@public
@param {Object} opts options to pass to parse stream
@param {String} opts.body string to parse
@param {Function} callback a callback function
@return {Object} the parsed JSON object
stream based JSON . parse . async function signature to abstract over streams .