added more content
This commit is contained in:
21
node_modules/match-at/LICENSE
generated
vendored
Normal file
21
node_modules/match-at/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Sophie Alpert
|
||||
|
||||
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.
|
16
node_modules/match-at/README.md
generated
vendored
Normal file
16
node_modules/match-at/README.md
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# match-at [](https://travis-ci.org/spicyj/match-at)
|
||||
|
||||
## Introduction
|
||||
|
||||
Like `String.prototype.match` if it only checked the regex at the given index instead of searching the entire string.
|
||||
|
||||
```js
|
||||
matchAt(/world/, 'hello world', 6); // ['world']
|
||||
matchAt(/world/, 'hello world', 0); // null
|
||||
```
|
||||
|
||||
Almost like `'hello world'.slice(i).match(/^world/)` except the resulting match object's `.index` property corresponds to the original string, and it doesn't actually slice the string. Most engines optimize taking a substring so this probably isn't particularly valuable in practice, but it was an entertaining exercise and could be useful if you reminisce about these semantics.
|
||||
|
||||
## License
|
||||
|
||||
MIT.
|
88
node_modules/match-at/lib/__tests__/matchAt-test.js
generated
vendored
Normal file
88
node_modules/match-at/lib/__tests__/matchAt-test.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
describe('matchAt', function () {
|
||||
|
||||
var matchAt;
|
||||
|
||||
beforeEach(function () {
|
||||
matchAt = require('../matchAt.js');
|
||||
});
|
||||
|
||||
it('matches a simple regex', function () {
|
||||
expect(matchAt(/l/, 'hello', 0)).toBe(null);
|
||||
expect(matchAt(/l/, 'hello', 1)).toBe(null);
|
||||
expect(matchAt(/l/, 'hello', 4)).toBe(null);
|
||||
expect(matchAt(/l/, 'hello', 5)).toBe(null);
|
||||
|
||||
var match = matchAt(/l/, 'hello', 2);
|
||||
expect(Array.isArray(match)).toBe(true);
|
||||
expect(match.index).toBe(2);
|
||||
expect(match.input).toBe('hello');
|
||||
expect(match[0]).toBe('l');
|
||||
expect(match[1]).toBe(undefined);
|
||||
expect(match.length).toBe(1);
|
||||
|
||||
var match = matchAt(/l/, 'hello', 3);
|
||||
expect(Array.isArray(match)).toBe(true);
|
||||
expect(match.index).toBe(3);
|
||||
expect(match.input).toBe('hello');
|
||||
expect(match[0]).toBe('l');
|
||||
expect(match[1]).toBe(undefined);
|
||||
expect(match.length).toBe(1);
|
||||
});
|
||||
|
||||
it('matches a zero-length regex', function () {
|
||||
expect(matchAt(/(?=l)/, 'hello', 0)).toBe(null);
|
||||
expect(matchAt(/(?=l)/, 'hello', 1)).toBe(null);
|
||||
expect(matchAt(/(?=l)/, 'hello', 4)).toBe(null);
|
||||
expect(matchAt(/(?=l)/, 'hello', 5)).toBe(null);
|
||||
|
||||
var match = matchAt(/(?=l)/, 'hello', 2);
|
||||
expect(Array.isArray(match)).toBe(true);
|
||||
expect(match.index).toBe(2);
|
||||
expect(match.input).toBe('hello');
|
||||
expect(match[0]).toBe('');
|
||||
expect(match[1]).toBe(undefined);
|
||||
expect(match.length).toBe(1);
|
||||
|
||||
var match = matchAt(/(?=l)/, 'hello', 3);
|
||||
expect(Array.isArray(match)).toBe(true);
|
||||
expect(match.index).toBe(3);
|
||||
expect(match.input).toBe('hello');
|
||||
expect(match[0]).toBe('');
|
||||
expect(match[1]).toBe(undefined);
|
||||
expect(match.length).toBe(1);
|
||||
});
|
||||
|
||||
it('matches a regex with capturing groups', function () {
|
||||
expect(matchAt(/(l)(l)?/, 'hello', 0)).toBe(null);
|
||||
expect(matchAt(/(l)(l)?/, 'hello', 1)).toBe(null);
|
||||
expect(matchAt(/(l)(l)?/, 'hello', 4)).toBe(null);
|
||||
expect(matchAt(/(l)(l)?/, 'hello', 5)).toBe(null);
|
||||
|
||||
var match = matchAt(/(l)(l)?/, 'hello', 2);
|
||||
expect(Array.isArray(match)).toBe(true);
|
||||
expect(match.index).toBe(2);
|
||||
expect(match.input).toBe('hello');
|
||||
expect(match[0]).toBe('ll');
|
||||
expect(match[1]).toBe('l');
|
||||
expect(match[2]).toBe('l');
|
||||
expect(match.length).toBe(3);
|
||||
|
||||
var match = matchAt(/(l)(l)?/, 'hello', 3);
|
||||
expect(Array.isArray(match)).toBe(true);
|
||||
expect(match.index).toBe(3);
|
||||
expect(match.input).toBe('hello');
|
||||
expect(match[0]).toBe('l');
|
||||
expect(match[1]).toBe('l');
|
||||
expect(match[2]).toBe(undefined);
|
||||
expect(match.length).toBe(3);
|
||||
});
|
||||
|
||||
it('copies flags over', function () {
|
||||
expect(matchAt(/L/i, 'hello', 0)).toBe(null);
|
||||
expect(matchAt(/L/i, 'hello', 1)).toBe(null);
|
||||
expect(matchAt(/L/i, 'hello', 2)).not.toBe(null);
|
||||
expect(matchAt(/L/i, 'hello', 3)).not.toBe(null);
|
||||
expect(matchAt(/L/i, 'hello', 4)).toBe(null);
|
||||
expect(matchAt(/L/i, 'hello', 5)).toBe(null);
|
||||
});
|
||||
});
|
38
node_modules/match-at/lib/matchAt.js
generated
vendored
Normal file
38
node_modules/match-at/lib/matchAt.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
function getRelocatable(re) {
|
||||
// In the future, this could use a WeakMap instead of an expando.
|
||||
if (!re.__matchAtRelocatable) {
|
||||
// Disjunctions are the lowest-precedence operator, so we can make any
|
||||
// pattern match the empty string by appending `|()` to it:
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-patterns
|
||||
var source = re.source + '|()';
|
||||
|
||||
// We always make the new regex global.
|
||||
var flags = 'g' + (re.ignoreCase ? 'i' : '') + (re.multiline ? 'm' : '') + (re.unicode ? 'u' : '')
|
||||
// sticky (/.../y) doesn't make sense in conjunction with our relocation
|
||||
// logic, so we ignore it here.
|
||||
;
|
||||
|
||||
re.__matchAtRelocatable = new RegExp(source, flags);
|
||||
}
|
||||
return re.__matchAtRelocatable;
|
||||
}
|
||||
|
||||
function matchAt(re, str, pos) {
|
||||
if (re.global || re.sticky) {
|
||||
throw new Error('matchAt(...): Only non-global regexes are supported');
|
||||
}
|
||||
var reloc = getRelocatable(re);
|
||||
reloc.lastIndex = pos;
|
||||
var match = reloc.exec(str);
|
||||
// Last capturing group is our sentinel that indicates whether the regex
|
||||
// matched at the given location.
|
||||
if (match[match.length - 1] == null) {
|
||||
// Original regex matched.
|
||||
match.length = match.length - 1;
|
||||
return match;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = matchAt;
|
40
node_modules/match-at/lib/matchAt.js.flow
generated
vendored
Normal file
40
node_modules/match-at/lib/matchAt.js.flow
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/** @flow */
|
||||
|
||||
function getRelocatable(re: RegExp): RegExp {
|
||||
// In the future, this could use a WeakMap instead of an expando.
|
||||
if (!(re: any).__matchAtRelocatable) {
|
||||
// Disjunctions are the lowest-precedence operator, so we can make any
|
||||
// pattern match the empty string by appending `|()` to it:
|
||||
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-patterns
|
||||
var source = re.source + '|()';
|
||||
|
||||
// We always make the new regex global.
|
||||
var flags = 'g' + (re.ignoreCase ? 'i' : '') + (re.multiline ? 'm' : '') + ((re: any).unicode ? 'u' : '')
|
||||
// sticky (/.../y) doesn't make sense in conjunction with our relocation
|
||||
// logic, so we ignore it here.
|
||||
;
|
||||
|
||||
(re: any).__matchAtRelocatable = new RegExp(source, flags);
|
||||
}
|
||||
return (re: any).__matchAtRelocatable;
|
||||
}
|
||||
|
||||
function matchAt(re: RegExp, str: string, pos: number): any {
|
||||
if (re.global || (re: any).sticky) {
|
||||
throw new Error('matchAt(...): Only non-global regexes are supported');
|
||||
}
|
||||
var reloc = getRelocatable(re);
|
||||
reloc.lastIndex = pos;
|
||||
var match: Array<string> = reloc.exec(str);
|
||||
// Last capturing group is our sentinel that indicates whether the regex
|
||||
// matched at the given location.
|
||||
if (match[match.length - 1] == null) {
|
||||
// Original regex matched.
|
||||
match.length = match.length - 1;
|
||||
return match;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = matchAt;
|
98
node_modules/match-at/package.json
generated
vendored
Normal file
98
node_modules/match-at/package.json
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"name": "match-at",
|
||||
"raw": "match-at@^0.1.0",
|
||||
"rawSpec": "^0.1.0",
|
||||
"scope": null,
|
||||
"spec": ">=0.1.0 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/Volumes/Atelier/lucil/Documents/_WEB/StreamMusicalPerformance/node_modules/katex"
|
||||
]
|
||||
],
|
||||
"_from": "match-at@>=0.1.0 <0.2.0",
|
||||
"_id": "match-at@0.1.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/match-at",
|
||||
"_nodeVersion": "8.2.1",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "s3://npm-registry-packages",
|
||||
"tmp": "tmp/match-at-0.1.1.tgz_1504663382647_0.7046560752205551"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "aria@classjourney.org",
|
||||
"name": "ariabuckles"
|
||||
},
|
||||
"_npmVersion": "5.3.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "match-at",
|
||||
"raw": "match-at@^0.1.0",
|
||||
"rawSpec": "^0.1.0",
|
||||
"scope": null,
|
||||
"spec": ">=0.1.0 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/katex"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/match-at/-/match-at-0.1.1.tgz",
|
||||
"_shasum": "25d040d291777704d5e6556bbb79230ec2de0540",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "match-at@^0.1.0",
|
||||
"_where": "/Volumes/Atelier/lucil/Documents/_WEB/StreamMusicalPerformance/node_modules/katex",
|
||||
"babel": {
|
||||
"plugins": [
|
||||
"transform-flow-strip-types"
|
||||
]
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sophiebits/match-at/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Relocatable regular expressions.",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-jest": "^21.0.0",
|
||||
"babel-plugin-syntax-flow": "^6.18.0",
|
||||
"babel-plugin-transform-flow-strip-types": "^6.22.0",
|
||||
"jest": "^21.0.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"integrity": "sha512-h4Yd392z9mST+dzc+yjuybOGFNOZjmXIPKWjxBd1Bb23r4SmDOsk2NYCU2BMUBGbSpZqwVsZYNq26QS3xfaT3Q==",
|
||||
"shasum": "25d040d291777704d5e6556bbb79230ec2de0540",
|
||||
"tarball": "https://registry.npmjs.org/match-at/-/match-at-0.1.1.tgz"
|
||||
},
|
||||
"files": [
|
||||
"lib/"
|
||||
],
|
||||
"gitHead": "4921ff66e58f7acd2d4f856504c7a3657b69ec6f",
|
||||
"homepage": "https://github.com/sophiebits/match-at#readme",
|
||||
"main": "lib/matchAt.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"email": "aria@classjourney.org",
|
||||
"name": "ariabuckles"
|
||||
},
|
||||
{
|
||||
"email": "npm@sophiebits.com",
|
||||
"name": "spicyj"
|
||||
}
|
||||
],
|
||||
"name": "match-at",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sophiebits/match-at.git"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "babel --no-babelrc --plugins syntax-flow -d lib/ src/ && mv lib/matchAt.js lib/matchAt.js.flow && babel -d lib/ src/",
|
||||
"test": "jest"
|
||||
},
|
||||
"version": "0.1.1"
|
||||
}
|
Reference in New Issue
Block a user