First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
26
node_modules/regexparam/dist/regexparam.js
generated
vendored
Normal file
26
node_modules/regexparam/dist/regexparam.js
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
module.exports = function (str, loose) {
|
||||
if (str instanceof RegExp) return { keys:false, pattern:str };
|
||||
var c, o, tmp, ext, keys=[], pattern='', arr = str.split('/');
|
||||
arr[0] || arr.shift();
|
||||
|
||||
while (tmp = arr.shift()) {
|
||||
c = tmp[0];
|
||||
if (c === '*') {
|
||||
keys.push('wild');
|
||||
pattern += '/(.*)';
|
||||
} else if (c === ':') {
|
||||
o = tmp.indexOf('?', 1);
|
||||
ext = tmp.indexOf('.', 1);
|
||||
keys.push( tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length) );
|
||||
pattern += !!~o && !~ext ? '(?:/([^/]+?))?' : '/([^/]+?)';
|
||||
if (!!~ext) pattern += (!!~o ? '?' : '') + '\\' + tmp.substring(ext);
|
||||
} else {
|
||||
pattern += '/' + tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
keys: keys,
|
||||
pattern: new RegExp('^' + pattern + (loose ? '(?=$|\/)' : '\/?$'), 'i')
|
||||
};
|
||||
}
|
1
node_modules/regexparam/dist/regexparam.min.js
generated
vendored
Normal file
1
node_modules/regexparam/dist/regexparam.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.regexparam=n()}(this,function(){return function(e,n){if(e instanceof RegExp)return{keys:!1,pattern:e};var t,i,f,r,s=[],o="",u=e.split("/");for(u[0]||u.shift();f=u.shift();)"*"===(t=f[0])?(s.push("wild"),o+="/(.*)"):":"===t?(i=f.indexOf("?",1),r=f.indexOf(".",1),s.push(f.substring(1,~i?i:~r?r:f.length)),o+=~i&&!~r?"(?:/([^/]+?))?":"/([^/]+?)",~r&&(o+=(~i?"?":"")+"\\"+f.substring(r))):o+="/"+f;return{keys:s,pattern:new RegExp("^"+o+(n?"(?=$|/)":"/?$"),"i")}}});
|
26
node_modules/regexparam/dist/regexparam.mjs
generated
vendored
Normal file
26
node_modules/regexparam/dist/regexparam.mjs
generated
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
export default function (str, loose) {
|
||||
if (str instanceof RegExp) return { keys:false, pattern:str };
|
||||
var c, o, tmp, ext, keys=[], pattern='', arr = str.split('/');
|
||||
arr[0] || arr.shift();
|
||||
|
||||
while (tmp = arr.shift()) {
|
||||
c = tmp[0];
|
||||
if (c === '*') {
|
||||
keys.push('wild');
|
||||
pattern += '/(.*)';
|
||||
} else if (c === ':') {
|
||||
o = tmp.indexOf('?', 1);
|
||||
ext = tmp.indexOf('.', 1);
|
||||
keys.push( tmp.substring(1, !!~o ? o : !!~ext ? ext : tmp.length) );
|
||||
pattern += !!~o && !~ext ? '(?:/([^/]+?))?' : '/([^/]+?)';
|
||||
if (!!~ext) pattern += (!!~o ? '?' : '') + '\\' + tmp.substring(ext);
|
||||
} else {
|
||||
pattern += '/' + tmp;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
keys: keys,
|
||||
pattern: new RegExp('^' + pattern + (loose ? '(?=$|\/)' : '\/?$'), 'i')
|
||||
};
|
||||
}
|
21
node_modules/regexparam/license
generated
vendored
Normal file
21
node_modules/regexparam/license
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.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.
|
73
node_modules/regexparam/package.json
generated
vendored
Normal file
73
node_modules/regexparam/package.json
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
"_args": [
|
||||
[
|
||||
"regexparam@1.3.0",
|
||||
"F:\\Documents\\websites\\BMM"
|
||||
]
|
||||
],
|
||||
"_from": "regexparam@1.3.0",
|
||||
"_id": "regexparam@1.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g==",
|
||||
"_location": "/regexparam",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "regexparam@1.3.0",
|
||||
"name": "regexparam",
|
||||
"escapedName": "regexparam",
|
||||
"rawSpec": "1.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/route-manifest"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/regexparam/-/regexparam-1.3.0.tgz",
|
||||
"_spec": "1.3.0",
|
||||
"_where": "F:\\Documents\\websites\\BMM",
|
||||
"author": {
|
||||
"name": "Luke Edwards",
|
||||
"email": "luke.edwards05@gmail.com",
|
||||
"url": "lukeed.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/lukeed/regexparam/issues"
|
||||
},
|
||||
"description": "A tiny (308B) utility that converts route patterns into RegExp. Limited alternative to `path-to-regexp` 🙇",
|
||||
"devDependencies": {
|
||||
"bundt": "^0.3.0",
|
||||
"tap-spec": "^4.1.1",
|
||||
"tape": "^4.8.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"dist"
|
||||
],
|
||||
"homepage": "https://github.com/lukeed/regexparam#readme",
|
||||
"keywords": [
|
||||
"regexp",
|
||||
"route",
|
||||
"routing"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "dist/regexparam.js",
|
||||
"module": "dist/regexparam.mjs",
|
||||
"name": "regexparam",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/lukeed/regexparam.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bundt",
|
||||
"pretest": "npm run build",
|
||||
"test": "tape test/*.js | tap-spec"
|
||||
},
|
||||
"types": "types.d.ts",
|
||||
"unpkg": "dist/regexparam.min.js",
|
||||
"version": "1.3.0"
|
||||
}
|
175
node_modules/regexparam/readme.md
generated
vendored
Normal file
175
node_modules/regexparam/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,175 @@
|
|||
# regexparam [](https://travis-ci.org/lukeed/regexparam)
|
||||
|
||||
> A tiny (308B) utility that converts route patterns into RegExp. Limited alternative to [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp) 🙇
|
||||
|
||||
With `regexparam`, you may turn a pathing string (eg, `/users/:id`) into a regular expression.
|
||||
|
||||
An object with shape of `{ keys, pattern }` is returned, where `pattern` is the `RegExp` and `keys` is an array of your parameter name(s) in the order that they appeared.
|
||||
|
||||
Unlike [`path-to-regexp`](https://github.com/pillarjs/path-to-regexp), this module does not create a `keys` dictionary, nor mutate an existing variable. Also, this only ships a parser, which only accept strings. Similarly, and most importantly, `regexparam` **only** handles basic pathing operators:
|
||||
|
||||
* Static (`/foo`, `/foo/bar`)
|
||||
* Parameter (`/:title`, `/books/:title`, `/books/:genre/:title`)
|
||||
* Parameter w/ Suffix (`/movies/:title.mp4`, `/movies/:title.(mp4|mov)`)
|
||||
* Optional Parameters (`/:title?`, `/books/:title?`, `/books/:genre/:title?`)
|
||||
* Wildcards (`*`, `/books/*`, `/books/:genre/*`)
|
||||
|
||||
This module exposes two module definitions:
|
||||
|
||||
* **CommonJS**: `dist/regexparam.js`
|
||||
* **ESModule**: `dist/regexparam.mjs`
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save regexparam
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const regexparam = require('regexparam');
|
||||
|
||||
// Example param-assignment
|
||||
function exec(path, result) {
|
||||
let i=0, out={};
|
||||
let matches = result.pattern.exec(path);
|
||||
while (i < result.keys.length) {
|
||||
out[ result.keys[i] ] = matches[++i] || null;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
// Parameter, with Optional Parameter
|
||||
// ---
|
||||
let foo = regexparam('/books/:genre/:title?')
|
||||
// foo.pattern => /^\/books\/([^\/]+?)(?:\/([^\/]+?))?\/?$/i
|
||||
// foo.keys => ['genre', 'title']
|
||||
|
||||
foo.pattern.test('/books/horror'); //=> true
|
||||
foo.pattern.test('/books/horror/goosebumps'); //=> true
|
||||
|
||||
exec('/books/horror', foo);
|
||||
//=> { genre: 'horror', title: null }
|
||||
|
||||
exec('/books/horror/goosebumps', foo);
|
||||
//=> { genre: 'horror', title: 'goosebumps' }
|
||||
|
||||
|
||||
// Parameter, with suffix
|
||||
// ---
|
||||
let bar = regexparam('/movies/:title.(mp4|mov)');
|
||||
// bar.pattern => /^\/movies\/([^\/]+?)\.(mp4|mov)\/?$/i
|
||||
// bar.keys => ['title']
|
||||
|
||||
bar.pattern.test('/movies/narnia'); //=> false
|
||||
bar.pattern.test('/movies/narnia.mp3'); //=> false
|
||||
bar.pattern.test('/movies/narnia.mp4'); //=> true
|
||||
|
||||
exec('/movies/narnia.mp4', bar);
|
||||
//=> { title: 'narnia' }
|
||||
|
||||
|
||||
// Wildcard
|
||||
// ---
|
||||
let baz = regexparam('users/*');
|
||||
// baz.pattern => /^\/users\/(.*)\/?$/i
|
||||
// baz.keys => ['wild']
|
||||
|
||||
baz.pattern.test('/users'); //=> false
|
||||
baz.pattern.test('/users/lukeed'); //=> true
|
||||
|
||||
exec('/users/lukeed/repos/new', baz);
|
||||
//=> { wild: 'lukeed/repos/new' }
|
||||
```
|
||||
|
||||
> **Important:** When matching/testing against a generated RegExp, your path **must** begin with a leading slash (`"/"`)!
|
||||
|
||||
## Regular Expressions
|
||||
|
||||
For fine-tuned control, you may pass a `RegExp` value directly to `regexparam` as its only parameter.
|
||||
|
||||
In these situations, `regexparam` **does not** parse nor manipulate your pattern in any way! Because of this, `regexparam` has no "insight" on your route, and instead trusts your input fully. In code, this means that the return value's `keys` is always equal to `false` and the `pattern` is identical to your input value.
|
||||
|
||||
This also means that you must manage and parse your own `keys`~!<br>
|
||||
You may use [named capture groups](https://javascript.info/regexp-groups#named-groups) or traverse the matched segments manually the "old-fashioned" way:
|
||||
|
||||
> **Important:** Please check your target browsers' and target [Node.js runtimes' support](https://node.green/#ES2018-features--RegExp-named-capture-groups)!
|
||||
|
||||
```js
|
||||
// Named capture group
|
||||
const named = regexparam(/^\/posts[/](?<year>[0-9]{4})[/](?<month>[0-9]{2})[/](?<title>[^\/]+)/i);
|
||||
const { groups } = named.pattern.exec('/posts/2019/05/hello-world');
|
||||
console.log(groups);
|
||||
//=> { year: '2019', month: '05', title: 'hello-world' }
|
||||
|
||||
// Widely supported / "Old-fashioned"
|
||||
const named = regexparam(/^\/posts[/]([0-9]{4})[/]([0-9]{2})[/]([^\/]+)/i);
|
||||
const [url, year, month, title] = named.pattern.exec('/posts/2019/05/hello-world');
|
||||
console.log(year, month, title);
|
||||
//=> 2019 05 hello-world
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
There are two API variants:
|
||||
|
||||
1) When passing a `String` input, the `loose` parameter is able to affect the output. [View API](#regexparamstr-loose)
|
||||
|
||||
2) When passing a `RegExp` value, that must be `regexparam`'s _only_ argument.<br>
|
||||
Your pattern is saved as written, so `loose` is ignored entirely. [View API](#regexparamrgx)
|
||||
|
||||
### regexparam(str, loose)
|
||||
Returns: `Object`
|
||||
|
||||
Returns a `{ keys, pattern }` object, where `pattern` is a generated `RegExp` instance and `keys` is a list of extracted parameter names.
|
||||
|
||||
#### str
|
||||
Type: `String`
|
||||
|
||||
The route/pathing string to convert.
|
||||
|
||||
> **Note:** It does not matter if your `str` begins with a `/` — it will be added if missing.
|
||||
|
||||
#### loose
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Should the `RegExp` match URLs that are longer than the [`str`](#str) pattern itself?<br>
|
||||
By default, the generated `RegExp` will test that the URL begins and _ends with_ the pattern.
|
||||
|
||||
```js
|
||||
const rgx = require('regexparam');
|
||||
|
||||
rgx('/users').pattern.test('/users/lukeed'); //=> false
|
||||
rgx('/users', true).pattern.test('/users/lukeed'); //=> true
|
||||
|
||||
rgx('/users/:name').pattern.test('/users/lukeed/repos'); //=> false
|
||||
rgx('/users/:name', true).pattern.test('/users/lukeed/repos'); //=> true
|
||||
```
|
||||
|
||||
### regexparam(rgx)
|
||||
Returns: `Object`
|
||||
|
||||
Returns a `{ keys, pattern }` object, where pattern is _identical_ to your `rgx` and `keys` is `false`, always.
|
||||
|
||||
#### rgx
|
||||
Type: `RegExp`
|
||||
|
||||
Your RegExp pattern.
|
||||
|
||||
> **Important:** This pattern is used _as is_! No parsing or interpreting is done on your behalf.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [trouter](https://github.com/lukeed/trouter) - A server-side HTTP router that extends from this module.
|
||||
- [matchit](https://github.com/lukeed/matchit) - Similar (650B) library, but relies on String comparison instead of `RegExp`s.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
11
node_modules/regexparam/types.d.ts
generated
vendored
Normal file
11
node_modules/regexparam/types.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
declare function regexparam(route: string, loose?: boolean): {
|
||||
keys: Array<string>,
|
||||
pattern: RegExp
|
||||
}
|
||||
|
||||
declare function regexparam(route: RegExp): {
|
||||
keys: false,
|
||||
pattern: RegExp
|
||||
}
|
||||
|
||||
export default regexparam;
|
Loading…
Add table
Add a link
Reference in a new issue