How to use strip-bom - 10 common examples

To help you get started, we’ve selected a few strip-bom 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 flow-typed / flow-typed / definitions / npm / strip-bom_v3.x.x / test_strip-bom_v3.x.x.js View on Github external
import stripBom from 'strip-bom';

const result: string = stripBom('\uFEFFunicorn');
//=> 'unicorn'

// $ExpectError
stripBom(42);

// $ExpectError
(stripBom('asdf'): number);
github DevExpress / testcafe / src / compiler / test-file / api-based.js View on Github external
require.extensions[ext] = (mod, filename) => {
                // NOTE: remove global API so that it will be unavailable for the dependencies
                this._removeGlobalAPI();

                if (APIBasedTestFileCompilerBase._isNodeModulesDep(filename) && origExt)
                    origExt(mod, filename);

                else {
                    const code         = readFileSync(filename).toString();
                    const compiledCode = requireCompilers[ext](stripBom(code), filename);

                    mod.paths = APIBasedTestFileCompilerBase._getNodeModulesLookupPath(filename);

                    mod._compile(compiledCode, filename);
                }

                this._addGlobalAPI(testFile);
            };
        });
github pikapkg / pack / checkpoint / dist-src / index.js View on Github external
function getVersion() {
    const packageJsonContent = fs.readFileSync(path.resolve(currentFilename, '../../package.json'), { encoding: 'utf-8' });
    const { version } = map(JSON.parse(stripBOM(packageJsonContent)));
    return version;
}
function findProjectRoot(base) {
github google / clasp / src / dotfile.ts View on Github external
return new Promise((resolve, reject) => {
      if (
        fs.existsSync(ignoreDirectory)
        && fs.existsSync(DOT.IGNORE.PATH)
      ) {
        const buffer = stripBom(fs.readFileSync(DOT.IGNORE.PATH, FS_OPTIONS));
        resolve(splitLines(buffer).filter((name: string) => name));
      } else {
        const defaultClaspignore = [
          '# ignore all files...',
          '**/**',
          '',
          '# except the extensions...',
          '!appsscript.json',
          '!**/*.gs',
          '!**/*.js',
          '!**/*.ts',
          '!**/*.html',
          '',
          '# ignore even valid files if in...',
          '.git/**',
          'node_modules/**',
github sebastian-software / preppy / src / file.js View on Github external
fs.readFile(file, { encoding: "utf-8" }, (readError, data) => {
    if (readError) {
      return callback(readError)
    }

    const json = stripComments(stripBom(data))

    let obj
    try {
      obj = JSON.parse(json)
    } catch (decodeError) {
      decodeError.message = `${file}: ${decodeError.message}`
      return callback(decodeError)
    }

    return callback(null, obj)
  })
}
github pikapkg / pack / src / index.ts View on Github external
function getVersion() {
  const packageJsonContent = fs.readFileSync(path.resolve(currentFilename, '../../package.json'), {encoding: 'utf-8'});
  const {version} = map(JSON.parse(stripBOM(packageJsonContent)));
  return version;
}
github yarnpkg / yarn / src / lockfile / parse.js View on Github external
export default function(str: string, fileLoc: string = 'lockfile'): ParseResult {
  str = stripBOM(str);
  return hasMergeConflicts(str) ? parseWithConflict(str, fileLoc) : {type: 'success', object: parse(str, fileLoc)};
}
github embroider-build / embroider / packages / core / src / template-compiler.ts View on Github external
if (this.params.resolver) {
      runtimeName = this.params.resolver.absPathToRuntimeName(moduleName) || moduleName;
    } else {
      runtimeName = moduleName;
    }

    let opts = this.syntax.defaultOptions({ contents, moduleName });
    if (this.params.resolver) {
      let transform = this.params.resolver.astTransformer(this);
      if (transform) {
        this.params.plugins.ast!.push(transform);
      }
    }
    opts.plugins!.ast = [...this.getReversedASTPlugins(this.params.plugins.ast!), ...opts.plugins!.ast!];

    let compiled = this.syntax.precompile(stripBom(contents), {
      contents,
      moduleName: runtimeName,
      filename: moduleName,
      plugins: opts.plugins,
    });

    if (this.params.resolver) {
      dependencies = this.params.resolver.dependenciesOf(moduleName);
    } else {
      dependencies = [];
    }

    return { compiled, dependencies };
  }
github pikapkg / pack / src / util / fs.ts View on Github external
export async function readJsonAndFile(
  loc: string,
): Promise<{
  object: Object;
  content: string;
}> {
  const file = await readFile(loc);
  try {
    return {
      object: map(JSON.parse(stripBOM(file))),
      content: file,
    };
  } catch (err) {
    err.message = `${loc}: ${err.message}`;
    throw err;
  }
}
github Andyliwr / FE-learning-load / 前端小demo / es6Toes5 / node_modules / vinyl-fs / lib / src / getContents / streamFile.js View on Github external
function streamFile(file, cb) {
  file.contents = fs.createReadStream(file.path)
    .pipe(stripBom.stream());

  cb(null, file);
}

strip-bom

Strip UTF-8 byte order mark (BOM) from a string

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular strip-bom functions