@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.
- package/README.md +3 -8
- package/dist/array/chunk.cjs +13 -5
- package/dist/array/chunk.d.ts +7 -0
- package/dist/array/chunk.js +14 -7
- package/dist/array/chunk.test.d.ts +1 -0
- package/dist/date/iso-date-time/constants.cjs +27 -0
- package/dist/date/iso-date-time/constants.d.ts +9 -0
- package/dist/date/iso-date-time/constants.js +19 -0
- package/dist/date/iso-date-time/index.cjs +8 -0
- package/dist/date/iso-date-time/index.d.ts +5 -0
- package/dist/date/iso-date-time/index.js +3 -0
- package/dist/date/iso-date-time/iso-date-time.arithmetic.test.d.ts +1 -0
- package/dist/date/iso-date-time/iso-date-time.cjs +232 -0
- package/dist/date/{iso-date-time.d.ts → iso-date-time/iso-date-time.d.ts} +3 -32
- package/dist/date/iso-date-time/iso-date-time.format.test.d.ts +1 -0
- package/dist/date/iso-date-time/iso-date-time.js +231 -0
- package/dist/date/iso-date-time/iso-date-time.test.d.ts +1 -0
- package/dist/date/iso-date-time/types.cjs +0 -0
- package/dist/date/iso-date-time/types.d.ts +25 -0
- package/dist/date/iso-date-time/types.js +0 -0
- package/dist/duration/add-durations.cjs +5 -8
- package/dist/duration/add-durations.js +5 -9
- package/dist/duration/duration.test.d.ts +1 -0
- package/dist/duration/is-duration.cjs +4 -3
- package/dist/duration/is-duration.js +5 -5
- package/dist/duration/to-number.cjs +11 -10
- package/dist/duration/to-number.d.ts +1 -1
- package/dist/duration/to-number.js +11 -11
- package/dist/format/formatter.cjs +31 -31
- package/dist/format/formatter.d.ts +4 -4
- package/dist/format/formatter.js +32 -37
- package/dist/format/formatter.test.d.ts +1 -0
- package/dist/format/stringfy.test.d.ts +1 -0
- package/dist/format/stringify.cjs +34 -40
- package/dist/format/stringify.d.ts +1 -1
- package/dist/format/stringify.js +35 -42
- package/dist/format/template.cjs +25 -32
- package/dist/format/template.d.ts +3 -3
- package/dist/format/template.js +24 -33
- package/dist/format/template.test.d.ts +1 -0
- package/dist/index.cjs +0 -1
- package/dist/index.js +0 -1
- package/dist/object/get.cjs +5 -5
- package/dist/object/get.d.ts +1 -1
- package/dist/object/get.js +6 -7
- package/dist/object/get.test.d.ts +1 -0
- package/dist/object/is-object.cjs +5 -2
- package/dist/object/is-object.d.ts +1 -1
- package/dist/object/is-object.js +6 -4
- package/dist/object/is-object.test.d.ts +1 -0
- package/dist/object/omit.cjs +14 -16
- package/dist/object/omit.d.ts +1 -1
- package/dist/object/omit.js +15 -18
- package/dist/object/omit.test.d.ts +1 -0
- package/dist/object/pick.cjs +10 -9
- package/dist/object/pick.d.ts +1 -1
- package/dist/object/pick.js +9 -9
- package/dist/object/pick.test.d.ts +1 -0
- package/dist/object/set.cjs +13 -12
- package/dist/object/set.d.ts +1 -1
- package/dist/object/set.js +14 -14
- package/dist/object/set.test.d.ts +1 -0
- package/dist/path/file-url-to-path.cjs +10 -6
- package/dist/path/file-url-to-path.js +11 -8
- package/dist/path/file-url-to-path.test.d.ts +1 -0
- package/dist/path/normalize.cjs +41 -27
- package/dist/path/normalize.d.ts +8 -2
- package/dist/path/normalize.js +41 -28
- package/dist/path/normalize.test.d.ts +1 -0
- package/dist/set/difference.cjs +5 -6
- package/dist/set/difference.d.ts +1 -1
- package/dist/set/difference.js +6 -8
- package/dist/set/intersection.cjs +6 -9
- package/dist/set/intersection.d.ts +1 -1
- package/dist/set/intersection.js +7 -11
- package/dist/set/is-superset.cjs +5 -8
- package/dist/set/is-superset.d.ts +1 -1
- package/dist/set/is-superset.js +6 -10
- package/dist/set/set.test.d.ts +1 -0
- package/dist/set/symmetric-difference.cjs +6 -10
- package/dist/set/symmetric-difference.d.ts +1 -1
- package/dist/set/symmetric-difference.js +7 -12
- package/dist/set/union.cjs +5 -6
- package/dist/set/union.d.ts +1 -1
- package/dist/set/union.js +6 -8
- package/dist/string/capitalize.cjs +5 -2
- package/dist/string/capitalize.d.ts +1 -1
- package/dist/string/capitalize.js +6 -4
- package/dist/string/capitalize.test.d.ts +1 -0
- package/dist/string/normalize.cjs +7 -2
- package/dist/string/normalize.js +8 -4
- package/dist/string/normalize.test.d.ts +1 -0
- package/dist/string/pluralize/index.cjs +5 -4
- package/dist/string/pluralize/index.js +4 -5
- package/dist/string/pluralize/pluralize.cjs +162 -208
- package/dist/string/pluralize/pluralize.d.ts +4 -8
- package/dist/string/pluralize/pluralize.js +158 -205
- package/dist/string/pluralize/pluralize.test.d.ts +1 -0
- package/dist/string/pluralize/rules/index.cjs +8 -9
- package/dist/string/pluralize/rules/index.js +1 -6
- package/dist/string/pluralize/rules/irregular.cjs +55 -59
- package/dist/string/pluralize/rules/irregular.js +56 -61
- package/dist/string/pluralize/rules/pluralization.cjs +28 -36
- package/dist/string/pluralize/rules/pluralization.js +29 -38
- package/dist/string/pluralize/rules/singularization.cjs +27 -44
- package/dist/string/pluralize/rules/singularization.js +28 -46
- package/dist/string/pluralize/rules/uncountable.cjs +104 -110
- package/dist/string/pluralize/rules/uncountable.js +105 -112
- package/dist/string/pluralize/types.cjs +0 -1
- package/dist/string/pluralize/types.js +0 -1
- package/dist/string/slugify/index.cjs +2129 -2246
- package/dist/string/slugify/index.js +2130 -2248
- package/dist/string/slugify/slugify.test.d.ts +1 -0
- package/dist/string/strip-html-tags.cjs +4 -3
- package/dist/string/strip-html-tags.js +5 -5
- package/dist/string/strip-html-tags.test.d.ts +1 -0
- package/dist/string/to-int.cjs +14 -6
- package/dist/string/to-int.js +15 -8
- package/dist/string/to-int.test.d.ts +1 -0
- package/dist/string/to-sentence-case.cjs +6 -6
- package/dist/string/to-sentence-case.d.ts +1 -1
- package/dist/string/to-sentence-case.js +7 -8
- package/dist/string/to-sentence-case.test.d.ts +1 -0
- package/dist/string/trim.cjs +8 -7
- package/dist/string/trim.js +9 -9
- package/dist/string/trim.test.d.ts +1 -0
- package/dist/string/truncate.cjs +16 -15
- package/dist/string/truncate.js +17 -17
- package/dist/string/truncate.test.d.ts +1 -0
- package/dist/value/is-empty.cjs +30 -12
- package/dist/value/is-empty.d.ts +1 -1
- package/dist/value/is-empty.js +31 -14
- package/dist/value/value.test.d.ts +1 -0
- package/package.json +180 -69
- package/dist/array/index.cjs +0 -4
- package/dist/array/index.d.ts +0 -2
- package/dist/array/index.js +0 -4
- package/dist/date/index.cjs +0 -8
- package/dist/date/index.d.ts +0 -3
- package/dist/date/index.js +0 -8
- package/dist/date/iso-date-time.cjs +0 -256
- package/dist/date/iso-date-time.js +0 -256
- package/dist/duration/index.cjs +0 -8
- package/dist/duration/index.d.ts +0 -4
- package/dist/duration/index.js +0 -8
- package/dist/format/index.cjs +0 -13
- package/dist/format/index.d.ts +0 -5
- package/dist/format/index.js +0 -13
- package/dist/object/index.cjs +0 -12
- package/dist/object/index.d.ts +0 -6
- package/dist/object/index.js +0 -12
- package/dist/path/index.cjs +0 -6
- package/dist/path/index.d.ts +0 -4
- package/dist/path/index.js +0 -6
- package/dist/set/index.cjs +0 -12
- package/dist/set/index.d.ts +0 -6
- package/dist/set/index.js +0 -12
- package/dist/string/index.cjs +0 -14
- package/dist/string/index.d.ts +0 -8
- package/dist/string/index.js +0 -14
- package/dist/value/index.cjs +0 -4
- package/dist/value/index.d.ts +0 -2
- package/dist/value/index.js +0 -4
package/dist/index.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/object/get.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
package/dist/object/get.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function get<T extends object>(object: T, prop: string): unknown;
|
package/dist/object/get.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
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
|
|
1
|
+
export declare function isObject(object: unknown): boolean;
|
package/dist/object/is-object.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 {};
|
package/dist/object/omit.cjs
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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;
|
package/dist/object/omit.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function omit<T extends object>(object: T, props: string[]): object;
|
package/dist/object/omit.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 {};
|
package/dist/object/pick.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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;
|
package/dist/object/pick.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function pick<T extends object>(object: T, props: string[]): object;
|
package/dist/object/pick.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { get } from "./get.js";
|
|
2
2
|
import { set } from "./set.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
|
|
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 {};
|
package/dist/object/set.cjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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;
|
package/dist/object/set.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare function set<T extends object, V>(object: T, prop: string, value: V): object;
|
package/dist/object/set.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { fileURLToPath };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/path/normalize.cjs
CHANGED
|
@@ -1,32 +1,46 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
package/dist/path/normalize.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface NormalizeOptions {
|
|
|
6
6
|
*
|
|
7
7
|
* @default "always"
|
|
8
8
|
*/
|
|
9
|
-
leadingSlash?:
|
|
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?:
|
|
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
|
package/dist/path/normalize.js
CHANGED
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import { fileURLToPath } from "./file-url-to-path.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
//#region src/path/normalize.ts
|
|
3
|
+
var defaultOptions = {
|
|
4
|
+
leadingSlash: "always",
|
|
5
|
+
trailingSlash: "never",
|
|
6
|
+
separator: "/"
|
|
5
7
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
44
|
+
//#endregion
|
|
45
|
+
export { normalize };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/set/difference.cjs
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
package/dist/set/difference.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function difference(setA: Iterable<
|
|
1
|
+
export declare function difference(setA: Iterable<unknown>, setB: Iterable<unknown>): Set<unknown>;
|
package/dist/set/difference.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
//#region src/set/difference.ts
|
|
1
2
|
function difference(setA, setB) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
9
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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<
|
|
1
|
+
export declare function intersection(setA: Iterable<unknown>, setB: Iterable<unknown>): Set<unknown>;
|
package/dist/set/intersection.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
+
//#region src/set/intersection.ts
|
|
1
2
|
function intersection(setA, setB) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { intersection };
|
package/dist/set/is-superset.cjs
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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<
|
|
1
|
+
export declare function isSuperset(set: Iterable<unknown>, subset: Iterable<unknown>): boolean;
|
package/dist/set/is-superset.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
+
//#region src/set/is-superset.ts
|
|
1
2
|
function isSuperset(set, subset) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
7
|
+
//#endregion
|
|
8
|
+
export { isSuperset };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|