@xylabs/promise 4.13.13 → 4.13.15

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.
@@ -0,0 +1,11 @@
1
+ export type PromiseExSubFunc<T, TResult = T> = (value: T) => TResult;
2
+ export type PromiseExFunc<T> = (resolve?: PromiseExSubFunc<T, void>, reject?: PromiseExSubFunc<T, void>) => void;
3
+ export type PromiseExValueFunc<V> = (value?: V) => boolean;
4
+ export declare class PromiseEx<T, V = void> extends Promise<T> {
5
+ cancelled?: boolean;
6
+ private _value?;
7
+ constructor(func: PromiseExFunc<T>, value?: V);
8
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null | undefined, onvalue?: (value?: V) => boolean): Promise<TResult1 | TResult2>;
9
+ value(onvalue?: (value?: V) => boolean): this;
10
+ }
11
+ //# sourceMappingURL=PromiseEx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PromiseEx.d.ts","sourceRoot":"","sources":["../../src/PromiseEx.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAA;AACpE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,IAAI,CAAA;AAChH,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,CAAA;AAE1D,qBAAa,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAE,SAAQ,OAAO,CAAC,CAAC,CAAC;IACpD,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,MAAM,CAAC,CAAG;gBAEN,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC;IAMpC,IAAI,CAAC,QAAQ,GAAG,CAAC,EAAE,QAAQ,GAAG,KAAK,EAC1C,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EACjF,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,EACvF,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,GAC/B,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAO/B,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO;CAMvC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * For use with Promise.allSettled to filter only successful results
3
+ * @param val
4
+ * @returns
5
+ */
6
+ export declare const fulfilled: <T>(val: PromiseSettledResult<T>) => val is PromiseFulfilledResult<T>;
7
+ //# sourceMappingURL=fulfilled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fulfilled.d.ts","sourceRoot":"","sources":["../../src/fulfilled.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,KAAK,oBAAoB,CAAC,CAAC,CAAC,KAAG,GAAG,IAAI,sBAAsB,CAAC,CAAC,CAE1F,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * For use with Promise.allSettled to reduce to only successful result values
3
+ * @example <caption>Casting the initialValue provided to reduce</caption>
4
+ * const resolved = Promise.resolve('resolved')
5
+ * const rejected = Promise.reject('rejected')
6
+ * const settled = await Promise.allSettled([resolved, rejected])
7
+ * const results = settled.reduce(fulfilledValues, [] as string[])
8
+ * // results === [ 'resolved' ]
9
+ * @example <caption>Providing type parameter to reduce and initialValue type can be inferred</caption>
10
+ * const resolved = Promise.resolve('resolved')
11
+ * const rejected = Promise.reject('rejected')
12
+ * const settled = await Promise.allSettled([resolved, rejected])
13
+ * const results = settled.reduce<string[]>(fulfilledValues, [])
14
+ * // results === [ 'resolved' ]
15
+ * @param previousValue
16
+ * @param currentValue
17
+ * @returns
18
+ */
19
+ export declare const fulfilledValues: <T>(previousValue: T[], currentValue: PromiseSettledResult<T>) => T[];
20
+ //# sourceMappingURL=fulfilledValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fulfilledValues.d.ts","sourceRoot":"","sources":["../../src/fulfilledValues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,eAAe,CAAC,EAAE,EAAE,cAAc,oBAAoB,CAAC,CAAC,CAAC,KAAG,CAAC,EAG/F,CAAA"}
@@ -0,0 +1,8 @@
1
+ export { fulfilled } from './fulfilled.ts';
2
+ export { fulfilledValues } from './fulfilledValues.ts';
3
+ export * from './isPromise.ts';
4
+ export * from './PromiseEx.ts';
5
+ export { rejected } from './rejected.ts';
6
+ export * from './toPromise.ts';
7
+ export * from './types.ts';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { TypedValue } from '@xylabs/typeof';
2
+ export interface PromiseType {
3
+ then: () => unknown;
4
+ }
5
+ export type AnyNonPromise = Exclude<TypedValue, PromiseType>;
6
+ export declare const isPromise: (value: unknown) => value is Promise<unknown>;
7
+ //# sourceMappingURL=isPromise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isPromise.d.ts","sourceRoot":"","sources":["../../src/isPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,OAAO,CAAA;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;AAE5D,eAAO,MAAM,SAAS,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,OAAO,CAAC,OAAO,CAKlE,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * For use with Promise.allSettled to filter only rejected results
3
+ * @param val
4
+ * @returns
5
+ */
6
+ export declare const rejected: <T>(val: PromiseSettledResult<T>) => val is PromiseRejectedResult;
7
+ //# sourceMappingURL=rejected.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rejected.d.ts","sourceRoot":"","sources":["../../src/rejected.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,EAAE,KAAK,oBAAoB,CAAC,CAAC,CAAC,KAAG,GAAG,IAAI,qBAEjE,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Promisable } from './types.ts';
2
+ export declare function toPromise<T>(value: Promisable<T>): Promise<T>;
3
+ //# sourceMappingURL=toPromise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toPromise.d.ts","sourceRoot":"","sources":["../../src/toPromise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE7D"}
@@ -0,0 +1,10 @@
1
+ import type { PromiseEx } from './PromiseEx.ts';
2
+ export type Promisable<T, V = never> = PromiseEx<T, V> | Promise<T> | T;
3
+ export type PromisableArray<T, V = never> = Promisable<T[], V>;
4
+ export type OptionalPromisable<T, V = never> = Promisable<T | undefined, V>;
5
+ export type OptionalPromisableArray<T, V = never> = PromisableArray<T | undefined, V>;
6
+ export type NullablePromisable<T, V = never> = Promisable<T | null, V>;
7
+ export type NullablePromisableArray<T, V = never> = PromisableArray<T | null, V>;
8
+ /** @description Used to document promises that are being used as Mutexes */
9
+ export type AsyncMutex<T> = Promise<T>;
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE/C,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AACvE,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AAC9D,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC,CAAA;AAC3E,MAAM,MAAM,uBAAuB,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,eAAe,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC,CAAA;AACrF,MAAM,MAAM,kBAAkB,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,UAAU,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAA;AACtE,MAAM,MAAM,uBAAuB,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,IAAI,eAAe,CAAC,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAA;AAEhF,4EAA4E;AAC5E,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/promise",
3
- "version": "4.13.13",
3
+ "version": "4.13.15",
4
4
  "description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
5
5
  "keywords": [
6
6
  "promise",
@@ -36,13 +36,13 @@
36
36
  "module": "./dist/neutral/index.mjs",
37
37
  "types": "./dist/neutral/index.d.ts",
38
38
  "dependencies": {
39
- "@xylabs/typeof": "^4.13.13"
39
+ "@xylabs/typeof": "^4.13.15"
40
40
  },
41
41
  "devDependencies": {
42
- "@xylabs/ts-scripts-yarn3": "^7.0.0-rc.9",
43
- "@xylabs/tsconfig": "^7.0.0-rc.9",
44
- "@xylabs/typeof": "^4.13.13",
45
- "@xylabs/vitest-extended": "^4.13.13",
42
+ "@xylabs/ts-scripts-yarn3": "^7.0.0-rc.20",
43
+ "@xylabs/tsconfig": "^7.0.0-rc.20",
44
+ "@xylabs/typeof": "^4.13.15",
45
+ "@xylabs/vitest-extended": "^4.13.15",
46
46
  "typescript": "^5.8.3",
47
47
  "vitest": "^3.2.4"
48
48
  },