node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

21
server/node_modules/byte-size/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014-23 Lloyd Brookes <75pound@gmail.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.

164
server/node_modules/byte-size/README.hbs generated vendored Normal file
View File

@@ -0,0 +1,164 @@
[![view on npm](https://badgen.net/npm/v/byte-size)](https://www.npmjs.org/package/byte-size)
[![npm module downloads](https://badgen.net/npm/dt/byte-size)](https://www.npmjs.org/package/byte-size)
[![Gihub repo dependents](https://badgen.net/github/dependents-repo/75lb/byte-size)](https://github.com/75lb/byte-size/network/dependents?dependent_type=REPOSITORY)
[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/byte-size)](https://github.com/75lb/byte-size/network/dependents?dependent_type=PACKAGE)
[![Node.js CI](https://github.com/75lb/byte-size/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/byte-size/actions/workflows/node.js.yml)
[![Coverage Status](https://coveralls.io/repos/github/75lb/byte-size/badge.svg)](https://coveralls.io/github/75lb/byte-size)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
***Upgraders, please check the [release notes](https://github.com/75lb/byte-size/releases).***
# byte-size
An isomorphic, load-anywhere function to convert a bytes value (e.g. `3456`) to a human-readable string (`'3.5 kB'`). Choose between [metric or IEC units](https://en.wikipedia.org/wiki/Gigabyte) (summarised below) or specify your own custom units.
Value | Metric | Metric (octet) |
----- | ------------- | -------------- |
1000 | kB kilobyte | ko kilooctet |
1000^2 | MB megabyte | Mo megaoctet |
1000^3 | GB gigabyte | Go gigaoctet |
1000^4 | TB terabyte | To teraoctet |
1000^5 | PB petabyte | Po petaoctet |
1000^6 | EB exabyte | Eo exaoctet |
1000^7 | ZB zettabyte | Zo zettaoctet |
1000^8 | YB yottabyte | Yo yottaoctet |
Value | IEC | IEC (octet) |
------ | ------------ | ------------- |
1024 | KiB kibibyte | Kio kibioctet |
1024^2 | MiB mebibyte | Mio mebioctet |
1024^3 | GiB gibibyte | Gio gibioctet |
1024^4 | TiB tebibyte | Tio tebioctet |
1024^5 | PiB pebibyte | Pio pebioctet |
1024^6 | EiB exbibyte | Eio exbioctet |
1024^7 | ZiB zebibyte | Zio zebioctet |
1024^8 | YiB yobibyte | Yio yobioctet |
## Synopsis
By default, `byteSize` converts the input number to a human readable string with metric units and a precision of 1.
```js
> const byteSize = require('byte-size')
> byteSize(1580)
{ value: '1.6', unit: 'kB', long: 'kilobytes' }
```
The object returned by `byteSize` defines a `toString` method therefore can be used directly in string context.
```js
> `Filesize: ${byteSize(12400)}`
'Filesize: 12.4 kB'
```
Override the default `toString` behaviour by setting [`options.toStringFn`](#bytesizebytes-options--object-).
```js
> function toStringFn () {
return `**${this.value}${this.unit}**`
}
> `Filesize: ${byteSize(12400, { toStringFn })}`
'Filesize: **12.4kB**'
```
Beside the default of `metric`, there are three other built-in units available: `metric_octet`, `iec` and `iec_octet`.
```js
> byteSize(1580, { units: 'iec' })
{ value: '1.5', unit: 'KiB', long: 'kibibytes' }
> byteSize(1580, { units: 'iec_octet' })
{ value: '1.5', unit: 'Kio', long: 'kibioctets' }
> byteSize(1580, { units: 'metric_octet' })
{ value: '1.6', unit: 'ko', long: 'kilooctets' }
```
You can adjust the `precision`.
```js
> byteSize(1580, { units: 'iec', precision: 3 })
{ value: '1.543', unit: 'KiB', long: 'kibibytes' }
> byteSize(1580, { units: 'iec', precision: 0 })
{ value: '2', unit: 'KiB', long: 'kibibytes' }
```
Define custom units by passing an object containing one or more additional conversion tables to `options.customUnits`. In `options.units`, specify the name of a property from the `customUnits` object.
```js
> const customUnits = {
simple: [
{ from: 0 , to: 1e3 , unit: '' },
{ from: 1e3 , to: 1e6 , unit: 'K', long: 'thousand' },
{ from: 1e6 , to: 1e9 , unit: 'Mn', long: 'million' },
{ from: 1e9 , to: 1e12, unit: 'Bn', long: 'billion' }
]
}
> const { value, unit } = byteSize(10000, { customUnits, units: 'simple' })
> `${value}${unit}`
'10.0K'
```
Override the built-in defaults for the duration of the process by passing an options object to `byteSize.defaultOptions()`. This results in cleaner code in cases where `byteSize` is used often with the same options.
```js
> byteSize.defaultOptions({
units: 'simple',
precision: 2,
customUnits: {
simple: [
{ from: 0, to: 1e3, unit: '' },
{ from: 1e3, to: 1e6, unit: 'k' },
{ from: 1e6, to: 1e9, unit: 'm' },
{ from: 1e9, to: 1e12, unit: 'bn' },
]
},
toStringFn: function () {
return this.value + this.unit
}
})
> [2400, 16400, 3991200].map(byteSize).join(', ')
'2.40k, 16.40k, 3.99m'
```
{{>main}}
## Load anywhere
This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.
Node.js (CommonJS):
```js
const byteSize = require('byte-size')
```
Node.js (ECMAScript Module):
```js
import byteSize from 'byte-size'
```
Within a modern browser ECMAScript Module:
```js
import byteSize from './node_modules/byte-size/index.js'
```
Browser global (adds `window.byteSize`):
```html
<script src="./node_modules/byte-size/dist/index.js"></script>
```
* * *
&copy; 2014-23 [Lloyd Brookes](https://github.com/75lb) \<75pound@gmail.com\>.
Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

199
server/node_modules/byte-size/README.md generated vendored Normal file
View File

@@ -0,0 +1,199 @@
[![view on npm](https://badgen.net/npm/v/byte-size)](https://www.npmjs.org/package/byte-size)
[![npm module downloads](https://badgen.net/npm/dt/byte-size)](https://www.npmjs.org/package/byte-size)
[![Gihub repo dependents](https://badgen.net/github/dependents-repo/75lb/byte-size)](https://github.com/75lb/byte-size/network/dependents?dependent_type=REPOSITORY)
[![Gihub package dependents](https://badgen.net/github/dependents-pkg/75lb/byte-size)](https://github.com/75lb/byte-size/network/dependents?dependent_type=PACKAGE)
[![Node.js CI](https://github.com/75lb/byte-size/actions/workflows/node.js.yml/badge.svg)](https://github.com/75lb/byte-size/actions/workflows/node.js.yml)
[![Coverage Status](https://coveralls.io/repos/github/75lb/byte-size/badge.svg)](https://coveralls.io/github/75lb/byte-size)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
***Upgraders, please check the [release notes](https://github.com/75lb/byte-size/releases).***
# byte-size
An isomorphic, load-anywhere function to convert a bytes value (e.g. `3456`) to a human-readable string (`'3.5 kB'`). Choose between [metric or IEC units](https://en.wikipedia.org/wiki/Gigabyte) (summarised below) or specify your own custom units.
Value | Metric | Metric (octet) |
----- | ------------- | -------------- |
1000 | kB kilobyte | ko kilooctet |
1000^2 | MB megabyte | Mo megaoctet |
1000^3 | GB gigabyte | Go gigaoctet |
1000^4 | TB terabyte | To teraoctet |
1000^5 | PB petabyte | Po petaoctet |
1000^6 | EB exabyte | Eo exaoctet |
1000^7 | ZB zettabyte | Zo zettaoctet |
1000^8 | YB yottabyte | Yo yottaoctet |
Value | IEC | IEC (octet) |
------ | ------------ | ------------- |
1024 | KiB kibibyte | Kio kibioctet |
1024^2 | MiB mebibyte | Mio mebioctet |
1024^3 | GiB gibibyte | Gio gibioctet |
1024^4 | TiB tebibyte | Tio tebioctet |
1024^5 | PiB pebibyte | Pio pebioctet |
1024^6 | EiB exbibyte | Eio exbioctet |
1024^7 | ZiB zebibyte | Zio zebioctet |
1024^8 | YiB yobibyte | Yio yobioctet |
## Synopsis
By default, `byteSize` converts the input number to a human readable string with metric units and a precision of 1.
```js
> const byteSize = require('byte-size')
> byteSize(1580)
{ value: '1.6', unit: 'kB', long: 'kilobytes' }
```
The object returned by `byteSize` defines a `toString` method therefore can be used directly in string context.
```js
> `Filesize: ${byteSize(12400)}`
'Filesize: 12.4 kB'
```
Override the default `toString` behaviour by setting [`options.toStringFn`](#bytesizebytes-options--object-).
```js
> function toStringFn () {
return `**${this.value}${this.unit}**`
}
> `Filesize: ${byteSize(12400, { toStringFn })}`
'Filesize: **12.4kB**'
```
Beside the default of `metric`, there are three other built-in units available: `metric_octet`, `iec` and `iec_octet`.
```js
> byteSize(1580, { units: 'iec' })
{ value: '1.5', unit: 'KiB', long: 'kibibytes' }
> byteSize(1580, { units: 'iec_octet' })
{ value: '1.5', unit: 'Kio', long: 'kibioctets' }
> byteSize(1580, { units: 'metric_octet' })
{ value: '1.6', unit: 'ko', long: 'kilooctets' }
```
You can adjust the `precision`.
```js
> byteSize(1580, { units: 'iec', precision: 3 })
{ value: '1.543', unit: 'KiB', long: 'kibibytes' }
> byteSize(1580, { units: 'iec', precision: 0 })
{ value: '2', unit: 'KiB', long: 'kibibytes' }
```
Define custom units by passing an object containing one or more additional conversion tables to `options.customUnits`. In `options.units`, specify the name of a property from the `customUnits` object.
```js
> const customUnits = {
simple: [
{ from: 0 , to: 1e3 , unit: '' },
{ from: 1e3 , to: 1e6 , unit: 'K', long: 'thousand' },
{ from: 1e6 , to: 1e9 , unit: 'Mn', long: 'million' },
{ from: 1e9 , to: 1e12, unit: 'Bn', long: 'billion' }
]
}
> const { value, unit } = byteSize(10000, { customUnits, units: 'simple' })
> `${value}${unit}`
'10.0K'
```
Override the built-in defaults for the duration of the process by passing an options object to `byteSize.defaultOptions()`. This results in cleaner code in cases where `byteSize` is used often with the same options.
```js
> byteSize.defaultOptions({
units: 'simple',
precision: 2,
customUnits: {
simple: [
{ from: 0, to: 1e3, unit: '' },
{ from: 1e3, to: 1e6, unit: 'k' },
{ from: 1e6, to: 1e9, unit: 'm' },
{ from: 1e9, to: 1e12, unit: 'bn' },
]
},
toStringFn: function () {
return this.value + this.unit
}
})
> [2400, 16400, 3991200].map(byteSize).join(', ')
'2.40k, 16.40k, 3.99m'
```
<a name="module_byte-size"></a>
## byte-size
* [byte-size](#module_byte-size)
* [byteSize(bytes, [options])](#exp_module_byte-size--byteSize) ⇒ <code>object</code> ⏏
* [.defaultOptions(options)](#module_byte-size--byteSize.defaultOptions)
<a name="exp_module_byte-size--byteSize"></a>
### byteSize(bytes, [options]) ⇒ <code>object</code> ⏏
Returns an object with the spec `{ value: string, unit: string, long: string }`. The returned object defines a `toString` method meaning it can be used in any string context.
**Kind**: Exported function
| Param | Type | Description |
| --- | --- | --- |
| bytes | <code>number</code> | The bytes value to convert. |
| [options] | <code>object</code> | Optional config. |
| [options.precision] | <code>number</code> | Number of decimal places. Defaults to `1`. |
| [options.units] | <code>string</code> | Specify `'metric'`, `'iec'`, `'metric_octet'`, `'iec_octet'` or the name of a property from the custom units table in `options.customUnits`. Defaults to `metric`. |
| [options.customUnits] | <code>object</code> | An object containing one or more custom unit lookup tables. |
| [options.toStringFn] | <code>function</code> | A `toString` function to override the default. |
| [options.locale] | <code>string</code> \| <code>Array.&lt;string&gt;</code> | *Node >=13 or modern browser only - on earlier platforms this option is ignored*. The locale to use for number formatting (e.g. `'de-DE'`). Defaults to your system locale. Passed directed into [Intl.NumberFormat()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat). |
<a name="module_byte-size--byteSize.defaultOptions"></a>
#### byteSize.defaultOptions(options)
Set the default `byteSize` options for the duration of the process.
**Kind**: static method of [<code>byteSize</code>](#exp_module_byte-size--byteSize)
| Param | Type | Description |
| --- | --- | --- |
| options | <code>object</code> | A `byteSize` options object. |
## Load anywhere
This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.
Node.js (CommonJS):
```js
const byteSize = require('byte-size')
```
Node.js (ECMAScript Module):
```js
import byteSize from 'byte-size'
```
Within a modern browser ECMAScript Module:
```js
import byteSize from './node_modules/byte-size/index.js'
```
Browser global (adds `window.byteSize`):
```html
<script src="./node_modules/byte-size/dist/index.js"></script>
```
* * *
&copy; 2014-23 [Lloyd Brookes](https://github.com/75lb) \<75pound@gmail.com\>.
Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

125
server/node_modules/byte-size/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,125 @@
'use strict';
/**
* @module byte-size
*/
let defaultOptions = {};
const _options = new WeakMap();
const referenceTables = {
metric: [
{ from: 0, to: 1e3, unit: 'B', long: 'bytes' },
{ from: 1e3, to: 1e6, unit: 'kB', long: 'kilobytes' },
{ from: 1e6, to: 1e9, unit: 'MB', long: 'megabytes' },
{ from: 1e9, to: 1e12, unit: 'GB', long: 'gigabytes' },
{ from: 1e12, to: 1e15, unit: 'TB', long: 'terabytes' },
{ from: 1e15, to: 1e18, unit: 'PB', long: 'petabytes' },
{ from: 1e18, to: 1e21, unit: 'EB', long: 'exabytes' },
{ from: 1e21, to: 1e24, unit: 'ZB', long: 'zettabytes' },
{ from: 1e24, to: 1e27, unit: 'YB', long: 'yottabytes' }
],
metric_octet: [
{ from: 0, to: 1e3, unit: 'o', long: 'octets' },
{ from: 1e3, to: 1e6, unit: 'ko', long: 'kilooctets' },
{ from: 1e6, to: 1e9, unit: 'Mo', long: 'megaoctets' },
{ from: 1e9, to: 1e12, unit: 'Go', long: 'gigaoctets' },
{ from: 1e12, to: 1e15, unit: 'To', long: 'teraoctets' },
{ from: 1e15, to: 1e18, unit: 'Po', long: 'petaoctets' },
{ from: 1e18, to: 1e21, unit: 'Eo', long: 'exaoctets' },
{ from: 1e21, to: 1e24, unit: 'Zo', long: 'zettaoctets' },
{ from: 1e24, to: 1e27, unit: 'Yo', long: 'yottaoctets' }
],
iec: [
{ from: 0, to: Math.pow(1024, 1), unit: 'B', long: 'bytes' },
{ from: Math.pow(1024, 1), to: Math.pow(1024, 2), unit: 'KiB', long: 'kibibytes' },
{ from: Math.pow(1024, 2), to: Math.pow(1024, 3), unit: 'MiB', long: 'mebibytes' },
{ from: Math.pow(1024, 3), to: Math.pow(1024, 4), unit: 'GiB', long: 'gibibytes' },
{ from: Math.pow(1024, 4), to: Math.pow(1024, 5), unit: 'TiB', long: 'tebibytes' },
{ from: Math.pow(1024, 5), to: Math.pow(1024, 6), unit: 'PiB', long: 'pebibytes' },
{ from: Math.pow(1024, 6), to: Math.pow(1024, 7), unit: 'EiB', long: 'exbibytes' },
{ from: Math.pow(1024, 7), to: Math.pow(1024, 8), unit: 'ZiB', long: 'zebibytes' },
{ from: Math.pow(1024, 8), to: Math.pow(1024, 9), unit: 'YiB', long: 'yobibytes' }
],
iec_octet: [
{ from: 0, to: Math.pow(1024, 1), unit: 'o', long: 'octets' },
{ from: Math.pow(1024, 1), to: Math.pow(1024, 2), unit: 'Kio', long: 'kibioctets' },
{ from: Math.pow(1024, 2), to: Math.pow(1024, 3), unit: 'Mio', long: 'mebioctets' },
{ from: Math.pow(1024, 3), to: Math.pow(1024, 4), unit: 'Gio', long: 'gibioctets' },
{ from: Math.pow(1024, 4), to: Math.pow(1024, 5), unit: 'Tio', long: 'tebioctets' },
{ from: Math.pow(1024, 5), to: Math.pow(1024, 6), unit: 'Pio', long: 'pebioctets' },
{ from: Math.pow(1024, 6), to: Math.pow(1024, 7), unit: 'Eio', long: 'exbioctets' },
{ from: Math.pow(1024, 7), to: Math.pow(1024, 8), unit: 'Zio', long: 'zebioctets' },
{ from: Math.pow(1024, 8), to: Math.pow(1024, 9), unit: 'Yio', long: 'yobioctets' }
]
};
class ByteSize {
constructor (bytes, options) {
options = Object.assign({
units: 'metric',
precision: 1,
locale: undefined // Default to the user's system locale
}, defaultOptions, options);
_options.set(this, options);
Object.assign(referenceTables, options.customUnits);
const prefix = bytes < 0 ? '-' : '';
bytes = Math.abs(bytes);
const table = referenceTables[options.units];
if (table) {
const units = table.find(u => bytes >= u.from && bytes < u.to);
if (units) {
const defaultFormat = new Intl.NumberFormat(options.locale, {
style: 'decimal',
minimumFractionDigits: options.precision,
maximumFractionDigits: options.precision
});
const value = units.from === 0
? prefix + bytes
: prefix + defaultFormat.format(bytes / units.from);
this.value = value;
this.unit = units.unit;
this.long = units.long;
} else {
this.value = prefix + bytes;
this.unit = '';
this.long = '';
}
} else {
throw new Error(`Invalid units specified: ${options.units}`)
}
}
toString () {
const options = _options.get(this);
return options.toStringFn ? options.toStringFn.bind(this)() : `${this.value} ${this.unit}`
}
}
/**
* Returns an object with the spec `{ value: string, unit: string, long: string }`. The returned object defines a `toString` method meaning it can be used in any string context.
* @param {number} - The bytes value to convert.
* @param [options] {object} - Optional config.
* @param [options.precision] {number} - Number of decimal places. Defaults to `1`.
* @param [options.units] {string} - Specify `'metric'`, `'iec'`, `'metric_octet'`, `'iec_octet'` or the name of a property from the custom units table in `options.customUnits`. Defaults to `metric`.
* @param [options.customUnits] {object} - An object containing one or more custom unit lookup tables.
* @param [options.toStringFn] {function} - A `toString` function to override the default.
* @param [options.locale] {string|string[]} - *Node >=13 or modern browser only - on earlier platforms this option is ignored*. The locale to use for number formatting (e.g. `'de-DE'`). Defaults to your system locale. Passed directed into [Intl.NumberFormat()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat).
* @returns {object}
* @alias module:byte-size
*/
function byteSize (bytes, options) {
return new ByteSize(bytes, options)
}
/**
* Set the default `byteSize` options for the duration of the process.
* @param options {object} - A `byteSize` options object.
*/
byteSize.defaultOptions = function (options) {
defaultOptions = options;
};
module.exports = byteSize;

131
server/node_modules/byte-size/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,131 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.byteSize = factory());
})(this, (function () { 'use strict';
/**
* @module byte-size
*/
let defaultOptions = {};
const _options = new WeakMap();
const referenceTables = {
metric: [
{ from: 0, to: 1e3, unit: 'B', long: 'bytes' },
{ from: 1e3, to: 1e6, unit: 'kB', long: 'kilobytes' },
{ from: 1e6, to: 1e9, unit: 'MB', long: 'megabytes' },
{ from: 1e9, to: 1e12, unit: 'GB', long: 'gigabytes' },
{ from: 1e12, to: 1e15, unit: 'TB', long: 'terabytes' },
{ from: 1e15, to: 1e18, unit: 'PB', long: 'petabytes' },
{ from: 1e18, to: 1e21, unit: 'EB', long: 'exabytes' },
{ from: 1e21, to: 1e24, unit: 'ZB', long: 'zettabytes' },
{ from: 1e24, to: 1e27, unit: 'YB', long: 'yottabytes' }
],
metric_octet: [
{ from: 0, to: 1e3, unit: 'o', long: 'octets' },
{ from: 1e3, to: 1e6, unit: 'ko', long: 'kilooctets' },
{ from: 1e6, to: 1e9, unit: 'Mo', long: 'megaoctets' },
{ from: 1e9, to: 1e12, unit: 'Go', long: 'gigaoctets' },
{ from: 1e12, to: 1e15, unit: 'To', long: 'teraoctets' },
{ from: 1e15, to: 1e18, unit: 'Po', long: 'petaoctets' },
{ from: 1e18, to: 1e21, unit: 'Eo', long: 'exaoctets' },
{ from: 1e21, to: 1e24, unit: 'Zo', long: 'zettaoctets' },
{ from: 1e24, to: 1e27, unit: 'Yo', long: 'yottaoctets' }
],
iec: [
{ from: 0, to: Math.pow(1024, 1), unit: 'B', long: 'bytes' },
{ from: Math.pow(1024, 1), to: Math.pow(1024, 2), unit: 'KiB', long: 'kibibytes' },
{ from: Math.pow(1024, 2), to: Math.pow(1024, 3), unit: 'MiB', long: 'mebibytes' },
{ from: Math.pow(1024, 3), to: Math.pow(1024, 4), unit: 'GiB', long: 'gibibytes' },
{ from: Math.pow(1024, 4), to: Math.pow(1024, 5), unit: 'TiB', long: 'tebibytes' },
{ from: Math.pow(1024, 5), to: Math.pow(1024, 6), unit: 'PiB', long: 'pebibytes' },
{ from: Math.pow(1024, 6), to: Math.pow(1024, 7), unit: 'EiB', long: 'exbibytes' },
{ from: Math.pow(1024, 7), to: Math.pow(1024, 8), unit: 'ZiB', long: 'zebibytes' },
{ from: Math.pow(1024, 8), to: Math.pow(1024, 9), unit: 'YiB', long: 'yobibytes' }
],
iec_octet: [
{ from: 0, to: Math.pow(1024, 1), unit: 'o', long: 'octets' },
{ from: Math.pow(1024, 1), to: Math.pow(1024, 2), unit: 'Kio', long: 'kibioctets' },
{ from: Math.pow(1024, 2), to: Math.pow(1024, 3), unit: 'Mio', long: 'mebioctets' },
{ from: Math.pow(1024, 3), to: Math.pow(1024, 4), unit: 'Gio', long: 'gibioctets' },
{ from: Math.pow(1024, 4), to: Math.pow(1024, 5), unit: 'Tio', long: 'tebioctets' },
{ from: Math.pow(1024, 5), to: Math.pow(1024, 6), unit: 'Pio', long: 'pebioctets' },
{ from: Math.pow(1024, 6), to: Math.pow(1024, 7), unit: 'Eio', long: 'exbioctets' },
{ from: Math.pow(1024, 7), to: Math.pow(1024, 8), unit: 'Zio', long: 'zebioctets' },
{ from: Math.pow(1024, 8), to: Math.pow(1024, 9), unit: 'Yio', long: 'yobioctets' }
]
};
class ByteSize {
constructor (bytes, options) {
options = Object.assign({
units: 'metric',
precision: 1,
locale: undefined // Default to the user's system locale
}, defaultOptions, options);
_options.set(this, options);
Object.assign(referenceTables, options.customUnits);
const prefix = bytes < 0 ? '-' : '';
bytes = Math.abs(bytes);
const table = referenceTables[options.units];
if (table) {
const units = table.find(u => bytes >= u.from && bytes < u.to);
if (units) {
const defaultFormat = new Intl.NumberFormat(options.locale, {
style: 'decimal',
minimumFractionDigits: options.precision,
maximumFractionDigits: options.precision
});
const value = units.from === 0
? prefix + bytes
: prefix + defaultFormat.format(bytes / units.from);
this.value = value;
this.unit = units.unit;
this.long = units.long;
} else {
this.value = prefix + bytes;
this.unit = '';
this.long = '';
}
} else {
throw new Error(`Invalid units specified: ${options.units}`)
}
}
toString () {
const options = _options.get(this);
return options.toStringFn ? options.toStringFn.bind(this)() : `${this.value} ${this.unit}`
}
}
/**
* Returns an object with the spec `{ value: string, unit: string, long: string }`. The returned object defines a `toString` method meaning it can be used in any string context.
* @param {number} - The bytes value to convert.
* @param [options] {object} - Optional config.
* @param [options.precision] {number} - Number of decimal places. Defaults to `1`.
* @param [options.units] {string} - Specify `'metric'`, `'iec'`, `'metric_octet'`, `'iec_octet'` or the name of a property from the custom units table in `options.customUnits`. Defaults to `metric`.
* @param [options.customUnits] {object} - An object containing one or more custom unit lookup tables.
* @param [options.toStringFn] {function} - A `toString` function to override the default.
* @param [options.locale] {string|string[]} - *Node >=13 or modern browser only - on earlier platforms this option is ignored*. The locale to use for number formatting (e.g. `'de-DE'`). Defaults to your system locale. Passed directed into [Intl.NumberFormat()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat).
* @returns {object}
* @alias module:byte-size
*/
function byteSize (bytes, options) {
return new ByteSize(bytes, options)
}
/**
* Set the default `byteSize` options for the duration of the process.
* @param options {object} - A `byteSize` options object.
*/
byteSize.defaultOptions = function (options) {
defaultOptions = options;
};
return byteSize;
}));

123
server/node_modules/byte-size/index.js generated vendored Normal file
View File

@@ -0,0 +1,123 @@
/**
* @module byte-size
*/
let defaultOptions = {}
const _options = new WeakMap()
const referenceTables = {
metric: [
{ from: 0, to: 1e3, unit: 'B', long: 'bytes' },
{ from: 1e3, to: 1e6, unit: 'kB', long: 'kilobytes' },
{ from: 1e6, to: 1e9, unit: 'MB', long: 'megabytes' },
{ from: 1e9, to: 1e12, unit: 'GB', long: 'gigabytes' },
{ from: 1e12, to: 1e15, unit: 'TB', long: 'terabytes' },
{ from: 1e15, to: 1e18, unit: 'PB', long: 'petabytes' },
{ from: 1e18, to: 1e21, unit: 'EB', long: 'exabytes' },
{ from: 1e21, to: 1e24, unit: 'ZB', long: 'zettabytes' },
{ from: 1e24, to: 1e27, unit: 'YB', long: 'yottabytes' }
],
metric_octet: [
{ from: 0, to: 1e3, unit: 'o', long: 'octets' },
{ from: 1e3, to: 1e6, unit: 'ko', long: 'kilooctets' },
{ from: 1e6, to: 1e9, unit: 'Mo', long: 'megaoctets' },
{ from: 1e9, to: 1e12, unit: 'Go', long: 'gigaoctets' },
{ from: 1e12, to: 1e15, unit: 'To', long: 'teraoctets' },
{ from: 1e15, to: 1e18, unit: 'Po', long: 'petaoctets' },
{ from: 1e18, to: 1e21, unit: 'Eo', long: 'exaoctets' },
{ from: 1e21, to: 1e24, unit: 'Zo', long: 'zettaoctets' },
{ from: 1e24, to: 1e27, unit: 'Yo', long: 'yottaoctets' }
],
iec: [
{ from: 0, to: Math.pow(1024, 1), unit: 'B', long: 'bytes' },
{ from: Math.pow(1024, 1), to: Math.pow(1024, 2), unit: 'KiB', long: 'kibibytes' },
{ from: Math.pow(1024, 2), to: Math.pow(1024, 3), unit: 'MiB', long: 'mebibytes' },
{ from: Math.pow(1024, 3), to: Math.pow(1024, 4), unit: 'GiB', long: 'gibibytes' },
{ from: Math.pow(1024, 4), to: Math.pow(1024, 5), unit: 'TiB', long: 'tebibytes' },
{ from: Math.pow(1024, 5), to: Math.pow(1024, 6), unit: 'PiB', long: 'pebibytes' },
{ from: Math.pow(1024, 6), to: Math.pow(1024, 7), unit: 'EiB', long: 'exbibytes' },
{ from: Math.pow(1024, 7), to: Math.pow(1024, 8), unit: 'ZiB', long: 'zebibytes' },
{ from: Math.pow(1024, 8), to: Math.pow(1024, 9), unit: 'YiB', long: 'yobibytes' }
],
iec_octet: [
{ from: 0, to: Math.pow(1024, 1), unit: 'o', long: 'octets' },
{ from: Math.pow(1024, 1), to: Math.pow(1024, 2), unit: 'Kio', long: 'kibioctets' },
{ from: Math.pow(1024, 2), to: Math.pow(1024, 3), unit: 'Mio', long: 'mebioctets' },
{ from: Math.pow(1024, 3), to: Math.pow(1024, 4), unit: 'Gio', long: 'gibioctets' },
{ from: Math.pow(1024, 4), to: Math.pow(1024, 5), unit: 'Tio', long: 'tebioctets' },
{ from: Math.pow(1024, 5), to: Math.pow(1024, 6), unit: 'Pio', long: 'pebioctets' },
{ from: Math.pow(1024, 6), to: Math.pow(1024, 7), unit: 'Eio', long: 'exbioctets' },
{ from: Math.pow(1024, 7), to: Math.pow(1024, 8), unit: 'Zio', long: 'zebioctets' },
{ from: Math.pow(1024, 8), to: Math.pow(1024, 9), unit: 'Yio', long: 'yobioctets' }
]
}
class ByteSize {
constructor (bytes, options) {
options = Object.assign({
units: 'metric',
precision: 1,
locale: undefined // Default to the user's system locale
}, defaultOptions, options)
_options.set(this, options)
Object.assign(referenceTables, options.customUnits)
const prefix = bytes < 0 ? '-' : ''
bytes = Math.abs(bytes)
const table = referenceTables[options.units]
if (table) {
const units = table.find(u => bytes >= u.from && bytes < u.to)
if (units) {
const defaultFormat = new Intl.NumberFormat(options.locale, {
style: 'decimal',
minimumFractionDigits: options.precision,
maximumFractionDigits: options.precision
})
const value = units.from === 0
? prefix + bytes
: prefix + defaultFormat.format(bytes / units.from)
this.value = value
this.unit = units.unit
this.long = units.long
} else {
this.value = prefix + bytes
this.unit = ''
this.long = ''
}
} else {
throw new Error(`Invalid units specified: ${options.units}`)
}
}
toString () {
const options = _options.get(this)
return options.toStringFn ? options.toStringFn.bind(this)() : `${this.value} ${this.unit}`
}
}
/**
* Returns an object with the spec `{ value: string, unit: string, long: string }`. The returned object defines a `toString` method meaning it can be used in any string context.
* @param {number} - The bytes value to convert.
* @param [options] {object} - Optional config.
* @param [options.precision] {number} - Number of decimal places. Defaults to `1`.
* @param [options.units] {string} - Specify `'metric'`, `'iec'`, `'metric_octet'`, `'iec_octet'` or the name of a property from the custom units table in `options.customUnits`. Defaults to `metric`.
* @param [options.customUnits] {object} - An object containing one or more custom unit lookup tables.
* @param [options.toStringFn] {function} - A `toString` function to override the default.
* @param [options.locale] {string|string[]} - *Node >=13 or modern browser only - on earlier platforms this option is ignored*. The locale to use for number formatting (e.g. `'de-DE'`). Defaults to your system locale. Passed directed into [Intl.NumberFormat()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat).
* @returns {object}
* @alias module:byte-size
*/
function byteSize (bytes, options) {
return new ByteSize(bytes, options)
}
/**
* Set the default `byteSize` options for the duration of the process.
* @param options {object} - A `byteSize` options object.
*/
byteSize.defaultOptions = function (options) {
defaultOptions = options
}
export default byteSize

55
server/node_modules/byte-size/package.json generated vendored Normal file
View File

@@ -0,0 +1,55 @@
{
"name": "byte-size",
"author": "Lloyd Brookes <75pound@gmail.com>",
"version": "8.1.1",
"description": "Convert a bytes or octets value (e.g. 34565346) to a human-readable string ('34.6 MB'). Choose between metric or IEC units.",
"repository": "https://github.com/75lb/byte-size",
"type": "module",
"exports": {
"import": "./index.js",
"require": "./dist/index.cjs"
},
"license": "MIT",
"engines": {
"node": ">=12.17"
},
"files": [
"index.js",
"dist"
],
"keywords": [
"convert",
"bytes",
"octet",
"size",
"human",
"readable",
"metric",
"IEC"
],
"scripts": {
"test": "npm run dist && npm run test:ci",
"test:ci": "npm run test:esm",
"test:esm": "test-runner --view.hide-skips test.js",
"docs": "jsdoc2md -t README.hbs index.js > README.md",
"cover": "c8 npm test && c8 report --reporter=text-lcov | coveralls",
"dist": "rollup -c"
},
"devDependencies": {
"jsdoc-to-markdown": "^8.0.0",
"rollup": "^3.21.3",
"test-runner": "^0.10.1"
},
"standard": {
"ignore": [
"dist"
]
},
"contributors": [
{
"name": "Raul Perez",
"email": "repejota@gmail.com",
"url": "http://repejota.com"
}
]
}