@bccampus/utils 0.2.3 → 0.3.0

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 (163) hide show
  1. package/README.md +3 -8
  2. package/dist/array/chunk.cjs +13 -5
  3. package/dist/array/chunk.d.ts +7 -0
  4. package/dist/array/chunk.js +14 -7
  5. package/dist/array/chunk.test.d.ts +1 -0
  6. package/dist/date/iso-date-time/constants.cjs +27 -0
  7. package/dist/date/iso-date-time/constants.d.ts +9 -0
  8. package/dist/date/iso-date-time/constants.js +19 -0
  9. package/dist/date/iso-date-time/index.cjs +8 -0
  10. package/dist/date/iso-date-time/index.d.ts +5 -0
  11. package/dist/date/iso-date-time/index.js +3 -0
  12. package/dist/date/iso-date-time/iso-date-time.arithmetic.test.d.ts +1 -0
  13. package/dist/date/iso-date-time/iso-date-time.cjs +232 -0
  14. package/dist/date/{iso-date-time.d.ts → iso-date-time/iso-date-time.d.ts} +3 -32
  15. package/dist/date/iso-date-time/iso-date-time.format.test.d.ts +1 -0
  16. package/dist/date/iso-date-time/iso-date-time.js +231 -0
  17. package/dist/date/iso-date-time/iso-date-time.test.d.ts +1 -0
  18. package/dist/date/iso-date-time/types.cjs +0 -0
  19. package/dist/date/iso-date-time/types.d.ts +25 -0
  20. package/dist/date/iso-date-time/types.js +0 -0
  21. package/dist/duration/add-durations.cjs +5 -8
  22. package/dist/duration/add-durations.js +5 -9
  23. package/dist/duration/duration.test.d.ts +1 -0
  24. package/dist/duration/is-duration.cjs +4 -3
  25. package/dist/duration/is-duration.js +5 -5
  26. package/dist/duration/to-number.cjs +11 -10
  27. package/dist/duration/to-number.d.ts +1 -1
  28. package/dist/duration/to-number.js +11 -11
  29. package/dist/format/formatter.cjs +31 -31
  30. package/dist/format/formatter.d.ts +4 -4
  31. package/dist/format/formatter.js +32 -37
  32. package/dist/format/formatter.test.d.ts +1 -0
  33. package/dist/format/stringfy.test.d.ts +1 -0
  34. package/dist/format/stringify.cjs +34 -40
  35. package/dist/format/stringify.d.ts +1 -1
  36. package/dist/format/stringify.js +35 -42
  37. package/dist/format/template.cjs +25 -32
  38. package/dist/format/template.d.ts +3 -3
  39. package/dist/format/template.js +24 -33
  40. package/dist/format/template.test.d.ts +1 -0
  41. package/dist/index.cjs +0 -1
  42. package/dist/index.js +0 -1
  43. package/dist/object/get.cjs +5 -5
  44. package/dist/object/get.d.ts +1 -1
  45. package/dist/object/get.js +6 -7
  46. package/dist/object/get.test.d.ts +1 -0
  47. package/dist/object/is-object.cjs +5 -2
  48. package/dist/object/is-object.d.ts +1 -1
  49. package/dist/object/is-object.js +6 -4
  50. package/dist/object/is-object.test.d.ts +1 -0
  51. package/dist/object/omit.cjs +14 -16
  52. package/dist/object/omit.d.ts +1 -1
  53. package/dist/object/omit.js +15 -18
  54. package/dist/object/omit.test.d.ts +1 -0
  55. package/dist/object/pick.cjs +10 -9
  56. package/dist/object/pick.d.ts +1 -1
  57. package/dist/object/pick.js +9 -9
  58. package/dist/object/pick.test.d.ts +1 -0
  59. package/dist/object/set.cjs +13 -12
  60. package/dist/object/set.d.ts +1 -1
  61. package/dist/object/set.js +14 -14
  62. package/dist/object/set.test.d.ts +1 -0
  63. package/dist/path/file-url-to-path.cjs +10 -6
  64. package/dist/path/file-url-to-path.js +11 -8
  65. package/dist/path/file-url-to-path.test.d.ts +1 -0
  66. package/dist/path/normalize.cjs +41 -27
  67. package/dist/path/normalize.d.ts +8 -2
  68. package/dist/path/normalize.js +41 -28
  69. package/dist/path/normalize.test.d.ts +1 -0
  70. package/dist/set/difference.cjs +5 -6
  71. package/dist/set/difference.d.ts +1 -1
  72. package/dist/set/difference.js +6 -8
  73. package/dist/set/intersection.cjs +6 -9
  74. package/dist/set/intersection.d.ts +1 -1
  75. package/dist/set/intersection.js +7 -11
  76. package/dist/set/is-superset.cjs +5 -8
  77. package/dist/set/is-superset.d.ts +1 -1
  78. package/dist/set/is-superset.js +6 -10
  79. package/dist/set/set.test.d.ts +1 -0
  80. package/dist/set/symmetric-difference.cjs +6 -10
  81. package/dist/set/symmetric-difference.d.ts +1 -1
  82. package/dist/set/symmetric-difference.js +7 -12
  83. package/dist/set/union.cjs +5 -6
  84. package/dist/set/union.d.ts +1 -1
  85. package/dist/set/union.js +6 -8
  86. package/dist/string/capitalize.cjs +5 -2
  87. package/dist/string/capitalize.d.ts +1 -1
  88. package/dist/string/capitalize.js +6 -4
  89. package/dist/string/capitalize.test.d.ts +1 -0
  90. package/dist/string/normalize.cjs +7 -2
  91. package/dist/string/normalize.js +8 -4
  92. package/dist/string/normalize.test.d.ts +1 -0
  93. package/dist/string/pluralize/index.cjs +5 -4
  94. package/dist/string/pluralize/index.js +4 -5
  95. package/dist/string/pluralize/pluralize.cjs +162 -208
  96. package/dist/string/pluralize/pluralize.d.ts +4 -8
  97. package/dist/string/pluralize/pluralize.js +158 -205
  98. package/dist/string/pluralize/pluralize.test.d.ts +1 -0
  99. package/dist/string/pluralize/rules/index.cjs +8 -9
  100. package/dist/string/pluralize/rules/index.js +1 -6
  101. package/dist/string/pluralize/rules/irregular.cjs +55 -59
  102. package/dist/string/pluralize/rules/irregular.js +56 -61
  103. package/dist/string/pluralize/rules/pluralization.cjs +28 -36
  104. package/dist/string/pluralize/rules/pluralization.js +29 -38
  105. package/dist/string/pluralize/rules/singularization.cjs +27 -44
  106. package/dist/string/pluralize/rules/singularization.js +28 -46
  107. package/dist/string/pluralize/rules/uncountable.cjs +104 -110
  108. package/dist/string/pluralize/rules/uncountable.js +105 -112
  109. package/dist/string/pluralize/types.cjs +0 -1
  110. package/dist/string/pluralize/types.js +0 -1
  111. package/dist/string/slugify/index.cjs +2129 -2246
  112. package/dist/string/slugify/index.js +2130 -2248
  113. package/dist/string/slugify/slugify.test.d.ts +1 -0
  114. package/dist/string/strip-html-tags.cjs +4 -3
  115. package/dist/string/strip-html-tags.js +5 -5
  116. package/dist/string/strip-html-tags.test.d.ts +1 -0
  117. package/dist/string/to-int.cjs +14 -6
  118. package/dist/string/to-int.js +15 -8
  119. package/dist/string/to-int.test.d.ts +1 -0
  120. package/dist/string/to-sentence-case.cjs +6 -6
  121. package/dist/string/to-sentence-case.d.ts +1 -1
  122. package/dist/string/to-sentence-case.js +7 -8
  123. package/dist/string/to-sentence-case.test.d.ts +1 -0
  124. package/dist/string/trim.cjs +8 -7
  125. package/dist/string/trim.js +9 -9
  126. package/dist/string/trim.test.d.ts +1 -0
  127. package/dist/string/truncate.cjs +16 -15
  128. package/dist/string/truncate.js +17 -17
  129. package/dist/string/truncate.test.d.ts +1 -0
  130. package/dist/value/is-empty.cjs +30 -12
  131. package/dist/value/is-empty.d.ts +1 -1
  132. package/dist/value/is-empty.js +31 -14
  133. package/dist/value/value.test.d.ts +1 -0
  134. package/package.json +180 -69
  135. package/dist/array/index.cjs +0 -4
  136. package/dist/array/index.d.ts +0 -2
  137. package/dist/array/index.js +0 -4
  138. package/dist/date/index.cjs +0 -8
  139. package/dist/date/index.d.ts +0 -3
  140. package/dist/date/index.js +0 -8
  141. package/dist/date/iso-date-time.cjs +0 -256
  142. package/dist/date/iso-date-time.js +0 -256
  143. package/dist/duration/index.cjs +0 -8
  144. package/dist/duration/index.d.ts +0 -4
  145. package/dist/duration/index.js +0 -8
  146. package/dist/format/index.cjs +0 -13
  147. package/dist/format/index.d.ts +0 -5
  148. package/dist/format/index.js +0 -13
  149. package/dist/object/index.cjs +0 -12
  150. package/dist/object/index.d.ts +0 -6
  151. package/dist/object/index.js +0 -12
  152. package/dist/path/index.cjs +0 -6
  153. package/dist/path/index.d.ts +0 -4
  154. package/dist/path/index.js +0 -6
  155. package/dist/set/index.cjs +0 -12
  156. package/dist/set/index.d.ts +0 -6
  157. package/dist/set/index.js +0 -12
  158. package/dist/string/index.cjs +0 -14
  159. package/dist/string/index.d.ts +0 -8
  160. package/dist/string/index.js +0 -14
  161. package/dist/value/index.cjs +0 -4
  162. package/dist/value/index.d.ts +0 -2
  163. package/dist/value/index.js +0 -4
