diff options
author | Marvin Borner | 2018-11-07 22:10:16 +0100 |
---|---|---|
committer | Marvin Borner | 2018-11-07 22:10:17 +0100 |
commit | 954583f3d56fbfb60321725f13ad092e536e3737 (patch) | |
tree | a0505a763797582c61fd8c2f90b422456d8874c9 /node_modules/balanced-match/index.js | |
parent | 1c355e6e956a4e507ed5436d0c814ba9c3a1deb2 (diff) |
Removed node_modules
Diffstat (limited to 'node_modules/balanced-match/index.js')
-rw-r--r-- | node_modules/balanced-match/index.js | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/node_modules/balanced-match/index.js b/node_modules/balanced-match/index.js deleted file mode 100644 index 1685a76..0000000 --- a/node_modules/balanced-match/index.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; -module.exports = balanced; -function balanced(a, b, str) { - if (a instanceof RegExp) a = maybeMatch(a, str); - if (b instanceof RegExp) b = maybeMatch(b, str); - - var r = range(a, b, str); - - return r && { - start: r[0], - end: r[1], - pre: str.slice(0, r[0]), - body: str.slice(r[0] + a.length, r[1]), - post: str.slice(r[1] + b.length) - }; -} - -function maybeMatch(reg, str) { - var m = str.match(reg); - return m ? m[0] : null; -} - -balanced.range = range; -function range(a, b, str) { - var begs, beg, left, right, result; - var ai = str.indexOf(a); - var bi = str.indexOf(b, ai + 1); - var i = ai; - - if (ai >= 0 && bi > 0) { - begs = []; - left = str.length; - - while (i >= 0 && !result) { - if (i == ai) { - begs.push(i); - ai = str.indexOf(a, i + 1); - } else if (begs.length == 1) { - result = [ begs.pop(), bi ]; - } else { - beg = begs.pop(); - if (beg < left) { - left = beg; - right = bi; - } - - bi = str.indexOf(b, i + 1); - } - - i = ai < bi && ai >= 0 ? ai : bi; - } - - if (begs.length) { - result = [ left, right ]; - } - } - - return result; -} |