diff options
author | Minteck <contact@minteck.org> | 2023-02-23 19:34:56 +0100 |
---|---|---|
committer | Minteck <contact@minteck.org> | 2023-02-23 19:34:56 +0100 |
commit | 3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch) | |
tree | 75be5fba4368472fb11c8015aee026b2b9a71888 /school/node_modules/matchit | |
parent | 8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff) | |
download | pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2 pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip |
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'school/node_modules/matchit')
-rw-r--r-- | school/node_modules/matchit/index.d.ts | 11 | ||||
-rw-r--r-- | school/node_modules/matchit/lib/matchit.js | 119 | ||||
-rw-r--r-- | school/node_modules/matchit/lib/matchit.mjs | 115 | ||||
-rw-r--r-- | school/node_modules/matchit/license.md | 21 | ||||
-rw-r--r-- | school/node_modules/matchit/package.json | 46 | ||||
-rw-r--r-- | school/node_modules/matchit/readme.md | 166 |
6 files changed, 0 insertions, 478 deletions
diff --git a/school/node_modules/matchit/index.d.ts b/school/node_modules/matchit/index.d.ts deleted file mode 100644 index fb6c0dd..0000000 --- a/school/node_modules/matchit/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export interface Segment { - old: string; - type: number; - val: string; -} - -export type Route = Segment[]; - -export function exec(url: string, match: Route): Record<string, string>; -export function match(path: string, routes: Route[]): Route; -export function parse(path: string): Route; diff --git a/school/node_modules/matchit/lib/matchit.js b/school/node_modules/matchit/lib/matchit.js deleted file mode 100644 index 2c76c54..0000000 --- a/school/node_modules/matchit/lib/matchit.js +++ /dev/null @@ -1,119 +0,0 @@ -'use strict'; - -const every = require('@arr/every'); - -const SEP = '/'; -// Types ~> static, param, any, optional -const STYPE=0, PTYPE=1, ATYPE=2, OTYPE=3; -// Char Codes ~> / : * -const SLASH=47, COLON=58, ASTER=42, QMARK=63; - -function strip(str) { - if (str === SEP) return str; - (str.charCodeAt(0) === SLASH) && (str=str.substring(1)); - var len = str.length - 1; - return str.charCodeAt(len) === SLASH ? str.substring(0, len) : str; -} - -function split(str) { - return (str=strip(str)) === SEP ? [SEP] : str.split(SEP); -} - -function isMatch(arr, obj, idx) { - idx = arr[idx]; - return (obj.val === idx && obj.type === STYPE) || (idx === SEP ? obj.type > PTYPE : obj.type !== STYPE && (idx || '').endsWith(obj.end)); -} - -function match(str, all) { - var i=0, tmp, segs=split(str), len=segs.length, l; - var fn = isMatch.bind(isMatch, segs); - - for (; i < all.length; i++) { - tmp = all[i]; - if ((l=tmp.length) === len || (l < len && tmp[l-1].type === ATYPE) || (l > len && tmp[l-1].type === OTYPE)) { - if (every(tmp, fn)) return tmp; - } - } - - return []; -} - -function parse(str) { - if (str === SEP) { - return [{ old:str, type:STYPE, val:str, end:'' }]; - } - - var c, x, t, sfx, nxt=strip(str), i=-1, j=0, len=nxt.length, out=[]; - - while (++i < len) { - c = nxt.charCodeAt(i); - - if (c === COLON) { - j = i + 1; // begining of param - t = PTYPE; // set type - x = 0; // reset mark - sfx = ''; - - while (i < len && nxt.charCodeAt(i) !== SLASH) { - c = nxt.charCodeAt(i); - if (c === QMARK) { - x=i; t=OTYPE; - } else if (c === 46 && sfx.length === 0) { - sfx = nxt.substring(x=i); - } - i++; // move on - } - - out.push({ - old: str, - type: t, - val: nxt.substring(j, x||i), - end: sfx - }); - - // shorten string & update pointers - nxt=nxt.substring(i); len-=i; i=0; - - continue; // loop - } else if (c === ASTER) { - out.push({ - old: str, - type: ATYPE, - val: nxt.substring(i), - end: '' - }); - continue; // loop - } else { - j = i; - while (i < len && nxt.charCodeAt(i) !== SLASH) { - ++i; // skip to next slash - } - out.push({ - old: str, - type: STYPE, - val: nxt.substring(j, i), - end: '' - }); - // shorten string & update pointers - nxt=nxt.substring(i); len-=i; i=j=0; - } - } - - return out; -} - -function exec(str, arr) { - var i=0, x, y, segs=split(str), out={}; - for (; i < arr.length; i++) { - x=segs[i]; y=arr[i]; - if (x === SEP) continue; - if (x !== void 0 && y.type | 2 === OTYPE) { - out[ y.val ] = x.replace(y.end, ''); - } - } - return out; -} - -exports.exec = exec; -exports.match = match; -exports.parse = parse;
\ No newline at end of file diff --git a/school/node_modules/matchit/lib/matchit.mjs b/school/node_modules/matchit/lib/matchit.mjs deleted file mode 100644 index 03da81e..0000000 --- a/school/node_modules/matchit/lib/matchit.mjs +++ /dev/null @@ -1,115 +0,0 @@ -'use strict'; - -import every from '@arr/every'; - -const SEP = '/'; -// Types ~> static, param, any, optional -const STYPE=0, PTYPE=1, ATYPE=2, OTYPE=3; -// Char Codes ~> / : * -const SLASH=47, COLON=58, ASTER=42, QMARK=63; - -function strip(str) { - if (str === SEP) return str; - (str.charCodeAt(0) === SLASH) && (str=str.substring(1)); - var len = str.length - 1; - return str.charCodeAt(len) === SLASH ? str.substring(0, len) : str; -} - -function split(str) { - return (str=strip(str)) === SEP ? [SEP] : str.split(SEP); -} - -function isMatch(arr, obj, idx) { - idx = arr[idx]; - return (obj.val === idx && obj.type === STYPE) || (idx === SEP ? obj.type > PTYPE : obj.type !== STYPE && (idx || '').endsWith(obj.end)); -} - -export function match(str, all) { - var i=0, tmp, segs=split(str), len=segs.length, l; - var fn = isMatch.bind(isMatch, segs); - - for (; i < all.length; i++) { - tmp = all[i]; - if ((l=tmp.length) === len || (l < len && tmp[l-1].type === ATYPE) || (l > len && tmp[l-1].type === OTYPE)) { - if (every(tmp, fn)) return tmp; - } - } - - return []; -} - -export function parse(str) { - if (str === SEP) { - return [{ old:str, type:STYPE, val:str, end:'' }]; - } - - var c, x, t, sfx, nxt=strip(str), i=-1, j=0, len=nxt.length, out=[]; - - while (++i < len) { - c = nxt.charCodeAt(i); - - if (c === COLON) { - j = i + 1; // begining of param - t = PTYPE; // set type - x = 0; // reset mark - sfx = ''; - - while (i < len && nxt.charCodeAt(i) !== SLASH) { - c = nxt.charCodeAt(i); - if (c === QMARK) { - x=i; t=OTYPE; - } else if (c === 46 && sfx.length === 0) { - sfx = nxt.substring(x=i); - } - i++; // move on - } - - out.push({ - old: str, - type: t, - val: nxt.substring(j, x||i), - end: sfx - }); - - // shorten string & update pointers - nxt=nxt.substring(i); len-=i; i=0; - - continue; // loop - } else if (c === ASTER) { - out.push({ - old: str, - type: ATYPE, - val: nxt.substring(i), - end: '' - }); - continue; // loop - } else { - j = i; - while (i < len && nxt.charCodeAt(i) !== SLASH) { - ++i; // skip to next slash - } - out.push({ - old: str, - type: STYPE, - val: nxt.substring(j, i), - end: '' - }); - // shorten string & update pointers - nxt=nxt.substring(i); len-=i; i=j=0; - } - } - - return out; -} - -export function exec(str, arr) { - var i=0, x, y, segs=split(str), out={}; - for (; i < arr.length; i++) { - x=segs[i]; y=arr[i]; - if (x === SEP) continue; - if (x !== void 0 && y.type | 2 === OTYPE) { - out[ y.val ] = x.replace(y.end, ''); - } - } - return out; -} diff --git a/school/node_modules/matchit/license.md b/school/node_modules/matchit/license.md deleted file mode 100644 index a3f96f8..0000000 --- a/school/node_modules/matchit/license.md +++ /dev/null @@ -1,21 +0,0 @@ -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. diff --git a/school/node_modules/matchit/package.json b/school/node_modules/matchit/package.json deleted file mode 100644 index 619a3fd..0000000 --- a/school/node_modules/matchit/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "matchit", - "version": "1.1.0", - "repository": "lukeed/matchit", - "description": "Quickly parse & match URLs", - "module": "lib/matchit.mjs", - "main": "lib/matchit.js", - "types": "index.d.ts", - "license": "MIT", - "files": [ - "*.d.ts", - "lib" - ], - "author": { - "name": "Luke Edwards", - "email": "luke.edwards05@gmail.com", - "url": "https://lukeed.com" - }, - "engines": { - "node": ">=6" - }, - "scripts": { - "build": "bundt", - "bench": "node bench", - "pretest": "npm run build", - "prebench": "npm run build", - "test": "tape test/*.js | tap-spec" - }, - "keywords": [ - "route", - "regexp", - "routing", - "pattern", - "match", - "parse", - "url" - ], - "dependencies": { - "@arr/every": "^1.0.0" - }, - "devDependencies": { - "bundt": "^0.3.0", - "tap-spec": "^4.1.1", - "tape": "^4.6.3" - } -} diff --git a/school/node_modules/matchit/readme.md b/school/node_modules/matchit/readme.md deleted file mode 100644 index c131890..0000000 --- a/school/node_modules/matchit/readme.md +++ /dev/null @@ -1,166 +0,0 @@ -# matchit [![Build Status](https://travis-ci.org/lukeed/matchit.svg?branch=master)](https://travis-ci.org/lukeed/matchit) - -> Quickly parse & match URLs - -## Install - -``` -$ npm install --save matchit -``` - - -## Usage - -```js -const { exec, match, parse } = require('matchit'); - -parse('/foo/:bar/:baz?'); -//=> [ -//=> { old:'/foo/:bar', type:0, val:'foo' }, -//=> { old:'/foo/:bar', type:1, val:'bar' }, -//=> { old:'/foo/:bar', type:3, val:'baz' } -//=> ] - -const routes = ['/', '/foo', 'bar', '/baz', '/baz/:title','/bat/*'].map(parse); - -match('/', routes); -//=> [{ old:'/', type:0, val:'/' }] - -match('/foo', routes); -//=> [{ old:'/foo', type:0, val:'foo' }] - -match('/bar', routes); -//=> [{ old:'bar', type:0, val:'bar' }] - -match('/baz', routes); -//=> [{ old:'/baz', type:0, val:'baz' }] - -let a = match('/baz/hello', routes); -//=> [{...}, {...}] -let b = exec('/baz/hello', a); -//=> { title:'hello' } - -match('/bat/quz/qut', routes); -//=> [ -//=> { old:'/bat/*', type:0, val:'bat' }, -//=> { old:'/bat/*', type:2, val:'*' } -//=> ] -``` - - -## API - -### matchit.parse(route) - -Returns: `Array` - -The `route` is `split` and parsed into a "definition" array of objects. Each object ("segment") contains a `val`, `type`, and `old` key: - -* `old` — The [`route`](#route)'s original value -* `type` — An numerical representation of the segment type. - * `0` - static - * `1` - parameter - * `2` - any/wildcard - * `3` - optional param -* `val` — The current segment's value. This is either a static value of the name of a parameter - -#### route - -Type: `String` - -A single URL pattern. - -> **Note:** Input will be stripped of all leading & trailing `/` characters, so there's no need to normalize your own URLs before passing it to `parse`! - - -### matchit.match(url, routes) - -Returns: `Array` - -Returns the [`route`](#route)'s encoded definition. See [`matchit.parse`](#matchitparseroute). - -#### url - -Type: `String` - -The true URL you want to be matched. - -#### routes - -Type: `Array` - -_All_ "parsed" route definitions, via [`matchit.parse`](#matchitparseroute). - -> **Important:** Multiple routes will require an Array of `matchit.parse` outputs. - - -### matchit.exec(url, match) - -Returns: `Object` - -Returns an object an object of `key:val` pairs, as defined by your [`route`](#route) pattern. - -#### url - -Type: `String` - -The URL (`pathname`) to evaluate. - -> **Important:** This should be `pathname`s only as any `querystring`s will be included the response. - -#### match - -Type: `Array` - -The route definition to use, via [`matchit.match`](#matchitmatchurl-routes). - - -## Benchmarks - -> Running Node v10.13.0 - -``` -# Parsing - matchit x 1,489,482 ops/sec ±2.89% (97 runs sampled) - regexparam x 406,824 ops/sec ±1.38% (96 runs sampled) - path-to-regexp x 83,439 ops/sec ±0.89% (96 runs sampled) - path-to-regexp.parse x 421,266 ops/sec ±0.13% (97 runs sampled) - -# Match (index) - matchit x 132,338,546 ops/sec ±0.14% (96 runs sampled) - regexparam x 49,889,162 ops/sec ±0.21% (95 runs sampled) - path-to-regexp.exec x 7,176,721 ops/sec ±1.23% (94 runs sampled) - path-to-regexp.tokens x 102,021 ops/sec ±0.21% (96 runs sampled) - -# Match (param) - matchit x 2,700,618 ops/sec ±0.92% (95 runs sampled) - regexparam x 6,924,653 ops/sec ±0.33% (94 runs sampled) - path-to-regexp.exec x 4,715,483 ops/sec ±0.28% (96 runs sampled) - path-to-regexp.tokens x 98,182 ops/sec ±0.45% (93 runs sampled) - -# Match (optional) - matchit x 2,816,313 ops/sec ±0.64% (93 runs sampled) - regexparam x 8,437,064 ops/sec ±0.41% (93 runs sampled) - path-to-regexp.exec x 5,909,510 ops/sec ±0.22% (97 runs sampled) - path-to-regexp.tokens x 101,832 ops/sec ±0.43% (98 runs sampled) - -# Match (wildcard) - matchit x 3,409,100 ops/sec ±0.34% (98 runs sampled) - regexparam x 9,740,429 ops/sec ±0.49% (95 runs sampled) - path-to-regexp.exec x 8,740,590 ops/sec ±0.43% (89 runs sampled) - path-to-regexp.tokens x 102,109 ops/sec ±0.35% (96 runs sampled) - -# Exec - matchit x 1,558,321 ops/sec ±0.33% (96 runs sampled) - regexparam x 6,966,297 ops/sec ±0.21% (97 runs sampled) - path-to-regexp x 102,250 ops/sec ±0.45% (95 runs sampled) -``` - -## Related - -- [regexparam](https://github.com/lukeed/regexparam) - A similar (285B) utility, but relies on `RegExp` instead of String comparisons. - - -## License - -MIT © [Luke Edwards](https://lukeed.com) |