package/dist/index.js CHANGED
@@ -1 +0,0 @@
1
-
@@ -1,7 +1,7 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const get = (object, prop) => prop.split(".").reduce(
4
- (reducedObject, key) => reducedObject && key in reducedObject ? reducedObject[key] : void 0,
5
- object
6
- );
2
+ //#region src/object/get.ts
3
+ function get(object, prop) {
4
+ return prop.split(".").reduce((reducedObject, key) => reducedObject && typeof reducedObject === "object" && key in reducedObject ? reducedObject[key] : void 0, object);
5
+ }
6
+ //#endregion
7
7
  exports.get = get;
@@ -1 +1 @@
1
- export declare const get: <T extends object>(object: T, prop: string) => any;
1
+ export declare function get<T extends object>(object: T, prop: string): unknown;
@@ -1,7 +1,6 @@
1
- const get = (object, prop) => prop.split(".").reduce(
2
- (reducedObject, key) => reducedObject && key in reducedObject ? reducedObject[key] : void 0,
3
- object
4
- );
5
- export {
6
- get
7
- };
1
+ //#region src/object/get.ts
2
+ function get(object, prop) {
3
+ return prop.split(".").reduce((reducedObject, key) => reducedObject && typeof reducedObject === "object" && key in reducedObject ? reducedObject[key] : void 0, object);
4
+ }
5
+ //#endregion
6
+ export { get };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,7 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const isObject = (object) => typeof object === "object" && !Array.isArray(object) && object !== null;
2
+ //#region src/object/is-object.ts
3
+ function isObject(object) {
4
+ return typeof object === "object" && !Array.isArray(object) && object !== null;
5
+ }
6
+ //#endregion
4
7
  exports.isObject = isObject;
