[Pkg-javascript-commits] [node-escape-string-regexp] 01/02: Imported Upstream version 1.0.3
Sebastiaan Couwenberg
sebastic at moszumanska.debian.org
Fri Mar 20 21:42:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
sebastic pushed a commit to branch master
in repository node-escape-string-regexp.
commit 8b6ad7d3aa9fb3b07dd70606547072e564fd8a65
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date: Fri Mar 20 22:19:05 2015 +0100
Imported Upstream version 1.0.3
---
.editorconfig | 16 ++++++++++++++++
.gitattributes | 1 +
.gitignore | 1 +
.jshintrc | 13 +++++++++++++
.travis.yml | 6 ++++++
index.js | 11 +++++++++++
license | 21 +++++++++++++++++++++
package.json | 40 ++++++++++++++++++++++++++++++++++++++++
readme.md | 27 +++++++++++++++++++++++++++
test.js | 7 +++++++
10 files changed, 143 insertions(+)
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..8311fe1
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,16 @@
+# editorconfig.org
+root = true
+
+[*]
+indent_style = tab
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[package.json]
+indent_style = space
+indent_size = 2
+
+[*.md]
+trim_trailing_whitespace = false
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/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..804f8af
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,13 @@
+{
+ "node": true,
+ "esnext": true,
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "immed": true,
+ "newcap": true,
+ "noarg": true,
+ "undef": true,
+ "unused": "vars",
+ "strict": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..dedfc07
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+sudo: false
+language: node_js
+node_js:
+ - 'iojs'
+ - '0.12'
+ - '0.10'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..ac6572c
--- /dev/null
+++ b/index.js
@@ -0,0 +1,11 @@
+'use strict';
+
+var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
+
+module.exports = function (str) {
+ if (typeof str !== 'string') {
+ throw new TypeError('Expected a string');
+ }
+
+ return str.replace(matchOperatorsRe, '\\$&');
+};
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..909ffd0
--- /dev/null
+++ b/package.json
@@ -0,0 +1,40 @@
+{
+ "name": "escape-string-regexp",
+ "version": "1.0.3",
+ "description": "Escape RegExp special characters",
+ "license": "MIT",
+ "repository": "sindresorhus/escape-string-regexp",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus at gmail.com",
+ "url": "http://sindresorhus.com"
+ },
+ "maintainers": [
+ "Sindre Sorhus <sindresorhus at gmail.com> (http://sindresorhus.com)",
+ "Joshua Appelman <jappelman at xebia.com> (http://jbnicolai.com)"
+ ],
+ "engines": {
+ "node": ">=0.8.0"
+ },
+ "scripts": {
+ "test": "mocha"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "regex",
+ "regexp",
+ "re",
+ "regular",
+ "expression",
+ "escape",
+ "string",
+ "str",
+ "special",
+ "characters"
+ ],
+ "devDependencies": {
+ "mocha": "*"
+ }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..808a963
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,27 @@
+# escape-string-regexp [![Build Status](https://travis-ci.org/sindresorhus/escape-string-regexp.svg?branch=master)](https://travis-ci.org/sindresorhus/escape-string-regexp)
+
+> Escape RegExp special characters
+
+
+## Install
+
+```sh
+$ npm install --save escape-string-regexp
+```
+
+
+## Usage
+
+```js
+var escapeStringRegexp = require('escape-string-regexp');
+
+var escapedString = escapeStringRegexp('how much $ for a unicorn?');
+//=> how much \$ for a unicorn\?
+
+new RegExp(escapedString);
+```
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..f968b71
--- /dev/null
+++ b/test.js
@@ -0,0 +1,7 @@
+'use strict';
+var assert = require('assert');
+var escapeStringRegexp = require('./');
+
+it('should escape RegExp special characters', function () {
+ assert.strictEqual(escapeStringRegexp('\\ ^ $ * + ? . ( ) | { } [ ]'), '\\\\ \\^ \\$ \\* \\+ \\? \\. \\( \\) \\| \\{ \\} \\[ \\]');
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-escape-string-regexp.git
More information about the Pkg-javascript-commits
mailing list