strip-bom-buffer
Advanced tools
Comparing version 0.1.1 to 1.0.0
16
index.js
/*! | ||
* strip-bom-buffer <https://github.com/jonschlinkert/strip-bom-buffer> | ||
* | ||
* Copyright (c) 2015, Jon Schlinkert. | ||
* Licensed under the MIT License. | ||
* Copyright (c) 2015, 2017, Jon Schlinkert. | ||
* Released under the MIT License. | ||
*/ | ||
@@ -11,12 +11,8 @@ | ||
var isBuffer = require('is-buffer'); | ||
var isUtf8 = require('is-utf8'); | ||
module.exports = function (buffer) { | ||
if (!isBuffer(buffer) || !isUtf8(buffer)) { | ||
return buffer; | ||
module.exports = function(buf) { | ||
if (isBuffer(buf) && String(buf.slice(0, 3)) === '\ufeff') { | ||
return buf.slice(3); | ||
} | ||
if (String(buffer.slice(0, 3)) === '\ufeff') { | ||
return buffer.slice(3); | ||
} | ||
return buffer; | ||
return buf; | ||
}; |
{ | ||
"name": "strip-bom-buffer", | ||
"description": "Strip a byte order mark (BOM) from a buffer.", | ||
"version": "0.1.1", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/jonschlinkert/strip-bom-buffer", | ||
@@ -23,10 +23,11 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"dependencies": { | ||
"is-buffer": "^1.1.0", | ||
"is-utf8": "^0.2.0" | ||
"is-buffer": "^1.1.5" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
"gulp-format-md": "^0.1.11", | ||
"mocha": "^3.2.0" | ||
}, | ||
"keywords": [ | ||
"bom", | ||
"buffer", | ||
"byte-order-mark", | ||
@@ -37,3 +38,3 @@ "file", | ||
"normalize", | ||
"buffer" | ||
"strip" | ||
], | ||
@@ -48,4 +49,15 @@ "verb": { | ||
] | ||
}, | ||
"toc": false, | ||
"layout": "default", | ||
"tasks": [ | ||
"readme" | ||
], | ||
"plugins": [ | ||
"gulp-format-md" | ||
], | ||
"lint": { | ||
"reflinks": true | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# strip-bom-buffer [![NPM version](https://badge.fury.io/js/strip-bom-buffer.svg)](http://badge.fury.io/js/strip-bom-buffer) [![Build Status](https://travis-ci.org/jonschlinkert/strip-bom-buffer.svg)](https://travis-ci.org/jonschlinkert/strip-bom-buffer) | ||
# strip-bom-buffer [![NPM version](https://img.shields.io/npm/v/strip-bom-buffer.svg?style=flat)](https://www.npmjs.com/package/strip-bom-buffer) [![NPM monthly downloads](https://img.shields.io/npm/dm/strip-bom-buffer.svg?style=flat)](https://npmjs.org/package/strip-bom-buffer) [![NPM total downloads](https://img.shields.io/npm/dt/strip-bom-buffer.svg?style=flat)](https://npmjs.org/package/strip-bom-buffer) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/strip-bom-buffer.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/strip-bom-buffer) | ||
@@ -7,6 +7,6 @@ > Strip a byte order mark (BOM) from a buffer. | ||
Install with [npm](https://www.npmjs.com/) | ||
Install with [npm](https://www.npmjs.com/): | ||
```sh | ||
$ npm i strip-bom-buffer --save | ||
$ npm install --save strip-bom-buffer | ||
``` | ||
@@ -21,35 +21,47 @@ | ||
## Related projects | ||
## About | ||
* [cr](https://www.npmjs.com/package/cr): Strip windows carriage returns, or convert carriage returns to newlines. | [homepage](https://github.com/jonschlinkert/cr) | ||
* [has-bom](https://www.npmjs.com/package/has-bom): Returns true if a buffer or string has a byte order mark (BOM) | [homepage](https://github.com/jonschlinkert/has-bom) | ||
* [read-file](https://www.npmjs.com/package/read-file): Thin wrapper around fs.readFile and fs.readFileSync that also strips byte order marks when `utf8` encoding… [more](https://www.npmjs.com/package/read-file) | [homepage](https://github.com/jonschlinkert/read-file) | ||
* [strip-bom-string](https://www.npmjs.com/package/strip-bom-string): Strip a byte order mark (BOM) from a string. | [homepage](https://github.com/jonschlinkert/strip-bom-string) | ||
### Related projects | ||
## Running tests | ||
* [cr](https://www.npmjs.com/package/cr): Strip windows carriage returns, or convert carriage returns to newlines. | [homepage](https://github.com/jonschlinkert/cr "Strip windows carriage returns, or convert carriage returns to newlines.") | ||
* [has-bom](https://www.npmjs.com/package/has-bom): Returns true if a buffer or string has a byte order mark (BOM) | [homepage](https://github.com/jonschlinkert/has-bom "Returns true if a buffer or string has a byte order mark (BOM)") | ||
* [read-file](https://www.npmjs.com/package/read-file): Thin wrapper around fs.readFile and fs.readFileSync that also strips byte order marks when `utf8` encoding… [more](https://github.com/jonschlinkert/read-file) | [homepage](https://github.com/jonschlinkert/read-file "Thin wrapper around fs.readFile and fs.readFileSync that also strips byte order marks when `utf8` encoding is chosen. Also optionally replaces windows newlines with unix newlines.") | ||
* [strip-bom-string](https://www.npmjs.com/package/strip-bom-string): Strip a byte order mark (BOM) from a string. | [homepage](https://github.com/jonschlinkert/strip-bom-string "Strip a byte order mark (BOM) from a string.") | ||
Install dev dependencies: | ||
### Contributing | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
### Building docs | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm i -d && npm test | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
## Contributing | ||
### Running tests | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/strip-bom-buffer/issues/new). | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
## Author | ||
```sh | ||
$ npm install && npm test | ||
``` | ||
### Author | ||
**Jon Schlinkert** | ||
+ [github/jonschlinkert](https://github.com/jonschlinkert) | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) | ||
## License | ||
### License | ||
Copyright © 2015 Jon Schlinkert | ||
Released under the MIT license. | ||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT License](LICENSE). | ||
*** | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 10, 2015._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.3, on March 29, 2017._ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5740
1
0
65
2
14
- Removedis-utf8@^0.2.0
- Removedis-utf8@0.2.1(transitive)
Updatedis-buffer@^1.1.5