js-build-tools 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/build.js +59 -59
  2. package/dist/bundle.js +12 -12
  3. package/dist/bundleLint.js +17 -17
  4. package/dist/bundleMinify.js +8 -8
  5. package/dist/copyFonts.js +8 -8
  6. package/dist/default.js +15 -15
  7. package/dist/distLint.js +17 -17
  8. package/dist/distMinify.js +8 -8
  9. package/dist/partials/addToReadme.js +13 -13
  10. package/dist/partials/beginWatcher.js +9 -9
  11. package/dist/partials/distFor.js +16 -16
  12. package/dist/partials/distForSrc.js +9 -9
  13. package/dist/partials/distSeries.js +19 -19
  14. package/dist/partials/imagesFor.js +27 -27
  15. package/dist/partials/readmeTemplate.js +11 -11
  16. package/dist/partials/runOnChange.js +27 -27
  17. package/dist/partials/sassFor.js +20 -20
  18. package/dist/partials/tsFor.js +20 -20
  19. package/dist/partials.js +34 -34
  20. package/dist/test-helpers/setUp.js +51 -51
  21. package/dist/testFull.js +17 -17
  22. package/dist/testHelpers.js +8 -8
  23. package/dist/testQuick.js +19 -19
  24. package/dist/utilities/dotGet.js +42 -42
  25. package/dist/utilities/dotNotate.js +50 -50
  26. package/dist/utilities/dotSet.js +36 -36
  27. package/dist/utilities/isObject.js +4 -4
  28. package/dist/utilities/strAfter.js +14 -0
  29. package/dist/utilities/strBefore.js +14 -0
  30. package/dist/watchTest.js +13 -13
  31. package/functions/utilities/dotGet.js +2 -2
  32. package/functions/utilities/dotSet.js +2 -2
  33. package/functions/utilities/strAfter.js +13 -0
  34. package/functions/utilities/strBefore.js +13 -0
  35. package/package.json +3 -3
  36. package/vendor/array-union/index.js +30 -30
  37. package/vendor/easy-transform-stream/index.js +54 -58
  38. package/vendor/globby/gitignore.js +96 -100
  39. package/vendor/globby/index.js +191 -195
  40. package/vendor/globby/stream-utils.js +57 -57
  41. package/vendor/globby/to-path.js +19 -19
  42. package/vendor/gulp-plugin-extras/index.js +42 -46
  43. package/vendor/gulp-plugin-extras/plugin-error.js +144 -144
  44. package/vendor/ignore/index.js +467 -467
  45. package/vendor/imagemin/index.js +90 -94
  46. package/vendor/imagemin-gifsicle/index.js +33 -37
  47. package/vendor/imagemin-mozjpeg/index.js +100 -104
  48. package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +2 -6
  49. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +2 -2
  50. package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +2 -6
  51. package/vendor/imagemin-optipng/index.js +43 -43
  52. package/vendor/imagemin-svgo/index.js +26 -26
  53. package/vendor/is-jpg/index.js +11 -11
  54. package/vendor/junk/index.js +48 -48
  55. package/vendor/mozjpeg/index.js +8 -8
  56. package/vendor/mozjpeg/lib/index.js +17 -17
  57. package/vendor/mozjpeg/package.json +49 -50
  58. package/vendor/mozjpeg/vendor/cjpeg +0 -0
  59. package/vendor/mozjpeg/vendor/source/mozjpeg.tar.gz +0 -0
  60. package/vendor/p-pipe/index.js +22 -26
  61. package/vendor/plur/index.js +31 -31
  62. package/vendor/pretty-bytes/index.js +70 -70
  63. package/vendor/slash/index.js +11 -11