@@ -1 +1 @@
1
- export declare const isObject: (object: unknown) => boolean;
1
+ export declare function isObject(object: unknown): boolean;
@@ -1,4 +1,6 @@
1
- const isObject = (object) => typeof object === "object" && !Array.isArray(object) && object !== null;
2
- export {
3
- isObject
4
- };
1
+ //#region src/object/is-object.ts
2
+ function isObject(object) {
3
+ return typeof object === "object" && !Array.isArray(object) && object !== null;
4
+ }
5
+ //#endregion
6
+ export { isObject };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,18 +1,16 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const omit = (object, props) => {
4
- const result = { ...object };
5
- props.forEach((prop) => {
6
- const propChunks = prop.split(".");
7
- const lastChunk = propChunks.pop();
8
- if (lastChunk) {
9
- const ref = propChunks.reduce(
10
- (reducedObject, key) => reducedObject && key in reducedObject ? reducedObject[key] : void 0,
11
- result
12
- );
13
- if (ref && lastChunk in ref) delete ref[lastChunk];
14
- }
15
- });
16
- return result;
17
- };
2
+ //#region src/object/omit.ts
3
+ function omit(object, props) {
4
+ const result = { ...object };
5
+ props.forEach((prop) => {
6
+ const propChunks = prop.split(".");
7
+ const lastChunk = propChunks.pop();
8
+ if (lastChunk) {
9
+ const ref = propChunks.reduce((reducedObject, key) => reducedObject && typeof reducedObject === "object" && key in reducedObject ? reducedObject[key] : void 0, result);
10
+ if (ref && typeof ref === "object" && lastChunk in ref) delete ref[lastChunk];
11
+ }
12
+ });
13
+ return result;
14
+ }
15
+ //#endregion
18
16
  exports.omit = omit;
