How to use the string_decoder.js function in string_decoder

To help you get started, we’ve selected a few string_decoder 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 nodejs / string_decoder / build / files.js View on Github external
/* This file lists the files to be fetched from the node repo
 * in the /lib/ directory which will be placed in the ../lib/
 * directory after having each of the "replacements" in the
 * array for that file applied to it. The replacements are
 * simply the arguments to String#replace, so they can be
 * strings, regexes, functions.
 */

module.exports['string_decoder.js'] = [

    // we do not need internal/util anymore
    [
        /const internalUtil = require\('internal\/util'\);/
      , ''
    ]

  , [
    /(?:var|const) (?:{ )Buffer(?: }) = require\('buffer'\)(?:\.Buffer)?;/,
    `/**/
  var Buffer = require('safe-buffer').Buffer;
/**/
`
    ]

    // add Buffer.isEncoding where missing
github IdeasNeverCease / hikari / node_modules / express / node_modules / connect / node_modules / multiparty / node_modules / readable-stream / node_modules / string_decoder / build / files.js View on Github external
/* This file lists the files to be fetched from the node repo
 * in the /lib/ directory which will be placed in the ../lib/
 * directory after having each of the "replacements" in the
 * array for that file applied to it. The replacements are
 * simply the arguments to String#replace, so they can be
 * strings, regexes, functions.
 */

module.exports['string_decoder.js'] = [

    // pull in Bufer as a require
    // add Buffer.isEncoding where missing
    [
        /^(\/\/ USE OR OTHER DEALINGS IN THE SOFTWARE\.)/m
      ,   '$1\n\nvar Buffer = require(\'buffer\').Buffer;'
        + '\n'
        + '\nvar isBufferEncoding = Buffer.isEncoding'
        + '\n  || function(encoding) {'
        + '\n       switch (encoding && encoding.toLowerCase()) {'
        + '\n         case \'hex\': case \'utf8\': case \'utf-8\': case \'ascii\': case \'binary\': case \'base64\': case \'ucs2\': case \'ucs-2\': case \'utf16le\': case \'utf-16le\': case \'raw\': return true;'
        + '\n         default: return false;'
        + '\n       }'
        + '\n     }'
        + '\n'
github IdeasNeverCease / hikari / node_modules / express / node_modules / connect / node_modules / multiparty / node_modules / readable-stream / node_modules / string_decoder / build / files.js View on Github external
+ '\n         default: return false;'
        + '\n       }'
        + '\n     }'
        + '\n'

    ]

    // use custom Buffer.isEncoding reference
  , [
        /Buffer\.isEncoding\(/g
      , 'isBufferEncoding\('
    ]

]

module.exports['string_decoder.js'].out = 'index.js'

string_decoder

The string_decoder module from Node core

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis