How to use the istextorbinary.getEncoding function in istextorbinary

To help you get started, we’ve selected a few istextorbinary 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 wj42ftns / replace-in-files / lib / ReplaceInFiles.js View on Github external
replaceOptions,
    path
  ) {
    const {
      shouldSkipBinaryFiles,
      encoding,
      from,
      onlyFindPathsWithoutReplace,
      replaceFileOnlyIfMatchRegxpInFile: regexp,
      to,
      saveOldFile,
      step,
    } = replaceOptions;
    const data = yield fs.readFile(path, encoding);

    if (shouldSkipBinaryFiles && getEncoding(data) === 'binary') {
      return;
    }

    if (onlyFindPathsWithoutReplace) {
      ReplaceInFiles.findMatches({
        data,
        from,
        path,
        step,
      });
      return;
    }


    const isReplaceFile = _.some([
      regexp === null,

istextorbinary

Determine if a filename and/or buffer is text or binary. Smarter detection than the other solutions.

Artistic-2.0
Latest version published 4 months ago

Package Health Score

77 / 100
Full package analysis