@@ -1 +1 @@
1
- export declare const omit: <T extends object>(object: T, props: string[]) => Partial<T>;
1
+ export declare function omit<T extends object>(object: T, props: string[]): object;
@@ -1,18 +1,15 @@
1
- const omit = (object, props) => {
2
- const result = { ...object };
3
- props.forEach((prop) => {
4
- const propChunks = prop.split(".");
5
- const lastChunk = propChunks.pop();
6
- if (lastChunk) {
7
- const ref = propChunks.reduce(
8
- (reducedObject, key) => reducedObject && key in reducedObject ? reducedObject[key] : void 0,
9
- result
10
- );
11
- if (ref && lastChunk in ref) delete ref[lastChunk];
12
- }
13
- });
14
- return result;
15
- };
16
- export {
17
- omit
18
- };
1
+ //#region src/object/omit.ts
2
+ function omit(object, props) {
3
+ const result = { ...object };
4
+ props.forEach((prop) => {
5
+ const propChunks = prop.split(".");
6
+ const lastChunk = propChunks.pop();
7
+ if (lastChunk) {
8
+ const ref = propChunks.reduce((reducedObject, key) => reducedObject && typeof reducedObject === "object" && key in reducedObject ? reducedObject[key] : void 0, result);
9
+ if (ref && typeof ref === "object" && lastChunk in ref) delete ref[lastChunk];
10
+ }
11
+ });
12
+ return result;
13
+ }
14
+ //#endregion
15
+ export { omit };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,11 +1,12 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const object_get = require("./get.cjs");
4
- const object_set = require("./set.cjs");
5
- const pick = (object, props) => {
6
- return props.reduce((result, key) => {
7
- object_set.set(result, key, object_get.get(object, key));
8
- return result;
9
- }, {});
10
- };
2
+ const require_object_get = require("./get.cjs");
3
+ const require_object_set = require("./set.cjs");
4
+ //#region src/object/pick.ts
5
+ function pick(object, props) {
6
+ return props.reduce((result, key) => {
7
+ require_object_set.set(result, key, require_object_get.get(object, key));
8
+ return result;
9
+ }, {});
10
+ }
11
+ //#endregion
11
12
  exports.pick = pick;
@@ -1 +1 @@
1
- export declare const pick: <T extends object>(object: T, props: string[]) => Partial<T>;
1
+ export declare function pick<T extends object>(object: T, props: string[]): object;
@@ -1,11 +1,11 @@
1
1
  import { get } from "./get.js";
2
2
  import { set } from "./set.js";
3
- const pick = (object, props) => {
4
- return props.reduce((result, key) => {
5
- set(result, key, get(object, key));
6
- return result;
7
- }, {});
8
- };
9
- export {
10
- pick
11
- };
3
+ //#region src/object/pick.ts
4
+ function pick(object, props) {
5
+ return props.reduce((result, key) => {
6
+ set(result, key, get(object, key));
7
+ return result;
8
+ }, {});
9
+ }
10
+ //#endregion
11
+ export { pick };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,14 +1,15 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const set = (object, prop, value) => {
4
- const propChunks = prop.split(".");
5
- const lastChunk = propChunks.pop();
6
- if (!lastChunk) return object;
7
- const ref = propChunks.reduce((reducedObject, key) => {
8
- if (reducedObject[key] === void 0) reducedObject[key] = {};
9
- return reducedObject[key];
10
- }, object);
11
- ref[lastChunk] = value;
12
- return object;
13
- };
2
+ //#region src/object/set.ts
3
+ function set(object, prop, value) {
4
+ const propChunks = prop.split(".");
5
+ const lastChunk = propChunks.pop();
6
+ if (!lastChunk) return object;
7
+ const ref = propChunks.reduce((reducedObject, key) => {
8
+ if (reducedObject[key] === void 0) reducedObject[key] = {};
9
+ return reducedObject[key];
10
+ }, object);
11
+ ref[lastChunk] = value;
12
+ return object;
13
+ }
14
+ //#endregion
14
15
  exports.set = set;