@@ -1,27 +1,27 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _nodeBuffer = require("node:buffer");
8
- var _isSvg = _interopRequireDefault(require("is-svg"));
9
- var _svgo = require("svgo");
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
- const imageminSvgo = options => async buffer => {
12
- options = {
13
- multipass: true,
14
- ...options
15
- };
16
- if (!(0, _isSvg.default)(buffer)) {
17
- return Promise.resolve(buffer);
18
- }
19
- if (_nodeBuffer.Buffer.isBuffer(buffer)) {
20
- buffer = buffer.toString();
21
- }
22
- const {
23
- data
24
- } = (0, _svgo.optimize)(buffer, options);
25
- return _nodeBuffer.Buffer.from(data);
26
- };
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _nodeBuffer = require("node:buffer");
8
+ var _isSvg = _interopRequireDefault(require("is-svg"));
9
+ var _svgo = require("svgo");
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+ const imageminSvgo = options => async buffer => {
12
+ options = {
13
+ multipass: true,
14
+ ...options
15
+ };
16
+ if (!(0, _isSvg.default)(buffer)) {
17
+ return Promise.resolve(buffer);
18
+ }
19
+ if (_nodeBuffer.Buffer.isBuffer(buffer)) {
20
+ buffer = buffer.toString();
21
+ }
22
+ const {
23
+ data
24
+ } = (0, _svgo.optimize)(buffer, options);
25
+ return _nodeBuffer.Buffer.from(data);
26
+ };
27
27
  var _default = exports.default = imageminSvgo;
