Socket
Socket
Sign inDemoInstall

strip-bom

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

strip-bom - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

18

cli.js

@@ -8,8 +8,2 @@ #!/usr/bin/env node

function stdin(cb) {
var ret = '';
process.stdin.on('data', function (data) { ret += data });
process.stdin.on('end', cb.bind(null, ret));
}
function help() {

@@ -26,7 +20,3 @@ console.log(pkg.description);

function init(data) {
process.stdout.write(stripBom(data));
}
if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) {
if (process.argv.indexOf('--help') !== -1) {
help();

@@ -36,3 +26,3 @@ return;

if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) {
if (process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);

@@ -48,5 +38,5 @@ return;

init(fs.readFileSync(input));
fs.createReadStream(input).pipe(stripBom.stream()).pipe(process.stdout);
} else {
stdin(init);
process.stdin.pipe(stripBom.stream()).pipe(process.stdout);
}
'use strict';
var isUtf8 = require('is-utf8');
module.exports = function (arg) {
var stripBom = module.exports = function (arg) {
if (typeof arg === 'string') {

@@ -16,1 +16,16 @@ return arg.replace(/^\uFEFF/g, '');

};
stripBom.stream = function () {
var through = require('through2');
var first = true;
return through(function (chunk, enc, cb) {
if (first) {
first = false;
chunk = stripBom(chunk);
}
this.push(chunk);
cb();
});
};
{
"name": "strip-bom",
"version": "0.2.1",
"description": "Strip UTF-8 byte order mark (BOM) from a string/buffer",
"version": "0.3.0",
"description": "Strip UTF-8 byte order mark (BOM) from a string/buffer/stream",
"license": "MIT",

@@ -40,10 +40,14 @@ "repository": "sindresorhus/strip-bom",

"buffer",
"string"
"string",
"stream",
"streams"
],
"dependencies": {
"is-utf8": "^0.2.0"
"is-utf8": "^0.2.0",
"through2": "^0.4.1"
},
"devDependencies": {
"concat-stream": "^1.4.5",
"mocha": "*"
}
}
# 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](http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string/buffer
> Strip UTF-8 [byte order mark](http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) (BOM) from a string/buffer/stream

@@ -13,3 +13,3 @@

```bash
```sh
$ npm install --save strip-bom

@@ -32,14 +32,21 @@ ```

Or as a [Transform stream](http://nodejs.org/api/stream.html#stream_class_stream_transform):
```js
var fs = require('fs');
var stripBom = require('strip-bom');
fs.createReadStream('unicorn.txt')
.pipe(stripBom.stream())
.pipe(fs.createWriteStream('unicorn.txt'));
```
## CLI
You can also use it as a CLI app by installing it globally:
```bash
```sh
$ npm install --global strip-bom
```
#### Usage
```bash
```sh
$ strip-bom --help

@@ -58,2 +65,2 @@

[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](http://sindresorhus.com)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc