Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-05-22 11:33:46 +0300
committerRebecca Turner <me@re-becca.org>2015-06-26 03:27:03 +0300
commitd3c858ce4cfb3aee515bb299eb034fe1b5e44344 (patch)
treee7714c839934a729b68038f4c7dc5ec3ed877638 /node_modules/balanced-match
parent24564b9654528d23c726cf9ea82b1aef2044b692 (diff)
deps: deduplicate npm@3 style
Diffstat (limited to 'node_modules/balanced-match')
-rw-r--r--node_modules/balanced-match/.npmignore2
-rw-r--r--node_modules/balanced-match/.travis.yml4
-rw-r--r--node_modules/balanced-match/Makefile6
-rw-r--r--node_modules/balanced-match/README.md80
-rw-r--r--node_modules/balanced-match/example.js5
-rw-r--r--node_modules/balanced-match/index.js38
-rw-r--r--node_modules/balanced-match/package.json96
-rw-r--r--node_modules/balanced-match/test/balanced.js56
8 files changed, 287 insertions, 0 deletions
diff --git a/node_modules/balanced-match/.npmignore b/node_modules/balanced-match/.npmignore
new file mode 100644
index 000000000..fd4f2b066
--- /dev/null
+++ b/node_modules/balanced-match/.npmignore
@@ -0,0 +1,2 @@
+node_modules
+.DS_Store
diff --git a/node_modules/balanced-match/.travis.yml b/node_modules/balanced-match/.travis.yml
new file mode 100644
index 000000000..cc4dba29d
--- /dev/null
+++ b/node_modules/balanced-match/.travis.yml
@@ -0,0 +1,4 @@
+language: node_js
+node_js:
+ - "0.8"
+ - "0.10"
diff --git a/node_modules/balanced-match/Makefile b/node_modules/balanced-match/Makefile
new file mode 100644
index 000000000..fa5da71a6
--- /dev/null
+++ b/node_modules/balanced-match/Makefile
@@ -0,0 +1,6 @@
+
+test:
+ @node_modules/.bin/tape test/*.js
+
+.PHONY: test
+
diff --git a/node_modules/balanced-match/README.md b/node_modules/balanced-match/README.md
new file mode 100644
index 000000000..2aff0ebff
--- /dev/null
+++ b/node_modules/balanced-match/README.md
@@ -0,0 +1,80 @@
+# balanced-match
+
+Match balanced string pairs, like `{` and `}` or `<b>` and `</b>`.
+
+[![build status](https://secure.travis-ci.org/juliangruber/balanced-match.svg)](http://travis-ci.org/juliangruber/balanced-match)
+[![downloads](https://img.shields.io/npm/dm/balanced-match.svg)](https://www.npmjs.org/package/balanced-match)
+
+[![testling badge](https://ci.testling.com/juliangruber/balanced-match.png)](https://ci.testling.com/juliangruber/balanced-match)
+
+## Example
+
+Get the first matching pair of braces:
+
+```js
+var balanced = require('balanced-match');
+
+console.log(balanced('{', '}', 'pre{in{nested}}post'));
+console.log(balanced('{', '}', 'pre{first}between{second}post'));
+```
+
+The matches are:
+
+```bash
+$ node example.js
+{ start: 3, end: 14, pre: 'pre', body: 'in{nested}', post: 'post' }
+{ start: 3,
+ end: 9,
+ pre: 'pre',
+ body: 'first',
+ post: 'between{second}post' }
+```
+
+## API
+
+### var m = balanced(a, b, str)
+
+For the first non-nested matching pair of `a` and `b` in `str`, return an
+object with those keys:
+
+* **start** the index of the first match of `a`
+* **end** the index of the matching `b`
+* **pre** the preamble, `a` and `b` not included
+* **body** the match, `a` and `b` not included
+* **post** the postscript, `a` and `b` not included
+
+If there's no match, `undefined` will be returned.
+
+If the `str` contains more `a` than `b` / there are unmatched pairs, the first match that was closed will be used. For example, `{{a}` will match `['{', 'a', '']`.
+
+## Installation
+
+With [npm](https://npmjs.org) do:
+
+```bash
+npm install balanced-match
+```
+
+## License
+
+(MIT)
+
+Copyright (c) 2013 Julian Gruber &lt;julian@juliangruber.com&gt;
+
+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/node_modules/balanced-match/example.js b/node_modules/balanced-match/example.js
new file mode 100644
index 000000000..c02ad348e
--- /dev/null
+++ b/node_modules/balanced-match/example.js
@@ -0,0 +1,5 @@
+var balanced = require('./');
+
+console.log(balanced('{', '}', 'pre{in{nested}}post'));
+console.log(balanced('{', '}', 'pre{first}between{second}post'));
+
diff --git a/node_modules/balanced-match/index.js b/node_modules/balanced-match/index.js
new file mode 100644
index 000000000..d165ae817
--- /dev/null
+++ b/node_modules/balanced-match/index.js
@@ -0,0 +1,38 @@
+module.exports = balanced;
+function balanced(a, b, str) {
+ var bal = 0;
+ var m = {};
+ var ended = false;
+
+ for (var i = 0; i < str.length; i++) {
+ if (a == str.substr(i, a.length)) {
+ if (!('start' in m)) m.start = i;
+ bal++;
+ }
+ else if (b == str.substr(i, b.length) && 'start' in m) {
+ ended = true;
+ bal--;
+ if (!bal) {
+ m.end = i;
+ m.pre = str.substr(0, m.start);
+ m.body = (m.end - m.start > 1)
+ ? str.substring(m.start + a.length, m.end)
+ : '';
+ m.post = str.slice(m.end + b.length);
+ return m;
+ }
+ }
+ }
+
+ // if we opened more than we closed, find the one we closed
+ if (bal && ended) {
+ var start = m.start + a.length;
+ m = balanced(a, b, str.substr(start));
+ if (m) {
+ m.start += start;
+ m.end += start;
+ m.pre = str.slice(0, start) + m.pre;
+ }
+ return m;
+ }
+}
diff --git a/node_modules/balanced-match/package.json b/node_modules/balanced-match/package.json
new file mode 100644
index 000000000..3f11aaccb
--- /dev/null
+++ b/node_modules/balanced-match/package.json
@@ -0,0 +1,96 @@
+{
+ "_args": [
+ [
+ "balanced-match@^0.2.0",
+ "/Users/rebecca/code/npm/node_modules/brace-expansion"
+ ]
+ ],
+ "_from": "balanced-match@>=0.2.0 <0.3.0",
+ "_id": "balanced-match@0.2.0",
+ "_inCache": true,
+ "_location": "/balanced-match",
+ "_nodeVersion": "0.10.32",
+ "_npmUser": {
+ "email": "julian@juliangruber.com",
+ "name": "juliangruber"
+ },
+ "_npmVersion": "2.1.8",
+ "_phantomChildren": {},
+ "_requested": {
+ "name": "balanced-match",
+ "raw": "balanced-match@^0.2.0",
+ "rawSpec": "^0.2.0",
+ "scope": null,
+ "spec": ">=0.2.0 <0.3.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/brace-expansion"
+ ],
+ "_resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.0.tgz",
+ "_shasum": "38f6730c03aab6d5edbb52bd934885e756d71674",
+ "_shrinkwrap": null,
+ "_spec": "balanced-match@^0.2.0",
+ "_where": "/Users/rebecca/code/npm/node_modules/brace-expansion",
+ "author": {
+ "email": "mail@juliangruber.com",
+ "name": "Julian Gruber",
+ "url": "http://juliangruber.com"
+ },
+ "bugs": {
+ "url": "https://github.com/juliangruber/balanced-match/issues"
+ },
+ "dependencies": {},
+ "description": "Match balanced character pairs, like \"{\" and \"}\"",
+ "devDependencies": {
+ "tape": "~1.1.1"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "38f6730c03aab6d5edbb52bd934885e756d71674",
+ "tarball": "http://registry.npmjs.org/balanced-match/-/balanced-match-0.2.0.tgz"
+ },
+ "gitHead": "ba40ed78e7114a4a67c51da768a100184dead39c",
+ "homepage": "https://github.com/juliangruber/balanced-match",
+ "keywords": [
+ "balanced",
+ "match",
+ "parse",
+ "regexp",
+ "test"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "juliangruber",
+ "email": "julian@juliangruber.com"
+ }
+ ],
+ "name": "balanced-match",
+ "optionalDependencies": {},
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/juliangruber/balanced-match.git"
+ },
+ "scripts": {
+ "test": "make test"
+ },
+ "testling": {
+ "browsers": [
+ "android-browser/4.2..latest",
+ "chrome/25..latest",
+ "chrome/canary",
+ "firefox/20..latest",
+ "firefox/nightly",
+ "ie/8..latest",
+ "ipad/6.0..latest",
+ "iphone/6.0..latest",
+ "opera/12..latest",
+ "opera/next",
+ "safari/5.1..latest"
+ ],
+ "files": "test/*.js"
+ },
+ "version": "0.2.0"
+}
diff --git a/node_modules/balanced-match/test/balanced.js b/node_modules/balanced-match/test/balanced.js
new file mode 100644
index 000000000..36bfd3995
--- /dev/null
+++ b/node_modules/balanced-match/test/balanced.js
@@ -0,0 +1,56 @@
+var test = require('tape');
+var balanced = require('..');
+
+test('balanced', function(t) {
+ t.deepEqual(balanced('{', '}', 'pre{in{nest}}post'), {
+ start: 3,
+ end: 12,
+ pre: 'pre',
+ body: 'in{nest}',
+ post: 'post'
+ });
+ t.deepEqual(balanced('{', '}', '{{{{{{{{{in}post'), {
+ start: 8,
+ end: 11,
+ pre: '{{{{{{{{',
+ body: 'in',
+ post: 'post'
+ });
+ t.deepEqual(balanced('{', '}', 'pre{body{in}post'), {
+ start: 8,
+ end: 11,
+ pre: 'pre{body',
+ body: 'in',
+ post: 'post'
+ });
+ t.deepEqual(balanced('{', '}', 'pre}{in{nest}}post'), {
+ start: 4,
+ end: 13,
+ pre: 'pre}',
+ body: 'in{nest}',
+ post: 'post'
+ });
+ t.deepEqual(balanced('{', '}', 'pre{body}between{body2}post'), {
+ start: 3,
+ end: 8,
+ pre: 'pre',
+ body: 'body',
+ post: 'between{body2}post'
+ });
+ t.notOk(balanced('{', '}', 'nope'), 'should be notOk');
+ t.deepEqual(balanced('<b>', '</b>', 'pre<b>in<b>nest</b></b>post'), {
+ start: 3,
+ end: 19,
+ pre: 'pre',
+ body: 'in<b>nest</b>',
+ post: 'post'
+ });
+ t.deepEqual(balanced('<b>', '</b>', 'pre</b><b>in<b>nest</b></b>post'), {
+ start: 7,
+ end: 23,
+ pre: 'pre</b>',
+ body: 'in<b>nest</b>',
+ post: 'post'
+ });
+ t.end();
+});