Projektstart
This commit is contained in:
37
backend/node_modules/@lukeed/ms/dist/index.js
generated
vendored
Normal file
37
backend/node_modules/@lukeed/ms/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var RGX = /^(-?(?:\d+)?\.?\d+) *(m(?:illiseconds?|s(?:ecs?)?))?(s(?:ec(?:onds?|s)?)?)?(m(?:in(?:utes?|s)?)?)?(h(?:ours?|rs?)?)?(d(?:ays?)?)?(w(?:eeks?|ks?)?)?(y(?:ears?|rs?)?)?$/,
|
||||
SEC = 1e3,
|
||||
MIN = SEC * 60,
|
||||
HOUR = MIN * 60,
|
||||
DAY = HOUR * 24,
|
||||
YEAR = DAY * 365.25;
|
||||
|
||||
function parse(val) {
|
||||
var num, arr = val.toLowerCase().match(RGX);
|
||||
if (arr != null && (num = parseFloat(arr[1]))) {
|
||||
if (arr[3] != null) return num * SEC;
|
||||
if (arr[4] != null) return num * MIN;
|
||||
if (arr[5] != null) return num * HOUR;
|
||||
if (arr[6] != null) return num * DAY;
|
||||
if (arr[7] != null) return num * DAY * 7;
|
||||
if (arr[8] != null) return num * YEAR;
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
function fmt(val, pfx, str, long) {
|
||||
var num = (val | 0) === val ? val : ~~(val + 0.5);
|
||||
return pfx + num + (long ? (' ' + str + (num != 1 ? 's' : '')) : str[0]);
|
||||
}
|
||||
|
||||
function format(num, long) {
|
||||
var pfx = num < 0 ? '-' : '', abs = num < 0 ? -num : num;
|
||||
if (abs < SEC) return num + (long ? ' ms' : 'ms');
|
||||
if (abs < MIN) return fmt(abs / SEC, pfx, 'second', long);
|
||||
if (abs < HOUR) return fmt(abs / MIN, pfx, 'minute', long);
|
||||
if (abs < DAY) return fmt(abs / HOUR, pfx, 'hour', long);
|
||||
if (abs < YEAR) return fmt(abs / DAY, pfx, 'day', long);
|
||||
return fmt(abs / YEAR, pfx, 'year', long);
|
||||
}
|
||||
|
||||
exports.format = format;
|
||||
exports.parse = parse;
|
||||
1
backend/node_modules/@lukeed/ms/dist/index.min.js
generated
vendored
Normal file
1
backend/node_modules/@lukeed/ms/dist/index.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.ms={})}(this,(function(e){var n=/^(-?(?:\d+)?\.?\d+) *(m(?:illiseconds?|s(?:ecs?)?))?(s(?:ec(?:onds?|s)?)?)?(m(?:in(?:utes?|s)?)?)?(h(?:ours?|rs?)?)?(d(?:ays?)?)?(w(?:eeks?|ks?)?)?(y(?:ears?|rs?)?)?$/,s=864e5,o=365.25*s;function r(e,n,s,o){var r=(0|e)===e?e:~~(e+.5);return n+r+(o?" "+s+(1!=r?"s":""):s[0])}e.format=function(e,n){var t=e<0?"-":"",u=e<0?-e:e;return u<1e3?e+(n?" ms":"ms"):u<6e4?r(u/1e3,t,"second",n):u<36e5?r(u/6e4,t,"minute",n):u<s?r(u/36e5,t,"hour",n):u<o?r(u/s,t,"day",n):r(u/o,t,"year",n)},e.parse=function(e){var r,t=e.toLowerCase().match(n);if(null!=t&&(r=parseFloat(t[1])))return null!=t[3]?1e3*r:null!=t[4]?6e4*r:null!=t[5]?36e5*r:null!=t[6]?r*s:null!=t[7]?r*s*7:null!=t[8]?r*o:r}}));
|
||||
34
backend/node_modules/@lukeed/ms/dist/index.mjs
generated
vendored
Normal file
34
backend/node_modules/@lukeed/ms/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
var RGX = /^(-?(?:\d+)?\.?\d+) *(m(?:illiseconds?|s(?:ecs?)?))?(s(?:ec(?:onds?|s)?)?)?(m(?:in(?:utes?|s)?)?)?(h(?:ours?|rs?)?)?(d(?:ays?)?)?(w(?:eeks?|ks?)?)?(y(?:ears?|rs?)?)?$/,
|
||||
SEC = 1e3,
|
||||
MIN = SEC * 60,
|
||||
HOUR = MIN * 60,
|
||||
DAY = HOUR * 24,
|
||||
YEAR = DAY * 365.25;
|
||||
|
||||
export function parse(val) {
|
||||
var num, arr = val.toLowerCase().match(RGX);
|
||||
if (arr != null && (num = parseFloat(arr[1]))) {
|
||||
if (arr[3] != null) return num * SEC;
|
||||
if (arr[4] != null) return num * MIN;
|
||||
if (arr[5] != null) return num * HOUR;
|
||||
if (arr[6] != null) return num * DAY;
|
||||
if (arr[7] != null) return num * DAY * 7;
|
||||
if (arr[8] != null) return num * YEAR;
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
function fmt(val, pfx, str, long) {
|
||||
var num = (val | 0) === val ? val : ~~(val + 0.5);
|
||||
return pfx + num + (long ? (' ' + str + (num != 1 ? 's' : '')) : str[0]);
|
||||
}
|
||||
|
||||
export function format(num, long) {
|
||||
var pfx = num < 0 ? '-' : '', abs = num < 0 ? -num : num;
|
||||
if (abs < SEC) return num + (long ? ' ms' : 'ms');
|
||||
if (abs < MIN) return fmt(abs / SEC, pfx, 'second', long);
|
||||
if (abs < HOUR) return fmt(abs / MIN, pfx, 'minute', long);
|
||||
if (abs < DAY) return fmt(abs / HOUR, pfx, 'hour', long);
|
||||
if (abs < YEAR) return fmt(abs / DAY, pfx, 'day', long);
|
||||
return fmt(abs / YEAR, pfx, 'year', long);
|
||||
}
|
||||
2
backend/node_modules/@lukeed/ms/index.d.ts
generated
vendored
Normal file
2
backend/node_modules/@lukeed/ms/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export function format(millis: number, long?: boolean): string;
|
||||
export function parse(input: string): number | undefined;
|
||||
9
backend/node_modules/@lukeed/ms/license
generated
vendored
Normal file
9
backend/node_modules/@lukeed/ms/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
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.
|
||||
48
backend/node_modules/@lukeed/ms/package.json
generated
vendored
Normal file
48
backend/node_modules/@lukeed/ms/package.json
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"umd:name": "ms",
|
||||
"version": "2.0.2",
|
||||
"name": "@lukeed/ms",
|
||||
"repository": "lukeed/ms",
|
||||
"description": "A tiny (414B) and fast utility to convert milliseconds to and from strings.",
|
||||
"unpkg": "dist/index.min.js",
|
||||
"module": "dist/index.mjs",
|
||||
"main": "dist/index.js",
|
||||
"types": "index.d.ts",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Luke Edwards",
|
||||
"email": "luke.edwards05@gmail.com",
|
||||
"url": "https://lukeed.com"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bundt",
|
||||
"test": "uvu -r esm test"
|
||||
},
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"dist"
|
||||
],
|
||||
"keywords": [
|
||||
"ms",
|
||||
"time",
|
||||
"format",
|
||||
"milliseconds",
|
||||
"convert"
|
||||
],
|
||||
"devDependencies": {
|
||||
"bundt": "1.1.2",
|
||||
"esm": "3.2.25",
|
||||
"uvu": "0.5.1"
|
||||
}
|
||||
}
|
||||
133
backend/node_modules/@lukeed/ms/readme.md
generated
vendored
Normal file
133
backend/node_modules/@lukeed/ms/readme.md
generated
vendored
Normal file
@@ -0,0 +1,133 @@
|
||||
# ms [](https://github.com/lukeed/ms/actions) [](https://codecov.io/gh/lukeed/ms)
|
||||
|
||||
> A tiny (414B) and [fast](#benchmarks) utility to convert milliseconds to and from strings.
|
||||
|
||||
---
|
||||
|
||||
***NOTICE:** This is a fork of [vercel/ms](https://github.com/vercel/ms)!*<br>
|
||||
In June 2019, I [opened a PR](https://github.com/zeit/ms/pull/120) with signficiant performance and code size improvements. After nearly 2 years of silence, it was eventually closed. :cry: A year into my wait, I started anew (this repo), hoping to improve upon my own improvements.
|
||||
|
||||
---
|
||||
|
||||
This module is delivered as:
|
||||
|
||||
* **CommonJS**: [`dist/index.js`](https://unpkg.com/@lukeed/ms/dist/index.js)
|
||||
* **ES Module**: [`dist/index.mjs`](https://unpkg.com/@lukeed/ms/dist/index.mjs)
|
||||
* **UMD**: [`dist/index.min.js`](https://unpkg.com/@lukeed/ms/dist/index.min.js)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save @lukeed/ms
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { parse, format } from '@lukeed/ms';
|
||||
|
||||
// string => number
|
||||
parse('2 days'); //=> 172800000
|
||||
parse('1d'); //=> 86400000
|
||||
parse('10h'); //=> 36000000
|
||||
parse('2.5 hrs'); //=> 9000000
|
||||
parse('2h'); //=> 7200000
|
||||
parse('1m'); //=> 60000
|
||||
parse('5s'); //=> 5000
|
||||
parse('1y'); //=> 31557600000
|
||||
parse('100'); //=> 100
|
||||
parse('-3 days'); //=> -259200000
|
||||
parse('-1h'); //=> -3600000
|
||||
parse('-200'); //=> -200
|
||||
|
||||
// number => string
|
||||
format(60000); //=> '1m'
|
||||
format(2 * 60000); //=> '2m'
|
||||
format(-3 * 60000); //=> '-3m'
|
||||
format(parse('10 hours')); //=> '10h'
|
||||
|
||||
// number => string (long)
|
||||
format(60000, true); //=> '1 minute'
|
||||
format(2 * 60000, true); //=> '2 minutes'
|
||||
format(-3 * 60000, true); //=> '-3 minutes'
|
||||
format(parse('10 hours'), true); //=> '10 hours'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### ms.parse(input)
|
||||
Returns: `Number`
|
||||
|
||||
Parses the input string, returning the number of milliseconds.
|
||||
|
||||
#### input
|
||||
Type: `String`
|
||||
|
||||
The human-readable time string; eg: `10min`, `10m`, `10 minutes`.
|
||||
|
||||
|
||||
### ms.format(milli, long?)
|
||||
Returns: `Number`
|
||||
|
||||
Formats the millisecond count to a human-readable time string.
|
||||
|
||||
> **Important:** The output will be rounded to the nearest whole integer.
|
||||
|
||||
#### milli
|
||||
Type: `Number`
|
||||
|
||||
The number of milliseconds.
|
||||
|
||||
#### long
|
||||
Type: `Boolean`<br>
|
||||
Default: `false`
|
||||
|
||||
Whether or not the output should use the interval's long/full form; eg `hour` or `hours` instead of `h`.
|
||||
|
||||
> **Note:** When `long`, the count and interval will be separated by a single space.<br>Also, when `long`, the interval may be pluralized; eg `1 second` vs `2 seconds`.
|
||||
|
||||
|
||||
## Benchmarks
|
||||
|
||||
> Running on Node.js v12.18.4
|
||||
|
||||
```
|
||||
Validation :: parse
|
||||
✔ lukeed/ms
|
||||
✔ zeit/ms
|
||||
|
||||
Benchmark :: "parse"
|
||||
lukeed/ms x 351,319 ops/sec ±0.31% (96 runs sampled)
|
||||
zeit/ms x 245,576 ops/sec ±1.66% (94 runs sampled)
|
||||
|
||||
Benchmark :: "parse" (long)
|
||||
lukeed/ms x 335,538 ops/sec ±0.50% (94 runs sampled)
|
||||
zeit/ms x 265,410 ops/sec ±1.72% (95 runs sampled)
|
||||
|
||||
|
||||
Validation :: format
|
||||
✔ lukeed/ms
|
||||
✔ zeit/ms
|
||||
|
||||
Benchmark :: "format"
|
||||
lukeed/ms x 4,109,440 ops/sec ±0.35% (94 runs sampled)
|
||||
zeit/ms x 3,420,198 ops/sec ±1.61% (94 runs sampled)
|
||||
|
||||
Benchmark :: "format" (long)
|
||||
lukeed/ms x 3,402,872 ops/sec ±0.14% (97 runs sampled)
|
||||
zeit/ms x 1,344,908 ops/sec ±3.68% (96 runs sampled)
|
||||
```
|
||||
|
||||
|
||||
## Credits
|
||||
|
||||
This is obviously a fork of [zeit/ms](https://github.com/zeit/ms).
|
||||
|
||||
I opened a [PR in June 2019](https://github.com/zeit/ms/pull/120) that introduced significant performance gains and code reduction — it was ignored for nearly two years. This repository is a from-scratch re-implementation that takes the goals of that PR a bit further.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
||||
Reference in New Issue
Block a user