Coder Social home page Coder Social logo

strip-bom's Introduction

strip-bom

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

From Wikipedia:

The Unicode Standard permits the BOM in UTF-8, but does not require nor recommend its use. Byte order has no meaning in UTF-8.

Install

$ npm install strip-bom

Usage

import stripBom from 'strip-bom';

stripBom('\uFEFFunicorn');
//=> 'unicorn'

Related


Get professional support for 'strip-bom' with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

strip-bom's People

Contributors

bendingbender avatar coreyfarrell avatar kevva avatar mathiasbynens avatar richienb avatar sindresorhus avatar slaks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

strip-bom's Issues

ECMAScript imports/exports and referencing its default export.ts(2497)

I'm trying to use this package but I'm getting:
This module can only be referenced with ECMAScript imports/exports by turning on the 'allowSyntheticDefaultImports' flag and referencing its default export.ts(2497)

Instead of this: const stripBom = require('strip-bom');
I am using:
import * as stripBom from "strip-bom";

I enabled "allowSyntheticDefaultImports" in my config file. What is the default export name? How does one use the import style instead of the require one? What is the 'default export"?

Is the import ECMAScript not supported?

Thank you.

Question: 0.8 support?

I have a few libraries that currently support node 0.8. It would be great if I could use strip-bom. Thoughts? Thank you.

What is the benefit of using arrow function while exporting?

This issue is not related to the functionality of this module.


What is the benefit of arrow function

module.exports = x => {
    ...
    return x;
};

over

module.exports = function (x) {
    ...
    return x;
};

when exporting.


I had been using arrow functions every where possible, but did not find it useful, thus changed it.


Does it emphasize that when ever there is a anonymous function or function expression use arrow function?

v5 Use an experimental feature

The compatibility with node 12 is breaking because the "ECMAScript modules" is an experimental feature in this version, the projects that depdends of this package need to force use it, or adapt they project.

/home/exos/example/node_modules/strip-bom/index.js:1
export default function stripBom(string) {
^^^^^^

SyntaxError: Unexpected token 'export'
    at Module._compile (internal/modules/cjs/loader.js:892:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/exos/example/lib/services/contents.js:75:40)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/exos/example/lib/services/index.js:18:40)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/exos/example/lib/tasks/start.js:10:40)
    at Module._compile (internal/modules/cjs/loader.js:956:30)

Others implementations breaks too:

  ● Test suite failed to run

    Jest encountered an unexpected token

    This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.

    By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it.
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/en/configuration.html

    Details:

    /home/exos/example/node_modules/strip-bom/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export default function stripBom(string) {
                                                                                             ^^^^^^

    SyntaxError: Unexpected token 'export'

      20 | import config from '../config';
      21 | import subsrt from 'subsrt';
    > 22 | import stripBom from 'strip-bom';
         | ^
      23 |

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
      at Object.<anonymous> (src/services/contents.js:22:1)

I recommend you to use babel, or move this release to a flag like strip-bom@es.

workaround, use v4:

npm install --save strip-bom@^4

or

yarn add strip-bom@^4

PS. sorry my poor english

npm package is out of date, version 3.0.0 from npm is broken

Should npm be updated to the most recent version of the code or possibly reverted back to a stable version?

I recently updated to version 3.0.0 from 2.0.0 but it appears that it is now broken. I get the error: "Expected a string, got object". Using the code here on github directly, not through npm, also breaks with the same error.

I will revert back to 2.0.0 for now.

transpile source to es5?

Hey. I'm developing a project that need to work for nodeJS 0.12. And I'm using latest ESLint version. This version of ESLint uses your script, but on nodeJS 0.12, it throws this:

eslint/node_modules/strip-bom/index.js:2
module.exports = x => {
                   ^^

Older versions of ESLint works fine, but not version 3.x.

Any possibility to convert to ES5 ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.