pax_global_header00006660000000000000000000000064134612272440014517gustar00rootroot0000000000000052 comment=9aef0f38ffefca91d3852c82cd6366e5d36d6dd1 strip-bom-4.0.0/000077500000000000000000000000001346122724400134345ustar00rootroot00000000000000strip-bom-4.0.0/.editorconfig000066400000000000000000000002571346122724400161150ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 strip-bom-4.0.0/.gitattributes000066400000000000000000000000231346122724400163220ustar00rootroot00000000000000* text=auto eol=lf strip-bom-4.0.0/.gitignore000066400000000000000000000000271346122724400154230ustar00rootroot00000000000000node_modules yarn.lock strip-bom-4.0.0/.npmrc000066400000000000000000000000231346122724400145470ustar00rootroot00000000000000package-lock=false strip-bom-4.0.0/.travis.yml000066400000000000000000000000651346122724400155460ustar00rootroot00000000000000language: node_js node_js: - '12' - '10' - '8' strip-bom-4.0.0/index.d.ts000066400000000000000000000004331346122724400153350ustar00rootroot00000000000000/** Strip UTF-8 [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string. @example ``` import stripBom = require('strip-bom'); stripBom('\uFEFFunicorn'); //=> 'unicorn' ``` */ declare function stripBom(string: string): string; export = stripBom; strip-bom-4.0.0/index.js000066400000000000000000000005341346122724400151030ustar00rootroot00000000000000'use strict'; module.exports = string => { if (typeof string !== 'string') { throw new TypeError(`Expected a string, got ${typeof string}`); } // Catches EFBBBF (UTF-8 BOM) because the buffer-to-string // conversion translates it to FEFF (UTF-16 BOM) if (string.charCodeAt(0) === 0xFEFF) { return string.slice(1); } return string; }; strip-bom-4.0.0/index.test-d.ts000066400000000000000000000001601346122724400163070ustar00rootroot00000000000000import {expectType} from 'tsd'; import stripBom = require('.'); expectType(stripBom('\uFEFFunicorn')); strip-bom-4.0.0/license000066400000000000000000000021251346122724400150010ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. strip-bom-4.0.0/package.json000066400000000000000000000012111346122724400157150ustar00rootroot00000000000000{ "name": "strip-bom", "version": "4.0.0", "description": "Strip UTF-8 byte order mark (BOM) from a string", "license": "MIT", "repository": "sindresorhus/strip-bom", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "strip", "bom", "byte", "order", "mark", "unicode", "utf8", "utf-8", "remove", "delete", "trim", "text", "string" ], "devDependencies": { "ava": "^1.4.1", "tsd": "^0.7.2", "xo": "^0.24.0" } } strip-bom-4.0.0/readme.md000066400000000000000000000027611346122724400152210ustar00rootroot00000000000000# strip-bom [![Build Status](https://travis-ci.org/sindresorhus/strip-bom.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-bom) > Strip UTF-8 [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (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. ---
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.
--- ## Install ``` $ npm install strip-bom ``` ## Usage ```js const stripBom = require('strip-bom'); stripBom('\uFEFFunicorn'); //=> 'unicorn' ``` ## Security To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. ## Related - [strip-bom-cli](https://github.com/sindresorhus/strip-bom-cli) - CLI for this module - [strip-bom-buf](https://github.com/sindresorhus/strip-bom-buf) - Buffer version of this module - [strip-bom-stream](https://github.com/sindresorhus/strip-bom-stream) - Stream version of this module ## License MIT © [Sindre Sorhus](https://sindresorhus.com) strip-bom-4.0.0/test/000077500000000000000000000000001346122724400144135ustar00rootroot00000000000000strip-bom-4.0.0/test/fixture-utf8000066400000000000000000000000131346122724400167020ustar00rootroot00000000000000Unicorn strip-bom-4.0.0/test/fixture-utf8-bom-middle000066400000000000000000000000231346122724400207120ustar00rootroot00000000000000Unicorn Unicorn strip-bom-4.0.0/test/test.js000066400000000000000000000006431346122724400157330ustar00rootroot00000000000000import fs from 'fs'; import path from 'path'; import test from 'ava'; import stripBom from '..'; test('strips BOM from string', t => { t.is(stripBom(fs.readFileSync(path.join(__dirname, 'fixture-utf8'), 'utf8')), 'Unicorn\n'); }); test('strips BOM from the beginning of a file', t => { const fixture = fs.readFileSync(path.join(__dirname, 'fixture-utf8-bom-middle'), 'utf8'); t.is(stripBom(fixture), fixture); });