[Pkg-javascript-commits] [node-strip-bom] 01/04: Import Upstream version 3.0.0

Praveen Arimbrathodiyil praveen at moszumanska.debian.org
Tue Oct 25 11:35:08 UTC 2016


This is an automated email from the git hooks/post-receive script.

praveen pushed a commit to branch master
in repository node-strip-bom.

commit 220286e4879233442d9acd7652e79e223d80d8ef
Author: Shanavas M <shanavas.m2 at gmail.com>
Date:   Thu Oct 20 06:49:14 2016 +0000

    Import Upstream version 3.0.0
---
 .editorconfig                | 12 ++++++++++++
 .gitattributes               |  1 +
 .gitignore                   |  1 +
 .travis.yml                  |  5 +++++
 index.js                     | 14 ++++++++++++++
 license                      | 21 +++++++++++++++++++++
 package.json                 | 40 ++++++++++++++++++++++++++++++++++++++++
 readme.md                    | 36 ++++++++++++++++++++++++++++++++++++
 test/fixture-utf8            |  1 +
 test/fixture-utf8-bom-middle |  1 +
 test/test.js                 | 12 ++++++++++++
 11 files changed, 144 insertions(+)

diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..98a761d
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,12 @@
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[{package.json,*.yml}]
+indent_style = space
+indent_size = 2
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..176a458
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1 @@
+* text=auto
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..b18bae5
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,5 @@
+sudo: false
+language: node_js
+node_js:
+  - '6'
+  - '4'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..b00feb9
--- /dev/null
+++ b/index.js
@@ -0,0 +1,14 @@
+'use strict';
+module.exports = x => {
+	if (typeof x !== 'string') {
+		throw new TypeError('Expected a string, got ' + typeof x);
+	}
+
+	// Catches EFBBBF (UTF-8 BOM) because the buffer-to-string
+	// conversion translates it to FEFF (UTF-16 BOM)
+	if (x.charCodeAt(0) === 0xFEFF) {
+		return x.slice(1);
+	}
+
+	return x;
+};
diff --git a/license b/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus at gmail.com> (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.
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..10f8fdd
--- /dev/null
+++ b/package.json
@@ -0,0 +1,40 @@
+{
+  "name": "strip-bom",
+  "version": "3.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 at gmail.com",
+    "url": "sindresorhus.com"
+  },
+  "engines": {
+    "node": ">=4"
+  },
+  "scripts": {
+    "test": "xo && ava"
+  },
+  "files": [
+    "index.js"
+  ],
+  "keywords": [
+    "strip",
+    "bom",
+    "byte",
+    "order",
+    "mark",
+    "unicode",
+    "utf8",
+    "utf-8",
+    "remove",
+    "delete",
+    "trim",
+    "text",
+    "string"
+  ],
+  "devDependencies": {
+    "ava": "*",
+    "xo": "*"
+  }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..812a980
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,36 @@
+# 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
+
+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 --save strip-bom
+```
+
+
+## Usage
+
+```js
+const stripBom = require('strip-bom');
+
+stripBom('\uFEFFunicorn');
+//=> 'unicorn'
+```
+
+
+## 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)
diff --git a/test/fixture-utf8 b/test/fixture-utf8
new file mode 100644
index 0000000..7ac5c5d
--- /dev/null
+++ b/test/fixture-utf8
@@ -0,0 +1 @@
+Unicorn
diff --git a/test/fixture-utf8-bom-middle b/test/fixture-utf8-bom-middle
new file mode 100644
index 0000000..124f06f
--- /dev/null
+++ b/test/fixture-utf8-bom-middle
@@ -0,0 +1 @@
+Unicorn Unicorn
diff --git a/test/test.js b/test/test.js
new file mode 100644
index 0000000..fc0db0f
--- /dev/null
+++ b/test/test.js
@@ -0,0 +1,12 @@
+import fs from 'fs';
+import test from 'ava';
+import m from '../';
+
+test('strips BOM from string', t => {
+	t.is(m(fs.readFileSync('fixture-utf8', 'utf8')), 'Unicorn\n');
+});
+
+test('strips BOM from the beginning of a file', t => {
+	const f = fs.readFileSync('fixture-utf8-bom-middle', 'utf8');
+	t.is(m(f), f);
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-strip-bom.git



More information about the Pkg-javascript-commits mailing list