[Pkg-javascript-commits] [node-ansi-regex] 01/02: Imported Upstream version 0.2.1
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jun 29 22:41:23 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to branch master
in repository node-ansi-regex.
commit caf0182538f635f65c997fd49d35ee9507470629
Author: Andrew Kelley <superjoe30 at gmail.com>
Date: Sun Jun 29 22:35:44 2014 +0000
Imported Upstream version 0.2.1
---
.editorconfig | 16 ++++++++++++++++
.gitattributes | 1 +
.gitignore | 1 +
.jshintrc | 16 ++++++++++++++++
.travis.yml | 3 +++
index.js | 4 ++++
license | 21 +++++++++++++++++++++
package.json | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
readme.md | 33 +++++++++++++++++++++++++++++++++
test.js | 19 +++++++++++++++++++
10 files changed, 165 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..c511975
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,16 @@
+{
+ "node": true,
+ "esnext": true,
+ "bitwise": true,
+ "camelcase": true,
+ "curly": true,
+ "eqeqeq": true,
+ "immed": true,
+ "indent": 4,
+ "newcap": true,
+ "noarg": true,
+ "quotmark": "single",
+ "undef": true,
+ "unused": "vars",
+ "strict": true
+}
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..244b7e8
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - '0.10'
diff --git a/index.js b/index.js
new file mode 100644
index 0000000..783c5c7
--- /dev/null
+++ b/index.js
@@ -0,0 +1,4 @@
+'use strict';
+module.exports = function () {
+ return /\u001b\[(?:[0-9]{1,3}(?:;[0-9]{1,3})*)?[m|K]/g;
+};
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..2734a78
--- /dev/null
+++ b/package.json
@@ -0,0 +1,51 @@
+{
+ "name": "ansi-regex",
+ "version": "0.2.1",
+ "description": "Regular expression for matching ANSI escape codes",
+ "license": "MIT",
+ "repository": "sindresorhus/ansi-regex",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus at gmail.com",
+ "url": "http://sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ },
+ "scripts": {
+ "test": "mocha"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "ansi",
+ "styles",
+ "color",
+ "colour",
+ "colors",
+ "terminal",
+ "console",
+ "cli",
+ "string",
+ "tty",
+ "escape",
+ "formatting",
+ "rgb",
+ "256",
+ "shell",
+ "xterm",
+ "command-line",
+ "text",
+ "regex",
+ "regexp",
+ "re",
+ "match",
+ "test",
+ "find",
+ "pattern"
+ ],
+ "devDependencies": {
+ "mocha": "*"
+ }
+}
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..ae876e7
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,33 @@
+# ansi-regex [![Build Status](https://travis-ci.org/sindresorhus/ansi-regex.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-regex)
+
+> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code)
+
+
+## Install
+
+```sh
+$ npm install --save ansi-regex
+```
+
+
+## Usage
+
+```js
+var ansiRegex = require('ansi-regex');
+
+ansiRegex().test('\u001b[4mcake\u001b[0m');
+//=> true
+
+ansiRegex().test('cake');
+//=> false
+
+'\u001b[4mcake\u001b[0m'.match(ansiRegex());
+//=> ['\u001b[4m', '\u001b[0m']
+```
+
+*It's a function so you can create multiple instances. Regexes with the global flag will have the `.lastIndex` property changed for each call to methods on the instance. Therefore reusing the instance with multiple calls will not work as expected for `.test()`.*
+
+
+## License
+
+MIT © [Sindre Sorhus](http://sindresorhus.com)
diff --git a/test.js b/test.js
new file mode 100644
index 0000000..7081ed6
--- /dev/null
+++ b/test.js
@@ -0,0 +1,19 @@
+'use strict';
+var assert = require('assert');
+var ansiRegex = require('./');
+
+it('should match ansi code in a string', function () {
+ assert(ansiRegex().test('foo\u001b[4mcake\u001b[0m'));
+ assert(ansiRegex().test('\u001b[4mcake\u001b[0m'));
+ assert(ansiRegex().test('foo\u001b[4mcake\u001b[0m'));
+ assert(ansiRegex().test('\u001b[0m\u001b[4m\u001b[42m\u001b[31mfoo\u001b[39m\u001b[49m\u001b[24mfoo\u001b[0m'));
+ assert(ansiRegex().test('foo\u001b[mfoo'));
+});
+
+it('should match ansi code from ls command', function () {
+ assert(ansiRegex().test('\u001b[00;38;5;244m\u001b[m\u001b[00;38;5;33mfoo\u001b[0m'));
+});
+
+it('should match reset;setfg;setbg;italics;strike;underline sequence in a string', function () {
+ assert(ansiRegex().test('\u001b[0;33;49;3;9;4mbar\u001b[0m'));
+});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ansi-regex.git
More information about the Pkg-javascript-commits
mailing list