@@ -1,12 +1,12 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = isJpg;
7
- function isJpg(buffer) {
8
- if (!buffer || buffer.length < 3) {
9
- return false;
10
- }
11
- return buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = isJpg;
7
+ function isJpg(buffer) {
8
+ if (!buffer || buffer.length < 3) {
9
+ return false;
10
+ }
11
+ return buffer[0] === 255 && buffer[1] === 216 && buffer[2] === 255;
12
12
  }
@@ -1,49 +1,49 @@
1
- 'use strict';
2
-
3
- const blacklist = [
4
- // # All
5
- '^npm-debug\\.log$',
6
- // Error log for npm
7
- '^\\..*\\.swp$',
8
- // Swap file for vim state
9
-
10
- // # macOS
11
- '^\\.DS_Store$',
12
- // Stores custom folder attributes
13
- '^\\.AppleDouble$',
14
- // Stores additional file resources
15
- '^\\.LSOverride$',
16
- // Contains the absolute path to the app to be used
17
- '^Icon\\r$',
18
- // Custom Finder icon: http://superuser.com/questions/298785/icon-file-on-os-x-desktop
19
- '^\\._.*',
20
- // Thumbnail
21
- '^\\.Spotlight-V100(?:$|\\/)',
22
- // Directory that might appear on external disk
23
- '\\.Trashes',
24
- // File that might appear on external disk
25
- '^__MACOSX$',
26
- // Resource fork
27
-
28
- // # Linux
29
- '~$',
30
- // Backup file
31
-
32
- // # Windows
33
- '^Thumbs\\.db$',
34
- // Image file cache
35
- '^ehthumbs\\.db$',
36
- // Folder config file
37
- '^Desktop\\.ini$',
38
- // Stores custom folder attributes
39
- '@eaDir$' // Synology Diskstation "hidden" folder where the server stores thumbnails
40
- ];
41
- exports.re = () => {
42
- throw new Error('`junk.re` was renamed to `junk.regex`');
43
- };
44
- exports.regex = new RegExp(blacklist.join('|'));
45
- exports.is = filename => exports.regex.test(filename);
46
- exports.not = filename => !exports.is(filename);
47
-
48
- // TODO: Remove this for the next major release
1
+ 'use strict';
2
+
3
+ const blacklist = [
4
+ // # All
5
+ '^npm-debug\\.log$',
6
+ // Error log for npm
7
+ '^\\..*\\.swp$',
8
+ // Swap file for vim state
9
+
10
+ // # macOS
11
+ '^\\.DS_Store$',
12
+ // Stores custom folder attributes
13
+ '^\\.AppleDouble$',
14
+ // Stores additional file resources
15
+ '^\\.LSOverride$',
16
+ // Contains the absolute path to the app to be used
17
+ '^Icon\\r$',
18
+ // Custom Finder icon: http://superuser.com/questions/298785/icon-file-on-os-x-desktop
19
+ '^\\._.*',
20
+ // Thumbnail
21
+ '^\\.Spotlight-V100(?:$|\\/)',
22
+ // Directory that might appear on external disk
23
+ '\\.Trashes',
24
+ // File that might appear on external disk
25
+ '^__MACOSX$',
26
+ // Resource fork
27
+
28
+ // # Linux
29
+ '~$',
30
+ // Backup file
31
+
32
+ // # Windows
33
+ '^Thumbs\\.db$',
34
+ // Image file cache
35
+ '^ehthumbs\\.db$',
36
+ // Folder config file
37
+ '^Desktop\\.ini$',
38
+ // Stores custom folder attributes
39
+ '@eaDir$' // Synology Diskstation "hidden" folder where the server stores thumbnails
40
+ ];
41
+ exports.re = () => {
42
+ throw new Error('`junk.re` was renamed to `junk.regex`');
43
+ };
44
+ exports.regex = new RegExp(blacklist.join('|'));
45
+ exports.is = filename => exports.regex.test(filename);
46
+ exports.not = filename => !exports.is(filename);
47
+
48
+ // TODO: Remove this for the next major release
49
49
  exports.default = module.exports;
@@ -1,9 +1,9 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _index = _interopRequireDefault(require("./lib/index.js"));
8
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _index = _interopRequireDefault(require("./lib/index.js"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
9
  var _default = exports.default = _index.default.path();
@@ -1,18 +1,18 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- require("core-js/modules/web.dom-collections.iterator.js");
8
- require("core-js/modules/web.url.js");
9
- require("core-js/modules/web.url-search-params.js");
10
- var _nodeFs = _interopRequireDefault(require("node:fs"));
11
- var _nodeProcess = _interopRequireDefault(require("node:process"));
12
- var _nodeUrl = require("node:url");
13
- var _binWrapper = _interopRequireDefault(require("bin-wrapper"));
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- const pkg = JSON.parse(_nodeFs.default.readFileSync(new URL('../package.json', require('url').pathToFileURL(__filename).toString())));
16
- const url = "https://raw.githubusercontent.com/imagemin/mozjpeg-bin/v".concat(pkg.version, "/vendor/");
17
- const binWrapper = new _binWrapper.default().src("".concat(url, "macos/cjpeg"), 'darwin').src("".concat(url, "linux/cjpeg"), 'linux').src("".concat(url, "win/cjpeg.exe"), 'win32').dest((0, _nodeUrl.fileURLToPath)(new URL('../vendor', require('url').pathToFileURL(__filename).toString()))).use(_nodeProcess.default.platform === 'win32' ? 'cjpeg.exe' : 'cjpeg');
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
+ require("core-js/modules/web.url.js");
9
+ require("core-js/modules/web.url-search-params.js");
10
+ var _nodeFs = _interopRequireDefault(require("node:fs"));
11
+ var _nodeProcess = _interopRequireDefault(require("node:process"));
12
+ var _nodeUrl = require("node:url");
13
+ var _binWrapper = _interopRequireDefault(require("bin-wrapper"));
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ const pkg = JSON.parse(_nodeFs.default.readFileSync(new URL('../package.json', require('url').pathToFileURL(__filename).toString())));
16
+ const url = "https://raw.githubusercontent.com/imagemin/mozjpeg-bin/v".concat(pkg.version, "/vendor/");
17
+ const binWrapper = new _binWrapper.default().src("".concat(url, "macos/cjpeg"), 'darwin').src("".concat(url, "linux/cjpeg"), 'linux').src("".concat(url, "win/cjpeg.exe"), 'win32').dest((0, _nodeUrl.fileURLToPath)(new URL('../vendor', require('url').pathToFileURL(__filename).toString()))).use(_nodeProcess.default.platform === 'win32' ? 'cjpeg.exe' : 'cjpeg');
18
18
  var _default = exports.default = binWrapper;
@@ -1,50 +1,49 @@
1
- {
2
- "name": "mozjpeg",
3
- "version": "8.0.0",
4
- "description": "mozjpeg wrapper that makes it seamlessly available as a local dependency",
5
- "license": "MIT",
6
- "repository": "imagemin/mozjpeg-bin",
7
- "type": "module",
8
- "exports": "./index.js",
9
- "bin": "cli.js",
10
- "engines": {
11
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
12
- },
13
- "scripts": {
14
- "postinstall": "node lib/install.js",
15
- "test": "xo && ava --timeout=120s",
16
- "build-linux": "docker build --tag imagemin/mozjpeg docker && docker run --rm --volume $(pwd)/vendor/linux:/src/out imagemin/mozjpeg cp cjpeg /src/out"
17
- },
18
- "files": [
19
- "index.js",
20
- "cli.js",
21
- "lib",
22
- "vendor/source"
23
- ],
24
- "keywords": [
25
- "imagemin",
26
- "jpeg",
27
- "jpg",
28
- "img",
29
- "image",
30
- "compress",
31
- "minify",
32
- "mozjpeg",
33
- "optimize"
34
- ],
35
- "dependencies": {
36
- "bin-build": "^3.0.0",
37
- "bin-wrapper": "^4.0.0"
38
- },
39
- "devDependencies": {
40
- "ava": "^3.8.0",
41
- "bin-check": "^4.1.0",
42
- "compare-size": "^3.0.0",
43
- "execa": "^5.1.1",
44
- "tempy": "^2.0.0",
45
- "xo": "^0.45.0"
46
- },
47
- "ava": {
48
- "serial": true
49
- }
50
- }
1
+ {
2
+ "name": "mozjpeg",
3
+ "version": "8.0.0",
4
+ "description": "mozjpeg wrapper that makes it seamlessly available as a local dependency",
5
+ "license": "MIT",
6
+ "repository": "imagemin/mozjpeg-bin",
7
+ "exports": "./index.js",
8
+ "bin": "cli.js",
9
+ "engines": {
10
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
11
+ },
12
+ "scripts": {
13
+ "postinstall": "node lib/install.js",
14
+ "test": "xo && ava --timeout=120s",
15
+ "build-linux": "docker build --tag imagemin/mozjpeg docker && docker run --rm --volume $(pwd)/vendor/linux:/src/out imagemin/mozjpeg cp cjpeg /src/out"
16
+ },
17
+ "files": [
18
+ "index.js",
19
+ "cli.js",
20
+ "lib",
21
+ "vendor/source"
22
+ ],
23
+ "keywords": [
24
+ "imagemin",
25
+ "jpeg",
26
+ "jpg",
27
+ "img",
28
+ "image",
29
+ "compress",
30
+ "minify",
31
+ "mozjpeg",
32
+ "optimize"
33
+ ],
34
+ "dependencies": {
35
+ "bin-build": "^3.0.0",
36
+ "bin-wrapper": "^4.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "ava": "^3.8.0",
40
+ "bin-check": "^4.1.0",
41
+ "compare-size": "^3.0.0",
42
+ "execa": "^5.1.1",
43
+ "tempy": "^2.0.0",
44
+ "xo": "^0.45.0"
45
+ },
46
+ "ava": {
47
+ "serial": true
48
+ }
49
+ }
Binary file
@@ -1,26 +1,22 @@
1
- async function exportPPipe () {
2
- "use strict";
3
-
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = pPipe;
8
- require("core-js/modules/web.dom-collections.iterator.js");
9
- function pPipe() {
10
- for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) {
11
- functions[_key] = arguments[_key];
12
- }
13
- if (functions.length === 0) {
14
- throw new Error('Expected at least one argument');
15
- }
16
- return async input => {
17
- let currentValue = input;
18
- for (const function_ of functions) {
19
- currentValue = await function_(currentValue); // eslint-disable-line no-await-in-loop
20
- }
21
- return currentValue;
22
- };
23
- }
24
- }
25
-
26
- exportPPipe()
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = pPipe;
7
+ require("core-js/modules/web.dom-collections.iterator.js");
8
+ function pPipe() {
9
+ for (var _len = arguments.length, functions = new Array(_len), _key = 0; _key < _len; _key++) {
10
+ functions[_key] = arguments[_key];
11
+ }
12
+ if (functions.length === 0) {
13
+ throw new Error('Expected at least one argument');
14
+ }
15
+ return async input => {
16
+ let currentValue = input;
17
+ for (const function_ of functions) {
18
+ currentValue = await function_(currentValue); // eslint-disable-line no-await-in-loop
19
+ }
20
+ return currentValue;
21
+ };
22
+ }
@@ -1,32 +1,32 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = plur;
7
- require("core-js/modules/es.string.replace.js");
8
- var _irregularPlurals = _interopRequireDefault(require("irregular-plurals"));
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- function plur(word, plural, count) {
11
- if (typeof plural === 'number') {
12
- count = plural;
13
- }
14
- if (_irregularPlurals.default.has(word.toLowerCase())) {
15
- plural = _irregularPlurals.default.get(word.toLowerCase());
16
- const firstLetter = word.charAt(0);
17
- const isFirstLetterUpperCase = firstLetter === firstLetter.toUpperCase();
18
- if (isFirstLetterUpperCase) {
19
- plural = firstLetter + plural.slice(1);
20
- }
21
- const isWholeWordUpperCase = word === word.toUpperCase();
22
- if (isWholeWordUpperCase) {
23
- plural = plural.toUpperCase();
24
- }
25
- } else if (typeof plural !== 'string') {
26
- plural = (word.replace(/(?:s|x|z|ch|sh)$/i, '$&e').replace(/([^aeiou])y$/i, '$1ie') + 's').replace(/i?e?s$/i, match => {
27
- const isTailLowerCase = word.slice(-1) === word.slice(-1).toLowerCase();
28
- return isTailLowerCase ? match.toLowerCase() : match.toUpperCase();
29
- });
30
- }
31
- return Math.abs(count) === 1 ? word : plural;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = plur;
7
+ require("core-js/modules/es.string.replace.js");
8
+ var _irregularPlurals = _interopRequireDefault(require("irregular-plurals"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function plur(word, plural, count) {
11
+ if (typeof plural === 'number') {
12
+ count = plural;
13
+ }
14
+ if (_irregularPlurals.default.has(word.toLowerCase())) {
15
+ plural = _irregularPlurals.default.get(word.toLowerCase());
16
+ const firstLetter = word.charAt(0);
17
+ const isFirstLetterUpperCase = firstLetter === firstLetter.toUpperCase();
18
+ if (isFirstLetterUpperCase) {
19
+ plural = firstLetter + plural.slice(1);
20
+ }
21
+ const isWholeWordUpperCase = word === word.toUpperCase();
22
+ if (isWholeWordUpperCase) {
23
+ plural = plural.toUpperCase();
24
+ }
25
+ } else if (typeof plural !== 'string') {
26
+ plural = (word.replace(/(?:s|x|z|ch|sh)$/i, '$&e').replace(/([^aeiou])y$/i, '$1ie') + 's').replace(/i?e?s$/i, match => {
27
+ const isTailLowerCase = word.slice(-1) === word.slice(-1).toLowerCase();
28
+ return isTailLowerCase ? match.toLowerCase() : match.toUpperCase();
29
+ });
30
+ }
31
+ return Math.abs(count) === 1 ? word : plural;
32
32
  }
@@ -1,71 +1,71 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = prettyBytes;
7
- const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
8
- const BIBYTE_UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
9
- const BIT_UNITS = ['b', 'kbit', 'Mbit', 'Gbit', 'Tbit', 'Pbit', 'Ebit', 'Zbit', 'Ybit'];
10
- const BIBIT_UNITS = ['b', 'kibit', 'Mibit', 'Gibit', 'Tibit', 'Pibit', 'Eibit', 'Zibit', 'Yibit'];
11
-
12
- /*
13
- Formats the given number using `Number#toLocaleString`.
14
- - If locale is a string, the value is expected to be a locale-key (for example: `de`).
15
- - If locale is true, the system default locale is used for translation.
16
- - If no value for locale is specified, the number is returned unmodified.
17
- */
18
- const toLocaleString = (number, locale, options) => {
19
- let result = number;
20
- if (typeof locale === 'string' || Array.isArray(locale)) {
21
- result = number.toLocaleString(locale, options);
22
- } else if (locale === true || options !== undefined) {
23
- result = number.toLocaleString(undefined, options);
24
- }
25
- return result;
26
- };
27
- function prettyBytes(number, options) {
28
- if (!Number.isFinite(number)) {
29
- throw new TypeError("Expected a finite number, got ".concat(typeof number, ": ").concat(number));
30
- }
31
- options = {
32
- bits: false,
33
- binary: false,
34
- space: true,
35
- ...options
36
- };
37
- const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
38
- const separator = options.space ? ' ' : '';
39
- if (options.signed && number === 0) {
40
- return " 0".concat(separator).concat(UNITS[0]);
41
- }
42
- const isNegative = number < 0;
43
- const prefix = isNegative ? '-' : options.signed ? '+' : '';
44
- if (isNegative) {
45
- number = -number;
46
- }
47
- let localeOptions;
48
- if (options.minimumFractionDigits !== undefined) {
49
- localeOptions = {
50
- minimumFractionDigits: options.minimumFractionDigits
51
- };
52
- }
53
- if (options.maximumFractionDigits !== undefined) {
54
- localeOptions = {
55
- maximumFractionDigits: options.maximumFractionDigits,
56
- ...localeOptions
57
- };
58
- }
59
- if (number < 1) {
60
- const numberString = toLocaleString(number, options.locale, localeOptions);
61
- return prefix + numberString + separator + UNITS[0];
62
- }
63
- const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
64
- number /= (options.binary ? 1024 : 1000) ** exponent;
65
- if (!localeOptions) {
66
- number = number.toPrecision(3);
67
- }
68
- const numberString = toLocaleString(Number(number), options.locale, localeOptions);
69
- const unit = UNITS[exponent];
70
- return prefix + numberString + separator + unit;
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = prettyBytes;
7
+ const BYTE_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
8
+ const BIBYTE_UNITS = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
9
+ const BIT_UNITS = ['b', 'kbit', 'Mbit', 'Gbit', 'Tbit', 'Pbit', 'Ebit', 'Zbit', 'Ybit'];
10
+ const BIBIT_UNITS = ['b', 'kibit', 'Mibit', 'Gibit', 'Tibit', 'Pibit', 'Eibit', 'Zibit', 'Yibit'];
11
+
12
+ /*
13
+ Formats the given number using `Number#toLocaleString`.
14
+ - If locale is a string, the value is expected to be a locale-key (for example: `de`).
15
+ - If locale is true, the system default locale is used for translation.
16
+ - If no value for locale is specified, the number is returned unmodified.
17
+ */
18
+ const toLocaleString = (number, locale, options) => {
19
+ let result = number;
20
+ if (typeof locale === 'string' || Array.isArray(locale)) {
21
+ result = number.toLocaleString(locale, options);
22
+ } else if (locale === true || options !== undefined) {
23
+ result = number.toLocaleString(undefined, options);
24
+ }
25
+ return result;
26
+ };
27
+ function prettyBytes(number, options) {
28
+ if (!Number.isFinite(number)) {
29
+ throw new TypeError("Expected a finite number, got ".concat(typeof number, ": ").concat(number));
30
+ }
31
+ options = {
32
+ bits: false,
33
+ binary: false,
34
+ space: true,
35
+ ...options
36
+ };
37
+ const UNITS = options.bits ? options.binary ? BIBIT_UNITS : BIT_UNITS : options.binary ? BIBYTE_UNITS : BYTE_UNITS;
38
+ const separator = options.space ? ' ' : '';
39
+ if (options.signed && number === 0) {
40
+ return " 0".concat(separator).concat(UNITS[0]);
41
+ }
42
+ const isNegative = number < 0;
43
+ const prefix = isNegative ? '-' : options.signed ? '+' : '';
44
+ if (isNegative) {
45
+ number = -number;
46
+ }
47
+ let localeOptions;
48
+ if (options.minimumFractionDigits !== undefined) {
49
+ localeOptions = {
50
+ minimumFractionDigits: options.minimumFractionDigits
51
+ };
52
+ }
53
+ if (options.maximumFractionDigits !== undefined) {
54
+ localeOptions = {
55
+ maximumFractionDigits: options.maximumFractionDigits,
56
+ ...localeOptions
57
+ };
58
+ }
59
+ if (number < 1) {
60
+ const numberString = toLocaleString(number, options.locale, localeOptions);
61
+ return prefix + numberString + separator + UNITS[0];
62
+ }
63
+ const exponent = Math.min(Math.floor(options.binary ? Math.log(number) / Math.log(1024) : Math.log10(number) / 3), UNITS.length - 1);
64
+ number /= (options.binary ? 1024 : 1000) ** exponent;
65
+ if (!localeOptions) {
66
+ number = number.toPrecision(3);
67
+ }
68
+ const numberString = toLocaleString(Number(number), options.locale, localeOptions);
69
+ const unit = UNITS[exponent];
70
+ return prefix + numberString + separator + unit;
71
71
  }
@@ -1,12 +1,12 @@
1
- 'use strict';
2
-
3
- require("core-js/modules/es.string.replace.js");
4
- module.exports = path => {
5
- const isExtendedLengthPath = /^\\\\\?\\/.test(path);
6
- const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex
7
-
8
- if (isExtendedLengthPath || hasNonAscii) {
9
- return path;
10
- }
11
- return path.replace(/\\/g, '/');
1
+ 'use strict';
2
+
3
+ require("core-js/modules/es.string.replace.js");
4
+ module.exports = path => {
5
+ const isExtendedLengthPath = /^\\\\\?\\/.test(path);
6
+ const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex
7
+
8
+ if (isExtendedLengthPath || hasNonAscii) {
9
+ return path;
10
+ }
11
+ return path.replace(/\\/g, '/');
12
12
  };