@@ -1 +1 @@
1
- export declare const set: <T extends object, V>(object: T, prop: string, value: V) => T;
1
+ export declare function set<T extends object, V>(object: T, prop: string, value: V): object;
@@ -1,14 +1,14 @@
1
- const set = (object, prop, value) => {
2
- const propChunks = prop.split(".");
3
- const lastChunk = propChunks.pop();
4
- if (!lastChunk) return object;
5
- const ref = propChunks.reduce((reducedObject, key) => {
6
- if (reducedObject[key] === void 0) reducedObject[key] = {};
7
- return reducedObject[key];
8
- }, object);
9
- ref[lastChunk] = value;
10
- return object;
11
- };
12
- export {
13
- set
14
- };
1
+ //#region src/object/set.ts
2
+ function set(object, prop, value) {
3
+ const propChunks = prop.split(".");
4
+ const lastChunk = propChunks.pop();
5
+ if (!lastChunk) return object;
6
+ const ref = propChunks.reduce((reducedObject, key) => {
7
+ if (reducedObject[key] === void 0) reducedObject[key] = {};
8
+ return reducedObject[key];
9
+ }, object);
10
+ ref[lastChunk] = value;
11
+ return object;
12
+ }
13
+ //#endregion
14
+ export { set };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,14 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const windowsDriveRegExp = /^\/[a-zA-Z1-9_-]+:\//;
2
+ //#region src/path/file-url-to-path.ts
3
+ var windowsDriveRegExp = /^\/[a-z1-9_-]+:\//i;
4
+ /**
5
+ * Browser compatible version of `node:url.fileURLToPath`
6
+ */
4
7
  function fileURLToPath(fileUrl) {
5
- const url = new URL(fileUrl);
6
- let path = decodeURIComponent(url.pathname);
7
- if (windowsDriveRegExp.test(path)) path = path.slice(1);
8
- return path;
8
+ const url = new URL(fileUrl);
9
+ let path = decodeURIComponent(url.pathname);
10
+ if (windowsDriveRegExp.test(path)) path = path.slice(1);
11
+ return path;
9
12
  }
13
+ //#endregion
10
14
  exports.fileURLToPath = fileURLToPath;
@@ -1,10 +1,13 @@
1
- const windowsDriveRegExp = /^\/[a-zA-Z1-9_-]+:\//;
1
+ //#region src/path/file-url-to-path.ts
2
+ var windowsDriveRegExp = /^\/[a-z1-9_-]+:\//i;
3
+ /**
4
+ * Browser compatible version of `node:url.fileURLToPath`
5
+ */
2
6
  function fileURLToPath(fileUrl) {
3
- const url = new URL(fileUrl);
4
- let path = decodeURIComponent(url.pathname);
5
- if (windowsDriveRegExp.test(path)) path = path.slice(1);
6
- return path;
7
+ const url = new URL(fileUrl);
8
+ let path = decodeURIComponent(url.pathname);
9
+ if (windowsDriveRegExp.test(path)) path = path.slice(1);
10
+ return path;
7
11
  }
