clear
This commit is contained in:
42
node_modules/strip-bom/cli.js
generated
vendored
Normal file
42
node_modules/strip-bom/cli.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
var fs = require('fs');
|
||||
var pkg = require('./package.json');
|
||||
var stripBom = require('./');
|
||||
var argv = process.argv.slice(2);
|
||||
var input = argv[0];
|
||||
|
||||
function help() {
|
||||
console.log([
|
||||
'',
|
||||
' ' + pkg.description,
|
||||
'',
|
||||
' Usage',
|
||||
' strip-bom <file> > <new-file>',
|
||||
' cat <file> | strip-bom > <new-file>',
|
||||
'',
|
||||
' Example',
|
||||
' strip-bom unicorn.txt > unicorn-without-bom.txt'
|
||||
].join('\n'));
|
||||
}
|
||||
|
||||
if (argv.indexOf('--help') !== -1) {
|
||||
help();
|
||||
return;
|
||||
}
|
||||
|
||||
if (argv.indexOf('--version') !== -1) {
|
||||
console.log(pkg.version);
|
||||
return;
|
||||
}
|
||||
|
||||
if (process.stdin.isTTY) {
|
||||
if (!input) {
|
||||
help();
|
||||
return;
|
||||
}
|
||||
|
||||
fs.createReadStream(input).pipe(stripBom.stream()).pipe(process.stdout);
|
||||
} else {
|
||||
process.stdin.pipe(stripBom.stream()).pipe(process.stdout);
|
||||
}
|
||||
24
node_modules/strip-bom/index.js
generated
vendored
Normal file
24
node_modules/strip-bom/index.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
var isUtf8 = require('is-utf8');
|
||||
|
||||
var stripBom = module.exports = function (arg) {
|
||||
if (typeof arg === 'string') {
|
||||
return arg.replace(/^\ufeff/g, '');
|
||||
}
|
||||
|
||||
if (Buffer.isBuffer(arg) && isUtf8(arg) &&
|
||||
arg[0] === 0xef && arg[1] === 0xbb && arg[2] === 0xbf) {
|
||||
return arg.slice(3);
|
||||
}
|
||||
|
||||
return arg;
|
||||
};
|
||||
|
||||
stripBom.stream = function () {
|
||||
var firstChunk = require('first-chunk-stream');
|
||||
|
||||
return firstChunk({minSize: 3}, function (chunk, enc, cb) {
|
||||
this.push(stripBom(chunk));
|
||||
cb();
|
||||
});
|
||||
};
|
||||
113
node_modules/strip-bom/package.json
generated
vendored
Normal file
113
node_modules/strip-bom/package.json
generated
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "strip-bom@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "strip-bom",
|
||||
"name": "strip-bom",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"D:\\web\\layui\\res\\layui\\node_modules\\vinyl-fs"
|
||||
]
|
||||
],
|
||||
"_from": "strip-bom@>=1.0.0 <2.0.0",
|
||||
"_id": "strip-bom@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/strip-bom",
|
||||
"_npmUser": {
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
},
|
||||
"_npmVersion": "1.4.9",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "strip-bom@^1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "strip-bom",
|
||||
"name": "strip-bom",
|
||||
"rawSpec": "^1.0.0",
|
||||
"spec": ">=1.0.0 <2.0.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/vinyl-fs"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz",
|
||||
"_shasum": "85b8862f3844b5a6d5ec8467a93598173a36f794",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "strip-bom@^1.0.0",
|
||||
"_where": "D:\\web\\layui\\res\\layui\\node_modules\\vinyl-fs",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
},
|
||||
"bin": {
|
||||
"strip-bom": "cli.js"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/strip-bom/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"first-chunk-stream": "^1.0.0",
|
||||
"is-utf8": "^0.2.0"
|
||||
},
|
||||
"description": "Strip UTF-8 byte order mark (BOM) from a string/buffer/stream",
|
||||
"devDependencies": {
|
||||
"concat-stream": "^1.4.5",
|
||||
"mocha": "*"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "85b8862f3844b5a6d5ec8467a93598173a36f794",
|
||||
"tarball": "https://registry.npmjs.org/strip-bom/-/strip-bom-1.0.0.tgz"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"files": [
|
||||
"cli.js",
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/strip-bom",
|
||||
"keywords": [
|
||||
"cli",
|
||||
"bin",
|
||||
"app",
|
||||
"bom",
|
||||
"strip",
|
||||
"byte",
|
||||
"mark",
|
||||
"unicode",
|
||||
"utf8",
|
||||
"utf-8",
|
||||
"remove",
|
||||
"trim",
|
||||
"text",
|
||||
"buffer",
|
||||
"string",
|
||||
"stream",
|
||||
"streams"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "sindresorhus",
|
||||
"email": "sindresorhus@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "strip-bom",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/sindresorhus/strip-bom.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
59
node_modules/strip-bom/readme.md
generated
vendored
Normal file
59
node_modules/strip-bom/readme.md
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# strip-bom [](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/stream
|
||||
|
||||
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.
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```sh
|
||||
$ npm install --save strip-bom
|
||||
```
|
||||
|
||||
```js
|
||||
var fs = require('fs');
|
||||
var stripBom = require('strip-bom');
|
||||
|
||||
stripBom('\ufeffUnicorn');
|
||||
//=> Unicorn
|
||||
|
||||
stripBom(fs.readFileSync('unicorn.txt'));
|
||||
//=> Unicorn
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
```sh
|
||||
$ npm install --global strip-bom
|
||||
```
|
||||
|
||||
```
|
||||
$ strip-bom --help
|
||||
|
||||
Usage
|
||||
strip-bom <file> > <new-file>
|
||||
cat <file> | strip-bom > <new-file>
|
||||
|
||||
Example
|
||||
strip-bom unicorn.txt > unicorn-without-bom.txt
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
Reference in New Issue
Block a user