getEncoding(buffer, opts, next)

./source/index.js

Get the encoding of a buffer Uses getEncodingSync behind the scenes.

Parameters

  • Buffer buffer :

    forwarded to getEncodingSync

  • Object opts :

    forwarded to getEncodingSync

  • Function next :

    accepts arguments: (error: Error, result: Boolean)

Returns

nothing

getEncodingSync(buffer, [opts])

./source/index.js

Get the encoding of a buffer. We fetch a bunch chars from the start, middle and end of the buffer. We check all three, as doing only start was not enough, and doing only middle was not enough, so better safe than sorry.

Parameters

Returns

( Error | string ) :

either an Error instance if something went wrong, or if successful "utf8" or "binary"

isBinary(filename, buffer, next)

./source/index.js

Is Binary Uses isText behind the scenes.

Parameters

  • ? string filename :

    forwarded to isText

  • ? Buffer buffer :

    forwarded to isText

  • Function next :

    accepts arguments: (error: Error, result: Boolean)

Returns

nothing

isBinarySync(filename, buffer)

./source/index.js

Is Binary (Synchronous) Uses isTextSync behind the scenes.

Parameters

  • ? string filename :

    forwarded to isTextSync

  • ? Buffer buffer :

    forwarded to isTextSync

Returns

( Error | boolean )

isText(filename, buffer, next)

./source/index.js

Is Text Uses isTextSync behind the scenes.

Parameters

  • ? string filename :

    forwarded to isTextSync

  • ? Buffer buffer :

    forwarded to isTextSync

  • Function next :

    accepts arguments: (error: Error, result: Boolean)

Returns

nothing

isTextSync(filename, buffer)

./source/index.js

Is Text (Synchronous) Determine whether or not a file is a text or binary file. Determined by extension checks first, then if unknown extension, will fallback on encoding detection. We do that as encoding detection cannot guarantee everything, especially for chars between utf8 and utf16

Parameters

  • ? string filename :

    the filename for the file/buffer if available

  • ? Buffer buffer :

    the buffer for the file if available

Returns

( Error | boolean )