@sourceaxis/shared 0.1.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 (48) hide show
  1. package/README.md +26 -0
  2. package/dist/cjs/assertions/index.js +43 -0
  3. package/dist/cjs/assertions/index.js.map +1 -0
  4. package/dist/cjs/async/index.js +69 -0
  5. package/dist/cjs/async/index.js.map +1 -0
  6. package/dist/cjs/constants/index.js +12 -0
  7. package/dist/cjs/constants/index.js.map +1 -0
  8. package/dist/cjs/guards/index.js +63 -0
  9. package/dist/cjs/guards/index.js.map +1 -0
  10. package/dist/cjs/index.js +25 -0
  11. package/dist/cjs/index.js.map +1 -0
  12. package/dist/cjs/objects/index.js +49 -0
  13. package/dist/cjs/objects/index.js.map +1 -0
  14. package/dist/cjs/package.json +1 -0
  15. package/dist/cjs/paths/index.js +69 -0
  16. package/dist/cjs/paths/index.js.map +1 -0
  17. package/dist/cjs/strings/index.js +41 -0
  18. package/dist/cjs/strings/index.js.map +1 -0
  19. package/dist/cjs/types/index.js +3 -0
  20. package/dist/cjs/types/index.js.map +1 -0
  21. package/dist/esm/assertions/index.d.ts +25 -0
  22. package/dist/esm/assertions/index.d.ts.map +1 -0
  23. package/dist/esm/assertions/index.js +36 -0
  24. package/dist/esm/async/index.d.ts +30 -0
  25. package/dist/esm/async/index.d.ts.map +1 -0
  26. package/dist/esm/async/index.js +63 -0
  27. package/dist/esm/constants/index.d.ts +9 -0
  28. package/dist/esm/constants/index.d.ts.map +1 -0
  29. package/dist/esm/constants/index.js +8 -0
  30. package/dist/esm/guards/index.d.ts +33 -0
  31. package/dist/esm/guards/index.d.ts.map +1 -0
  32. package/dist/esm/guards/index.js +52 -0
  33. package/dist/esm/index.d.ts +9 -0
  34. package/dist/esm/index.d.ts.map +1 -0
  35. package/dist/esm/index.js +8 -0
  36. package/dist/esm/objects/index.d.ts +20 -0
  37. package/dist/esm/objects/index.d.ts.map +1 -0
  38. package/dist/esm/objects/index.js +42 -0
  39. package/dist/esm/paths/index.d.ts +21 -0
  40. package/dist/esm/paths/index.d.ts.map +1 -0
  41. package/dist/esm/paths/index.js +61 -0
  42. package/dist/esm/strings/index.d.ts +21 -0
  43. package/dist/esm/strings/index.d.ts.map +1 -0
  44. package/dist/esm/strings/index.js +33 -0
  45. package/dist/esm/types/index.d.ts +47 -0
  46. package/dist/esm/types/index.d.ts.map +1 -0
  47. package/dist/esm/types/index.js +1 -0
  48. package/package.json +99 -0
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @sourceaxis/shared
2
+
3
+ Shared implementation utilities for SourceAxis packages.
4
+
5
+ ## Responsibilities
6
+
7
+ - Provide small assertion, async, constant, guard, object, path, string, and type helpers.
8
+ - Avoid provider-specific behavior.
9
+ - Keep common implementation utilities out of public runtime package internals.
10
+
11
+ ## Install
12
+
13
+ ```sh
14
+ pnpm add @sourceaxis/shared
15
+ ```
16
+
17
+ Applications usually do not need this package directly. Prefer the public APIs exposed by
18
+ `@sourceaxis/core`, provider packages, and `@sourceaxis/contracts`.
19
+
20
+ ## Usage
21
+
22
+ ```ts
23
+ import { deepFreeze } from "@sourceaxis/shared";
24
+
25
+ const value = deepFreeze({ stable: true });
26
+ ```
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assert = assert;
4
+ exports.assertDefined = assertDefined;
5
+ exports.assertNever = assertNever;
6
+ exports.unreachable = unreachable;
7
+ /**
8
+ * Asserts that a condition is truthy.
9
+ *
10
+ * @throws Error when the condition is false.
11
+ */
12
+ function assert(condition, message = "Assertion failed") {
13
+ if (!condition) {
14
+ throw new Error(message);
15
+ }
16
+ }
17
+ /**
18
+ * Asserts that a value is neither null nor undefined.
19
+ *
20
+ * @throws Error when the value is null or undefined.
21
+ */
22
+ function assertDefined(value, message = "Expected value to be defined") {
23
+ if (value === null || value === undefined) {
24
+ throw new Error(message);
25
+ }
26
+ }
27
+ /**
28
+ * Exhaustiveness helper for discriminated unions.
29
+ *
30
+ * @throws Error when reached at runtime.
31
+ */
32
+ function assertNever(value, message = "Unexpected value") {
33
+ throw new Error(`${message}: ${String(value)}`);
34
+ }
35
+ /**
36
+ * Marks code paths that should be unreachable.
37
+ *
38
+ * @throws Error whenever called.
39
+ */
40
+ function unreachable(message = "Unreachable code reached") {
41
+ throw new Error(message);
42
+ }
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAKA,wBAIC;AAOD,sCAOC;AAOD,kCAEC;AAOD,kCAEC;AAzCD;;;;GAIG;AACH,SAAgB,MAAM,CAAC,SAAkB,EAAE,OAAO,GAAG,kBAAkB;IACrE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAC3B,KAAQ,EACR,OAAO,GAAG,8BAA8B;IAExC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,KAAY,EAAE,OAAO,GAAG,kBAAkB;IACpE,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,SAAgB,WAAW,CAAC,OAAO,GAAG,0BAA0B;IAC9D,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deferred = deferred;
4
+ exports.raceAbort = raceAbort;
5
+ exports.sleep = sleep;
6
+ /**
7
+ * Creates a Promise with externally exposed resolve and reject callbacks.
8
+ */
9
+ function deferred() {
10
+ let resolve;
11
+ let reject;
12
+ const promise = new Promise((promiseResolve, promiseReject) => {
13
+ resolve = promiseResolve;
14
+ reject = promiseReject;
15
+ });
16
+ return { promise, resolve, reject };
17
+ }
18
+ /**
19
+ * Races a Promise-like operation against an AbortSignal.
20
+ */
21
+ function raceAbort(operation, signal) {
22
+ if (signal === undefined) {
23
+ return Promise.resolve(operation);
24
+ }
25
+ if (signal.aborted) {
26
+ return Promise.reject(createAbortError(signal));
27
+ }
28
+ return new Promise((resolve, reject) => {
29
+ const onAbort = () => {
30
+ reject(createAbortError(signal));
31
+ };
32
+ signal.addEventListener("abort", onAbort, { once: true });
33
+ Promise.resolve(operation).then((value) => {
34
+ signal.removeEventListener("abort", onAbort);
35
+ resolve(value);
36
+ }, (error) => {
37
+ signal.removeEventListener("abort", onAbort);
38
+ reject(error);
39
+ });
40
+ });
41
+ }
42
+ /**
43
+ * Resolves after the requested delay unless aborted.
44
+ */
45
+ function sleep(milliseconds, signal) {
46
+ if (signal === undefined) {
47
+ return new Promise((resolve) => {
48
+ setTimeout(resolve, milliseconds);
49
+ });
50
+ }
51
+ if (signal.aborted) {
52
+ return Promise.reject(createAbortError(signal));
53
+ }
54
+ return new Promise((resolve, reject) => {
55
+ const timeout = setTimeout(() => {
56
+ signal.removeEventListener("abort", onAbort);
57
+ resolve();
58
+ }, milliseconds);
59
+ const onAbort = () => {
60
+ clearTimeout(timeout);
61
+ reject(createAbortError(signal));
62
+ };
63
+ signal.addEventListener("abort", onAbort, { once: true });
64
+ });
65
+ }
66
+ function createAbortError(signal) {
67
+ return signal.reason instanceof Error ? signal.reason : new Error("Operation aborted");
68
+ }
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAuBA,4BAUC;AAKD,8BA2BC;AAKD,sBAwBC;AA1ED;;GAEG;AACH,SAAgB,QAAQ;IACt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C;AAED;;GAEG;AACH,SAAgB,KAAK,CAAC,YAAoB,EAAE,MAAoB;IAC9D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YACnC,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3C,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,YAAY,CAAC,CAAC;QAEjB,MAAM,OAAO,GAAG,GAAS,EAAE;YACzB,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAmB;IAC3C,OAAO,MAAM,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;AACzF,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EMPTY_OBJECT = exports.EMPTY_ARRAY = void 0;
4
+ /**
5
+ * Shared immutable empty array sentinel.
6
+ */
7
+ exports.EMPTY_ARRAY = Object.freeze([]);
8
+ /**
9
+ * Shared immutable empty object sentinel.
10
+ */
11
+ exports.EMPTY_OBJECT = Object.freeze({});
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,WAAW,GAAqB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE/D;;GAEG;AACU,QAAA,YAAY,GAAyC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isDefined = isDefined;
4
+ exports.isString = isString;
5
+ exports.isNumber = isNumber;
6
+ exports.isBoolean = isBoolean;
7
+ exports.isObject = isObject;
8
+ exports.isPlainObject = isPlainObject;
9
+ exports.isRecord = isRecord;
10
+ exports.isError = isError;
11
+ /**
12
+ * Returns true when a value is neither null nor undefined.
13
+ */
14
+ function isDefined(value) {
15
+ return value !== null && value !== undefined;
16
+ }
17
+ /**
18
+ * Returns true when a value is a string.
19
+ */
20
+ function isString(value) {
21
+ return typeof value === "string";
22
+ }
23
+ /**
24
+ * Returns true when a value is a finite number.
25
+ */
26
+ function isNumber(value) {
27
+ return typeof value === "number" && Number.isFinite(value);
28
+ }
29
+ /**
30
+ * Returns true when a value is a boolean.
31
+ */
32
+ function isBoolean(value) {
33
+ return typeof value === "boolean";
34
+ }
35
+ /**
36
+ * Returns true when a value is a non-null object.
37
+ */
38
+ function isObject(value) {
39
+ return typeof value === "object" && value !== null;
40
+ }
41
+ /**
42
+ * Returns true when a value is an object literal or a null-prototype object.
43
+ */
44
+ function isPlainObject(value) {
45
+ if (!isObject(value)) {
46
+ return false;
47
+ }
48
+ const prototype = Object.getPrototypeOf(value);
49
+ return prototype === Object.prototype || prototype === null;
50
+ }
51
+ /**
52
+ * Returns true when a value can be treated as an object record.
53
+ */
54
+ function isRecord(value) {
55
+ return isObject(value) && !Array.isArray(value);
56
+ }
57
+ /**
58
+ * Returns true when a value is an Error instance.
59
+ */
60
+ function isError(value) {
61
+ return value instanceof Error;
62
+ }
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAGA,8BAEC;AAKD,4BAEC;AAKD,4BAEC;AAKD,8BAEC;AAKD,4BAEC;AAKD,sCAOC;AAKD,4BAEC;AAKD,0BAEC;AA3DD;;GAEG;AACH,SAAgB,SAAS,CAAI,KAAQ;IACnC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,KAAc;IAC1C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,OAAO,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,SAAgB,QAAQ,CAAC,KAAc;IACrC,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,YAAY,KAAK,CAAC;AAChC,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./assertions/index.js"), exports);
18
+ __exportStar(require("./async/index.js"), exports);
19
+ __exportStar(require("./constants/index.js"), exports);
20
+ __exportStar(require("./guards/index.js"), exports);
21
+ __exportStar(require("./objects/index.js"), exports);
22
+ __exportStar(require("./paths/index.js"), exports);
23
+ __exportStar(require("./strings/index.js"), exports);
24
+ __exportStar(require("./types/index.js"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,mDAAiC;AACjC,uDAAqC;AACrC,oDAAkC;AAClC,qDAAmC;AACnC,mDAAiC;AACjC,qDAAmC;AACnC,mDAAiC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.deepFreeze = deepFreeze;
4
+ exports.hasOwn = hasOwn;
5
+ exports.isEmptyObject = isEmptyObject;
6
+ exports.mergeDefined = mergeDefined;
7
+ /**
8
+ * Recursively freezes an object and its object-valued own properties.
9
+ */
10
+ function deepFreeze(value) {
11
+ if (value === null || (typeof value !== "object" && typeof value !== "function")) {
12
+ return value;
13
+ }
14
+ for (const key of Reflect.ownKeys(value)) {
15
+ const child = value[key];
16
+ if (child !== null && (typeof child === "object" || typeof child === "function")) {
17
+ deepFreeze(child);
18
+ }
19
+ }
20
+ return Object.freeze(value);
21
+ }
22
+ /**
23
+ * Returns true when an object owns a property directly.
24
+ */
25
+ function hasOwn(object, key) {
26
+ return Object.prototype.hasOwnProperty.call(object, key);
27
+ }
28
+ /**
29
+ * Returns true when an object has no own string or symbol keys.
30
+ */
31
+ function isEmptyObject(object) {
32
+ return Reflect.ownKeys(object).length === 0;
33
+ }
34
+ /**
35
+ * Returns a shallow merge where undefined source values are ignored.
36
+ */
37
+ function mergeDefined(target, ...sources) {
38
+ const result = { ...target };
39
+ for (const source of sources) {
40
+ for (const key of Reflect.ownKeys(source)) {
41
+ const value = source[key];
42
+ if (value !== undefined) {
43
+ result[key] = value;
44
+ }
45
+ }
46
+ }
47
+ return result;
48
+ }
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAKA,gCAcC;AAKD,wBAKC;AAKD,sCAEC;AAKD,oCAiBC;AAxDD;;GAEG;AACH,SAAgB,UAAU,CAAI,KAAQ;IACpC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,EAAE,CAAC;QACjF,OAAO,KAAwB,CAAC;IAClC,CAAC;IAED,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzC,MAAM,KAAK,GAAI,KAAsC,CAAC,GAAG,CAAC,CAAC;QAE3D,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,EAAE,CAAC;YACjF,UAAU,CAAC,KAAK,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAoB,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,SAAgB,MAAM,CACpB,MAAS,EACT,GAAM;IAEN,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAc;IAC1C,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAC1B,MAAS,EACT,GAAG,OAAiE;IAEpE,MAAM,MAAM,GAAe,EAAE,GAAG,MAAM,EAAE,CAAC;IAEzC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAmB,EAAE,CAAC;YAC5D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YAE1B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACtB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.basename = basename;
4
+ exports.dirname = dirname;
5
+ exports.joinPath = joinPath;
6
+ exports.normalizePath = normalizePath;
7
+ exports.splitPath = splitPath;
8
+ /**
9
+ * Returns the final segment of a slash-delimited path.
10
+ */
11
+ function basename(path) {
12
+ const parts = splitPath(path);
13
+ return parts.at(-1) ?? "";
14
+ }
15
+ /**
16
+ * Returns every segment before the final segment of a slash-delimited path.
17
+ */
18
+ function dirname(path) {
19
+ const normalized = normalizePath(path);
20
+ const absolute = normalized.startsWith("/");
21
+ const parts = splitPath(normalized);
22
+ if (parts.length <= 1) {
23
+ return absolute ? "/" : "";
24
+ }
25
+ const directory = parts.slice(0, -1).join("/");
26
+ return absolute ? `/${directory}` : directory;
27
+ }
28
+ /**
29
+ * Joins path segments using forward slashes and normalizes the result.
30
+ */
31
+ function joinPath(...segments) {
32
+ return normalizePath(segments.filter((segment) => segment.length > 0).join("/"));
33
+ }
34
+ /**
35
+ * Normalizes a path to forward slashes, removes duplicate separators, and resolves dot segments.
36
+ */
37
+ function normalizePath(path) {
38
+ const slashPath = path.replace(/\\/g, "/");
39
+ const absolute = slashPath.startsWith("/");
40
+ const output = [];
41
+ for (const segment of slashPath.split("/")) {
42
+ if (segment === "" || segment === ".") {
43
+ continue;
44
+ }
45
+ if (segment === "..") {
46
+ if (output.length > 0 && output.at(-1) !== "..") {
47
+ output.pop();
48
+ }
49
+ else if (!absolute) {
50
+ output.push(segment);
51
+ }
52
+ continue;
53
+ }
54
+ output.push(segment);
55
+ }
56
+ const normalized = output.join("/");
57
+ if (absolute) {
58
+ return normalized.length > 0 ? `/${normalized}` : "/";
59
+ }
60
+ return normalized;
61
+ }
62
+ /**
63
+ * Splits a normalized path into non-empty segments.
64
+ */
65
+ function splitPath(path) {
66
+ const normalized = normalizePath(path);
67
+ return normalized.split("/").filter((segment) => segment.length > 0);
68
+ }
69
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAGA,4BAGC;AAKD,0BAWC;AAKD,4BAEC;AAKD,sCA8BC;AAKD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OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YACtC,SAAS;QACX,CAAC;QAED,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBAChD,MAAM,CAAC,GAAG,EAAE,CAAC;YACf,CAAC;iBAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACrB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;YAED,SAAS;QACX,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,UAAU,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACxD,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,IAAY;IACpC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACvE,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.capitalize = capitalize;
4
+ exports.isBlank = isBlank;
5
+ exports.trimStartSlash = trimStartSlash;
6
+ exports.trimEndSlash = trimEndSlash;
7
+ exports.normalizeLineEndings = normalizeLineEndings;
8
+ /**
9
+ * Uppercases the first character of a string.
10
+ */
11
+ function capitalize(value) {
12
+ if (value.length === 0) {
13
+ return value;
14
+ }
15
+ return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
16
+ }
17
+ /**
18
+ * Returns true when a string contains only whitespace.
19
+ */
20
+ function isBlank(value) {
21
+ return value.trim().length === 0;
22
+ }
23
+ /**
24
+ * Removes leading forward slashes.
25
+ */
26
+ function trimStartSlash(value) {
27
+ return value.replace(/^\/+/, "");
28
+ }
29
+ /**
30
+ * Removes trailing forward slashes.
31
+ */
32
+ function trimEndSlash(value) {
33
+ return value.replace(/\/+$/, "");
34
+ }
35
+ /**
36
+ * Converts CRLF and CR line endings to LF.
37
+ */
38
+ function normalizeLineEndings(value) {
39
+ return value.replace(/\r\n?/g, "\n");
40
+ }
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAGA,gCAMC;AAKD,0BAEC;AAKD,wCAEC;AAKD,oCAEC;AAKD,oDAEC;AArCD;;GAEG;AACH,SAAgB,UAAU,CAAC,KAAa;IACtC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAC7D,CAAC;AAED;;GAEG;AACH,SAAgB,OAAO,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,KAAa;IAC1C,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,KAAa;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Asserts that a condition is truthy.
3
+ *
4
+ * @throws Error when the condition is false.
5
+ */
6
+ export declare function assert(condition: unknown, message?: string): asserts condition;
7
+ /**
8
+ * Asserts that a value is neither null nor undefined.
9
+ *
10
+ * @throws Error when the value is null or undefined.
11
+ */
12
+ export declare function assertDefined<T>(value: T, message?: string): asserts value is NonNullable<T>;
13
+ /**
14
+ * Exhaustiveness helper for discriminated unions.
15
+ *
16
+ * @throws Error when reached at runtime.
17
+ */
18
+ export declare function assertNever(value: never, message?: string): never;
19
+ /**
20
+ * Marks code paths that should be unreachable.
21
+ *
22
+ * @throws Error whenever called.
23
+ */
24
+ export declare function unreachable(message?: string): never;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/assertions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,SAAqB,GAAG,OAAO,CAAC,SAAS,CAI1F;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,KAAK,EAAE,CAAC,EACR,OAAO,SAAiC,GACvC,OAAO,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAIjC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,SAAqB,GAAG,KAAK,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,SAA6B,GAAG,KAAK,CAEvE"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Asserts that a condition is truthy.
3
+ *
4
+ * @throws Error when the condition is false.
5
+ */
6
+ export function assert(condition, message = "Assertion failed") {
7
+ if (!condition) {
8
+ throw new Error(message);
9
+ }
10
+ }
11
+ /**
12
+ * Asserts that a value is neither null nor undefined.
13
+ *
14
+ * @throws Error when the value is null or undefined.
15
+ */
16
+ export function assertDefined(value, message = "Expected value to be defined") {
17
+ if (value === null || value === undefined) {
18
+ throw new Error(message);
19
+ }
20
+ }
21
+ /**
22
+ * Exhaustiveness helper for discriminated unions.
23
+ *
24
+ * @throws Error when reached at runtime.
25
+ */
26
+ export function assertNever(value, message = "Unexpected value") {
27
+ throw new Error(`${message}: ${String(value)}`);
28
+ }
29
+ /**
30
+ * Marks code paths that should be unreachable.
31
+ *
32
+ * @throws Error whenever called.
33
+ */
34
+ export function unreachable(message = "Unreachable code reached") {
35
+ throw new Error(message);
36
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A Promise with externally controlled resolution functions.
3
+ */
4
+ export interface Deferred<T> {
5
+ /**
6
+ * The Promise controlled by this deferred value.
7
+ */
8
+ readonly promise: Promise<T>;
9
+ /**
10
+ * Resolves the Promise.
11
+ */
12
+ readonly resolve: (value: T | PromiseLike<T>) => void;
13
+ /**
14
+ * Rejects the Promise.
15
+ */
16
+ readonly reject: (reason?: unknown) => void;
17
+ }
18
+ /**
19
+ * Creates a Promise with externally exposed resolve and reject callbacks.
20
+ */
21
+ export declare function deferred<T>(): Deferred<T>;
22
+ /**
23
+ * Races a Promise-like operation against an AbortSignal.
24
+ */
25
+ export declare function raceAbort<T>(operation: PromiseLike<T>, signal?: AbortSignal): Promise<T>;
26
+ /**
27
+ * Resolves after the requested delay unless aborted.
28
+ */
29
+ export declare function sleep(milliseconds: number, signal?: AbortSignal): Promise<void>;
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/async/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAE7B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAEtD;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAUzC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CA2BxF;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAwB/E"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Creates a Promise with externally exposed resolve and reject callbacks.
3
+ */
4
+ export function deferred() {
5
+ let resolve;
6
+ let reject;
7
+ const promise = new Promise((promiseResolve, promiseReject) => {
8
+ resolve = promiseResolve;
9
+ reject = promiseReject;
10
+ });
11
+ return { promise, resolve, reject };
12
+ }
13
+ /**
14
+ * Races a Promise-like operation against an AbortSignal.
15
+ */
16
+ export function raceAbort(operation, signal) {
17
+ if (signal === undefined) {
18
+ return Promise.resolve(operation);
19
+ }
20
+ if (signal.aborted) {
21
+ return Promise.reject(createAbortError(signal));
22
+ }
23
+ return new Promise((resolve, reject) => {
24
+ const onAbort = () => {
25
+ reject(createAbortError(signal));
26
+ };
27
+ signal.addEventListener("abort", onAbort, { once: true });
28
+ Promise.resolve(operation).then((value) => {
29
+ signal.removeEventListener("abort", onAbort);
30
+ resolve(value);
31
+ }, (error) => {
32
+ signal.removeEventListener("abort", onAbort);
33
+ reject(error);
34
+ });
35
+ });
36
+ }
37
+ /**
38
+ * Resolves after the requested delay unless aborted.
39
+ */
40
+ export function sleep(milliseconds, signal) {
41
+ if (signal === undefined) {
42
+ return new Promise((resolve) => {
43
+ setTimeout(resolve, milliseconds);
44
+ });
45
+ }
46
+ if (signal.aborted) {
47
+ return Promise.reject(createAbortError(signal));
48
+ }
49
+ return new Promise((resolve, reject) => {
50
+ const timeout = setTimeout(() => {
51
+ signal.removeEventListener("abort", onAbort);
52
+ resolve();
53
+ }, milliseconds);
54
+ const onAbort = () => {
55
+ clearTimeout(timeout);
56
+ reject(createAbortError(signal));
57
+ };
58
+ signal.addEventListener("abort", onAbort, { once: true });
59
+ });
60
+ }
61
+ function createAbortError(signal) {
62
+ return signal.reason instanceof Error ? signal.reason : new Error("Operation aborted");
63
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Shared immutable empty array sentinel.
3
+ */
4
+ export declare const EMPTY_ARRAY: readonly never[];
5
+ /**
6
+ * Shared immutable empty object sentinel.
7
+ */
8
+ export declare const EMPTY_OBJECT: Readonly<Record<PropertyKey, never>>;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/constants/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,SAAS,KAAK,EAAsB,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,CAAqB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Shared immutable empty array sentinel.
3
+ */
4
+ export const EMPTY_ARRAY = Object.freeze([]);
5
+ /**
6
+ * Shared immutable empty object sentinel.
7
+ */
8
+ export const EMPTY_OBJECT = Object.freeze({});
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Returns true when a value is neither null nor undefined.
3
+ */
4
+ export declare function isDefined<T>(value: T): value is NonNullable<T>;
5
+ /**
6
+ * Returns true when a value is a string.
7
+ */
8
+ export declare function isString(value: unknown): value is string;
9
+ /**
10
+ * Returns true when a value is a finite number.
11
+ */
12
+ export declare function isNumber(value: unknown): value is number;
13
+ /**
14
+ * Returns true when a value is a boolean.
15
+ */
16
+ export declare function isBoolean(value: unknown): value is boolean;
17
+ /**
18
+ * Returns true when a value is a non-null object.
19
+ */
20
+ export declare function isObject(value: unknown): value is object;
21
+ /**
22
+ * Returns true when a value is an object literal or a null-prototype object.
23
+ */
24
+ export declare function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
25
+ /**
26
+ * Returns true when a value can be treated as an object record.
27
+ */
28
+ export declare function isRecord(value: unknown): value is Record<PropertyKey, unknown>;
29
+ /**
30
+ * Returns true when a value is an Error instance.
31
+ */
32
+ export declare function isError(value: unknown): value is Error;
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/guards/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAE9D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,OAAO,CAE1D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAOnF;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAE9E;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAEtD"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Returns true when a value is neither null nor undefined.
3
+ */
4
+ export function isDefined(value) {
5
+ return value !== null && value !== undefined;
6
+ }
7
+ /**
8
+ * Returns true when a value is a string.
9
+ */
10
+ export function isString(value) {
11
+ return typeof value === "string";
12
+ }
13
+ /**
14
+ * Returns true when a value is a finite number.
15
+ */
16
+ export function isNumber(value) {
17
+ return typeof value === "number" && Number.isFinite(value);
18
+ }
19
+ /**
20
+ * Returns true when a value is a boolean.
21
+ */
22
+ export function isBoolean(value) {
23
+ return typeof value === "boolean";
24
+ }
25
+ /**
26
+ * Returns true when a value is a non-null object.
27
+ */
28
+ export function isObject(value) {
29
+ return typeof value === "object" && value !== null;
30
+ }
31
+ /**
32
+ * Returns true when a value is an object literal or a null-prototype object.
33
+ */
34
+ export function isPlainObject(value) {
35
+ if (!isObject(value)) {
36
+ return false;
37
+ }
38
+ const prototype = Object.getPrototypeOf(value);
39
+ return prototype === Object.prototype || prototype === null;
40
+ }
41
+ /**
42
+ * Returns true when a value can be treated as an object record.
43
+ */
44
+ export function isRecord(value) {
45
+ return isObject(value) && !Array.isArray(value);
46
+ }
47
+ /**
48
+ * Returns true when a value is an Error instance.
49
+ */
50
+ export function isError(value) {
51
+ return value instanceof Error;
52
+ }
@@ -0,0 +1,9 @@
1
+ export * from "./assertions/index.js";
2
+ export * from "./async/index.js";
3
+ export * from "./constants/index.js";
4
+ export * from "./guards/index.js";
5
+ export * from "./objects/index.js";
6
+ export * from "./paths/index.js";
7
+ export * from "./strings/index.js";
8
+ export * from "./types/index.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export * from "./assertions/index.js";
2
+ export * from "./async/index.js";
3
+ export * from "./constants/index.js";
4
+ export * from "./guards/index.js";
5
+ export * from "./objects/index.js";
6
+ export * from "./paths/index.js";
7
+ export * from "./strings/index.js";
8
+ export * from "./types/index.js";
@@ -0,0 +1,20 @@
1
+ import type { DeepReadonly } from "../types/index.js";
2
+ /**
3
+ * Recursively freezes an object and its object-valued own properties.
4
+ */
5
+ export declare function deepFreeze<T>(value: T): DeepReadonly<T>;
6
+ /**
7
+ * Returns true when an object owns a property directly.
8
+ */
9
+ export declare function hasOwn<T extends object, K extends PropertyKey>(object: T, key: K): object is T & Record<K, unknown>;
10
+ /**
11
+ * Returns true when an object has no own string or symbol keys.
12
+ */
13
+ export declare function isEmptyObject(object: object): boolean;
14
+ /**
15
+ * Returns a shallow merge where undefined source values are ignored.
16
+ */
17
+ export declare function mergeDefined<T extends object>(target: T, ...sources: ReadonlyArray<{
18
+ [Key in keyof T]?: T[Key] | undefined;
19
+ }>): T;
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/objects/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAcvD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,WAAW,EAC5D,MAAM,EAAE,CAAC,EACT,GAAG,EAAE,CAAC,GACL,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAElC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,aAAa,CAAC;KAAG,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS;CAAE,CAAC,GACnE,CAAC,CAcH"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Recursively freezes an object and its object-valued own properties.
3
+ */
4
+ export function deepFreeze(value) {
5
+ if (value === null || (typeof value !== "object" && typeof value !== "function")) {
6
+ return value;
7
+ }
8
+ for (const key of Reflect.ownKeys(value)) {
9
+ const child = value[key];
10
+ if (child !== null && (typeof child === "object" || typeof child === "function")) {
11
+ deepFreeze(child);
12
+ }
13
+ }
14
+ return Object.freeze(value);
15
+ }
16
+ /**
17
+ * Returns true when an object owns a property directly.
18
+ */
19
+ export function hasOwn(object, key) {
20
+ return Object.prototype.hasOwnProperty.call(object, key);
21
+ }
22
+ /**
23
+ * Returns true when an object has no own string or symbol keys.
24
+ */
25
+ export function isEmptyObject(object) {
26
+ return Reflect.ownKeys(object).length === 0;
27
+ }
28
+ /**
29
+ * Returns a shallow merge where undefined source values are ignored.
30
+ */
31
+ export function mergeDefined(target, ...sources) {
32
+ const result = { ...target };
33
+ for (const source of sources) {
34
+ for (const key of Reflect.ownKeys(source)) {
35
+ const value = source[key];
36
+ if (value !== undefined) {
37
+ result[key] = value;
38
+ }
39
+ }
40
+ }
41
+ return result;
42
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns the final segment of a slash-delimited path.
3
+ */
4
+ export declare function basename(path: string): string;
5
+ /**
6
+ * Returns every segment before the final segment of a slash-delimited path.
7
+ */
8
+ export declare function dirname(path: string): string;
9
+ /**
10
+ * Joins path segments using forward slashes and normalizes the result.
11
+ */
12
+ export declare function joinPath(...segments: readonly string[]): string;
13
+ /**
14
+ * Normalizes a path to forward slashes, removes duplicate separators, and resolves dot segments.
15
+ */
16
+ export declare function normalizePath(path: string): string;
17
+ /**
18
+ * Splits a normalized path into non-empty segments.
19
+ */
20
+ export declare function splitPath(path: string): string[];
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/paths/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG7C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW5C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAE/D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA8BlD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAGhD"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Returns the final segment of a slash-delimited path.
3
+ */
4
+ export function basename(path) {
5
+ const parts = splitPath(path);
6
+ return parts.at(-1) ?? "";
7
+ }
8
+ /**
9
+ * Returns every segment before the final segment of a slash-delimited path.
10
+ */
11
+ export function dirname(path) {
12
+ const normalized = normalizePath(path);
13
+ const absolute = normalized.startsWith("/");
14
+ const parts = splitPath(normalized);
15
+ if (parts.length <= 1) {
16
+ return absolute ? "/" : "";
17
+ }
18
+ const directory = parts.slice(0, -1).join("/");
19
+ return absolute ? `/${directory}` : directory;
20
+ }
21
+ /**
22
+ * Joins path segments using forward slashes and normalizes the result.
23
+ */
24
+ export function joinPath(...segments) {
25
+ return normalizePath(segments.filter((segment) => segment.length > 0).join("/"));
26
+ }
27
+ /**
28
+ * Normalizes a path to forward slashes, removes duplicate separators, and resolves dot segments.
29
+ */
30
+ export function normalizePath(path) {
31
+ const slashPath = path.replace(/\\/g, "/");
32
+ const absolute = slashPath.startsWith("/");
33
+ const output = [];
34
+ for (const segment of slashPath.split("/")) {
35
+ if (segment === "" || segment === ".") {
36
+ continue;
37
+ }
38
+ if (segment === "..") {
39
+ if (output.length > 0 && output.at(-1) !== "..") {
40
+ output.pop();
41
+ }
42
+ else if (!absolute) {
43
+ output.push(segment);
44
+ }
45
+ continue;
46
+ }
47
+ output.push(segment);
48
+ }
49
+ const normalized = output.join("/");
50
+ if (absolute) {
51
+ return normalized.length > 0 ? `/${normalized}` : "/";
52
+ }
53
+ return normalized;
54
+ }
55
+ /**
56
+ * Splits a normalized path into non-empty segments.
57
+ */
58
+ export function splitPath(path) {
59
+ const normalized = normalizePath(path);
60
+ return normalized.split("/").filter((segment) => segment.length > 0);
61
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Uppercases the first character of a string.
3
+ */
4
+ export declare function capitalize(value: string): string;
5
+ /**
6
+ * Returns true when a string contains only whitespace.
7
+ */
8
+ export declare function isBlank(value: string): boolean;
9
+ /**
10
+ * Removes leading forward slashes.
11
+ */
12
+ export declare function trimStartSlash(value: string): string;
13
+ /**
14
+ * Removes trailing forward slashes.
15
+ */
16
+ export declare function trimEndSlash(value: string): string;
17
+ /**
18
+ * Converts CRLF and CR line endings to LF.
19
+ */
20
+ export declare function normalizeLineEndings(value: string): string;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/strings/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMhD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Uppercases the first character of a string.
3
+ */
4
+ export function capitalize(value) {
5
+ if (value.length === 0) {
6
+ return value;
7
+ }
8
+ return `${value.charAt(0).toUpperCase()}${value.slice(1)}`;
9
+ }
10
+ /**
11
+ * Returns true when a string contains only whitespace.
12
+ */
13
+ export function isBlank(value) {
14
+ return value.trim().length === 0;
15
+ }
16
+ /**
17
+ * Removes leading forward slashes.
18
+ */
19
+ export function trimStartSlash(value) {
20
+ return value.replace(/^\/+/, "");
21
+ }
22
+ /**
23
+ * Removes trailing forward slashes.
24
+ */
25
+ export function trimEndSlash(value) {
26
+ return value.replace(/\/+$/, "");
27
+ }
28
+ /**
29
+ * Converts CRLF and CR line endings to LF.
30
+ */
31
+ export function normalizeLineEndings(value) {
32
+ return value.replace(/\r\n?/g, "\n");
33
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * A value that may be returned directly or through a Promise.
3
+ */
4
+ export type Awaitable<T> = T | Promise<T>;
5
+ /**
6
+ * Recursively makes every property optional.
7
+ */
8
+ export type DeepPartial<T> = T extends Primitive | ((...args: never[]) => unknown) ? T : T extends readonly (infer Item)[] ? readonly DeepPartial<Item>[] : {
9
+ readonly [Key in keyof T]?: DeepPartial<T[Key]>;
10
+ };
11
+ /**
12
+ * Recursively makes every property readonly.
13
+ */
14
+ export type DeepReadonly<T> = T extends Primitive | ((...args: never[]) => unknown) ? T : T extends readonly (infer Item)[] ? readonly DeepReadonly<Item>[] : {
15
+ readonly [Key in keyof T]: DeepReadonly<T[Key]>;
16
+ };
17
+ /**
18
+ * A value that may be undefined.
19
+ */
20
+ export type Maybe<T> = T | undefined;
21
+ /**
22
+ * A value that may be returned directly or through a Promise-like value.
23
+ */
24
+ export type MaybePromise<T> = T | PromiseLike<T>;
25
+ /**
26
+ * A readonly array with at least one item.
27
+ */
28
+ export type NonEmptyArray<T> = readonly [T, ...T[]];
29
+ /**
30
+ * A value that may be null.
31
+ */
32
+ export type Nullable<T> = T | null;
33
+ /**
34
+ * Primitive JavaScript values.
35
+ */
36
+ export type Primitive = string | number | boolean | bigint | symbol | null | undefined;
37
+ /**
38
+ * Flattens an object type for easier editor display.
39
+ */
40
+ export type Prettify<T> = {
41
+ [Key in keyof T]: T[Key];
42
+ } & {};
43
+ /**
44
+ * The union of an object's value types.
45
+ */
46
+ export type ValueOf<T> = T[keyof T];
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAE1C;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,GAC9E,CAAC,GACD,CAAC,SAAS,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,GAC/B,SAAS,WAAW,CAAC,IAAI,CAAC,EAAE,GAC5B;IAAE,QAAQ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-0,0 +1,99 @@
1
+ {
2
+ "name": "@sourceaxis/shared",
3
+ "version": "0.1.0",
4
+ "description": "Provider-neutral shared utilities for SourceAxis packages.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/esm/index.d.ts",
15
+ "import": "./dist/esm/index.js",
16
+ "require": "./dist/cjs/index.js",
17
+ "default": "./dist/esm/index.js"
18
+ },
19
+ "./assertions": {
20
+ "types": "./dist/esm/assertions/index.d.ts",
21
+ "import": "./dist/esm/assertions/index.js",
22
+ "require": "./dist/cjs/assertions/index.js",
23
+ "default": "./dist/esm/assertions/index.js"
24
+ },
25
+ "./async": {
26
+ "types": "./dist/esm/async/index.d.ts",
27
+ "import": "./dist/esm/async/index.js",
28
+ "require": "./dist/cjs/async/index.js",
29
+ "default": "./dist/esm/async/index.js"
30
+ },
31
+ "./constants": {
32
+ "types": "./dist/esm/constants/index.d.ts",
33
+ "import": "./dist/esm/constants/index.js",
34
+ "require": "./dist/cjs/constants/index.js",
35
+ "default": "./dist/esm/constants/index.js"
36
+ },
37
+ "./guards": {
38
+ "types": "./dist/esm/guards/index.d.ts",
39
+ "import": "./dist/esm/guards/index.js",
40
+ "require": "./dist/cjs/guards/index.js",
41
+ "default": "./dist/esm/guards/index.js"
42
+ },
43
+ "./objects": {
44
+ "types": "./dist/esm/objects/index.d.ts",
45
+ "import": "./dist/esm/objects/index.js",
46
+ "require": "./dist/cjs/objects/index.js",
47
+ "default": "./dist/esm/objects/index.js"
48
+ },
49
+ "./paths": {
50
+ "types": "./dist/esm/paths/index.d.ts",
51
+ "import": "./dist/esm/paths/index.js",
52
+ "require": "./dist/cjs/paths/index.js",
53
+ "default": "./dist/esm/paths/index.js"
54
+ },
55
+ "./strings": {
56
+ "types": "./dist/esm/strings/index.d.ts",
57
+ "import": "./dist/esm/strings/index.js",
58
+ "require": "./dist/cjs/strings/index.js",
59
+ "default": "./dist/esm/strings/index.js"
60
+ },
61
+ "./types": {
62
+ "types": "./dist/esm/types/index.d.ts",
63
+ "import": "./dist/esm/types/index.js",
64
+ "require": "./dist/cjs/types/index.js",
65
+ "default": "./dist/esm/types/index.js"
66
+ }
67
+ },
68
+ "types": "./dist/esm/index.d.ts",
69
+ "scripts": {
70
+ "build": "tsc -p tsconfig.esm.json && node ../../scripts/build/build-cjs.mjs .",
71
+ "test": "vitest run",
72
+ "typecheck": "tsc -p tsconfig.json --noEmit"
73
+ },
74
+ "main": "./dist/cjs/index.js",
75
+ "module": "./dist/esm/index.js",
76
+ "engines": {
77
+ "node": ">=20.19.0"
78
+ },
79
+ "repository": {
80
+ "type": "git",
81
+ "url": "git+https://github.com/mriduldey/source-axis.git",
82
+ "directory": "packages/shared"
83
+ },
84
+ "bugs": {
85
+ "url": "https://github.com/mriduldey/source-axis/issues"
86
+ },
87
+ "homepage": "https://github.com/mriduldey/source-axis#readme",
88
+ "keywords": [
89
+ "git",
90
+ "github",
91
+ "sdk",
92
+ "typescript",
93
+ "provider-neutral"
94
+ ],
95
+ "publishConfig": {
96
+ "access": "public",
97
+ "provenance": true
98
+ }
99
+ }