8
- export {
9
- fileURLToPath
10
- };
12
+ //#endregion
13
+ export { fileURLToPath };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,32 +1,46 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const path_fileUrlToPath = require("./file-url-to-path.cjs");
4
- const defaultOptions = {
5
- leadingSlash: "always",
6
- trailingSlash: "never"
2
+ const require_path_file_url_to_path = require("./file-url-to-path.cjs");
3
+ //#region src/path/normalize.ts
4
+ var defaultOptions = {
5
+ leadingSlash: "always",
6
+ trailingSlash: "never",
7
+ separator: "/"
7
8
  };
8
- const windowsPathSepRegExp = /[\\]+/g;
9
- const unixPathSepRegExp = /[/]+/g;
10
- const windowsDriveRegExp = /^[a-zA-Z1-9_-]+:\//;
11
- const fileProtocolRegExp = /^file:\/\//;
12
- const leadingSlashRegExp = /^\//g;
13
- const trailingSlashRegExp = /\/$/g;
9
+ var windowsPathSepRegExp = /\\+/g;
10
+ var unixPathSepRegExp = /\/+/g;
11
+ var windowsDriveRegExp = /^[a-z1-9_-]+:\//i;
12
+ var fileProtocolRegExp = /^file:\/\//;
13
+ var leadingSlashRegExp = /^\//g;
14
+ var trailingSlashRegExp = /\/$/g;
15
+ /**
16
+ * Clears and converts the provided path to a Posix filepath
17
+ *
18
+ * By default, adds a leading slash and removes the trailing
19
+ *
20
+ * @example
21
+ * ```
22
+ * normalize("src/test/"); //returns: /src/test
23
+ * normalize("C:\\Users\\test\\folder\\"); //returns: C:/Users/test/folder
24
+ * normalize("file:///C:/Users/test/folder/file.ts"); //returns: C:/Users/test/folder/file.ts
25
+ * ```
26
+ */
14
27
  function normalize(path, options) {
15
- const conf = { ...defaultOptions, ...options };
16
- const sep = "\\";
17
- let normalPath = path.trim();
18
- if (fileProtocolRegExp.test(normalPath))
19
- normalPath = path_fileUrlToPath.fileURLToPath(normalPath);
20
- normalPath = normalPath.replace(windowsPathSepRegExp, sep).replace(unixPathSepRegExp, sep);
21
- if (conf.leadingSlash !== "as-is") {
22
- normalPath = normalPath.replace(leadingSlashRegExp, "");
23
- if (conf.leadingSlash === "always" && !windowsDriveRegExp.test(normalPath))
24
- normalPath = `${sep}${normalPath}`;
25
- }
26
- if (conf.trailingSlash !== "as-is") {
27
- normalPath = normalPath.replace(trailingSlashRegExp, "");
28
- if (conf.trailingSlash === "always") normalPath = `${normalPath}${sep}`;
29
- }
30
- return normalPath;
28
+ const conf = {
29
+ ...defaultOptions,
30
+ ...options
31
+ };
32
+ let normalPath = path.trim();
33
+ if (fileProtocolRegExp.test(normalPath)) normalPath = require_path_file_url_to_path.fileURLToPath(normalPath);
34
+ normalPath = normalPath.replace(windowsPathSepRegExp, conf.separator).replace(unixPathSepRegExp, conf.separator);
35
+ if (conf.leadingSlash !== "as-is") {
36
+ normalPath = normalPath.replace(leadingSlashRegExp, "");
37
+ if (conf.leadingSlash === "always" && !windowsDriveRegExp.test(normalPath)) normalPath = `${conf.separator}${normalPath}`;
38
+ }
39
+ if (conf.trailingSlash !== "as-is") {
40
+ normalPath = normalPath.replace(trailingSlashRegExp, "");
41
+ if (conf.trailingSlash === "always") normalPath = `${normalPath}${conf.separator}`;
42
+ }
43
+ return normalPath;
31
44
  }
45
+ //#endregion
32
46
  exports.normalize = normalize;
@@ -6,7 +6,7 @@ export interface NormalizeOptions {
6
6
  *
7
7
  * @default "always"
8
8
  */
9
- leadingSlash?: "always" | "never" | "as-is";
9
+ leadingSlash?: 'always' | 'never' | 'as-is';
10
10
  /**
11
11
  * - `always`: ensure trailing slash exists
12
12
  * - `never`: ensure trailing slash does not exist
@@ -14,7 +14,13 @@ export interface NormalizeOptions {
14
14
  *
15
15
  * @default "never"
16
16
  */
17
- trailingSlash?: "always" | "never" | "as-is";
17
+ trailingSlash?: 'always' | 'never' | 'as-is';
18
+ /**
19
+ * Path separator
20
+ *
21
+ * @default "/"
22
+ */
23
+ separator?: string;
18
24
  }
19
25
  /**
20
26
  * Clears and converts the provided path to a Posix filepath
@@ -1,32 +1,45 @@
1
1
  import { fileURLToPath } from "./file-url-to-path.js";
2
- const defaultOptions = {
3
- leadingSlash: "always",
4
- trailingSlash: "never"
2
+ //#region src/path/normalize.ts
3
+ var defaultOptions = {
4
+ leadingSlash: "always",
5
+ trailingSlash: "never",
6
+ separator: "/"
5
7
  };
6
- const windowsPathSepRegExp = /[\\]+/g;
7
- const unixPathSepRegExp = /[/]+/g;
8
- const windowsDriveRegExp = /^[a-zA-Z1-9_-]+:\//;
9
- const fileProtocolRegExp = /^file:\/\//;
10
- const leadingSlashRegExp = /^\//g;
11
- const trailingSlashRegExp = /\/$/g;
8
+ var windowsPathSepRegExp = /\\+/g;
9
+ var unixPathSepRegExp = /\/+/g;
10
+ var windowsDriveRegExp = /^[a-z1-9_-]+:\//i;
11
+ var fileProtocolRegExp = /^file:\/\//;
12
+ var leadingSlashRegExp = /^\//g;
13
+ var trailingSlashRegExp = /\/$/g;
14
+ /**
15
+ * Clears and converts the provided path to a Posix filepath
16
+ *
17
+ * By default, adds a leading slash and removes the trailing
18
+ *
19
+ * @example
20
+ * ```
21
+ * normalize("src/test/"); //returns: /src/test
22
+ * normalize("C:\\Users\\test\\folder\\"); //returns: C:/Users/test/folder
23
+ * normalize("file:///C:/Users/test/folder/file.ts"); //returns: C:/Users/test/folder/file.ts
24
+ * ```
25
+ */
12
26
  function normalize(path, options) {
13
- const conf = { ...defaultOptions, ...options };
14
- const sep = "\\";
15
- let normalPath = path.trim();
16
- if (fileProtocolRegExp.test(normalPath))
17
- normalPath = fileURLToPath(normalPath);
18
- normalPath = normalPath.replace(windowsPathSepRegExp, sep).replace(unixPathSepRegExp, sep);
19
- if (conf.leadingSlash !== "as-is") {
20
- normalPath = normalPath.replace(leadingSlashRegExp, "");
21
- if (conf.leadingSlash === "always" && !windowsDriveRegExp.test(normalPath))
22
- normalPath = `${sep}${normalPath}`;
23
- }
24
- if (conf.trailingSlash !== "as-is") {
25
- normalPath = normalPath.replace(trailingSlashRegExp, "");
26
- if (conf.trailingSlash === "always") normalPath = `${normalPath}${sep}`;
27
- }
28
- return normalPath;
27
+ const conf = {
28
+ ...defaultOptions,
29
+ ...options
30
+ };
31
+ let normalPath = path.trim();
32
+ if (fileProtocolRegExp.test(normalPath)) normalPath = fileURLToPath(normalPath);
33
+ normalPath = normalPath.replace(windowsPathSepRegExp, conf.separator).replace(unixPathSepRegExp, conf.separator);
34
+ if (conf.leadingSlash !== "as-is") {
35
+ normalPath = normalPath.replace(leadingSlashRegExp, "");
36
+ if (conf.leadingSlash === "always" && !windowsDriveRegExp.test(normalPath)) normalPath = `${conf.separator}${normalPath}`;
37
+ }
38
+ if (conf.trailingSlash !== "as-is") {
39
+ normalPath = normalPath.replace(trailingSlashRegExp, "");
40
+ if (conf.trailingSlash === "always") normalPath = `${normalPath}${conf.separator}`;
41
+ }
42
+ return normalPath;
29
43
  }
30
- export {
31
- normalize
32
- };
44
+ //#endregion
45
+ export { normalize };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,9 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/set/difference.ts
3
3
  function difference(setA, setB) {
4
- const _difference = new Set(setA);
5
- for (const elem of setB) {
6
- _difference.delete(elem);
7
- }
8
- return _difference;
4
+ const _difference = new Set(setA);
5
+ for (const elem of setB) _difference.delete(elem);
6
+ return _difference;
9
7
  }
8
+ //#endregion
10
9
  exports.difference = difference;
@@ -1 +1 @@
1
- export declare function difference(setA: Iterable<any>, setB: Iterable<any>): Set<any>;
1
+ export declare function difference(setA: Iterable<unknown>, setB: Iterable<unknown>): Set<unknown>;
@@ -1,10 +1,8 @@
1
+ //#region src/set/difference.ts
1
2
  function difference(setA, setB) {
2
- const _difference = new Set(setA);
3
- for (const elem of setB) {
4
- _difference.delete(elem);
5
- }
6
- return _difference;
3
+ const _difference = new Set(setA);
4
+ for (const elem of setB) _difference.delete(elem);
5
+ return _difference;
7
6
  }
8
- export {
9
- difference
10
- };
7
+ //#endregion
8
+ export { difference };
@@ -1,13 +1,10 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/set/intersection.ts
3
3
  function intersection(setA, setB) {
4
- const _setA = setA instanceof Set ? setA : new Set(setA);
5
- const _intersection = /* @__PURE__ */ new Set();
6
- for (const elem of setB) {
7
- if (_setA.has(elem)) {
8
- _intersection.add(elem);
9
- }
10
- }
11
- return _intersection;
4
+ const _setA = setA instanceof Set ? setA : new Set(setA);
5
+ const _intersection = /* @__PURE__ */ new Set();
6
+ for (const elem of setB) if (_setA.has(elem)) _intersection.add(elem);
7
+ return _intersection;
12
8
  }
9
+ //#endregion
13
10
  exports.intersection = intersection;
@@ -1 +1 @@
1
- export declare function intersection(setA: Iterable<any>, setB: Iterable<any>): Set<unknown>;
1
+ export declare function intersection(setA: Iterable<unknown>, setB: Iterable<unknown>): Set<unknown>;
@@ -1,13 +1,9 @@
1
+ //#region src/set/intersection.ts
1
2
  function intersection(setA, setB) {
2
- const _setA = setA instanceof Set ? setA : new Set(setA);
3
- const _intersection = /* @__PURE__ */ new Set();
4
- for (const elem of setB) {
5
- if (_setA.has(elem)) {
6
- _intersection.add(elem);
7
- }
8
- }
9
- return _intersection;
3
+ const _setA = setA instanceof Set ? setA : new Set(setA);
4
+ const _intersection = /* @__PURE__ */ new Set();
5
+ for (const elem of setB) if (_setA.has(elem)) _intersection.add(elem);
6
+ return _intersection;
10
7
  }
11
- export {
12
- intersection
13
- };
8
+ //#endregion
9
+ export { intersection };
@@ -1,12 +1,9 @@
1
- "use strict";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/set/is-superset.ts
3
3
  function isSuperset(set, subset) {
4
- const _set = set instanceof Set ? set : new Set(set);
5
- for (const elem of subset) {
6
- if (!_set.has(elem)) {
7
- return false;
8
- }
9
- }
10
- return true;
4
+ const _set = set instanceof Set ? set : new Set(set);
5
+ for (const elem of subset) if (!_set.has(elem)) return false;
6
+ return true;
11
7
  }
8
+ //#endregion
12
9
  exports.isSuperset = isSuperset;
@@ -1 +1 @@
1
- export declare function isSuperset(set: Iterable<any>, subset: Iterable<any>): boolean;
1
+ export declare function isSuperset(set: Iterable<unknown>, subset: Iterable<unknown>): boolean;
@@ -1,12 +1,8 @@
1
+ //#region src/set/is-superset.ts
1
2
  function isSuperset(set, subset) {
2
- const _set = set instanceof Set ? set : new Set(set);
3
- for (const elem of subset) {
4
- if (!_set.has(elem)) {
5
- return false;
6
- }
7
- }
8
- return true;
3
+ const _set = set instanceof Set ? set : new Set(set);
4
+ for (const elem of subset) if (!_set.has(elem)) return false;
5
+ return true;
9
6
  }
10
- export {
11
- isSuperset
12
- };
7
+ //#endregion
8
+ export { isSuperset };
@@ -0,0 +1 @@
1
+ export {};