@js-bits/xpromise
Advanced tools
Comparing version 1.0.10 to 1.0.11
export default ExtendablePromise; | ||
export type Resolve<T> = (value: T | PromiseLike<T>, ...rest: unknown[]) => void; | ||
export type Reject = (reason?: Error) => void; | ||
export type ErrorName<T> = T extends `ExtendablePromise|${infer S}` ? `*|${S}` : never; | ||
/** | ||
@@ -54,6 +55,6 @@ * @template T | ||
declare namespace ExtendablePromise { | ||
const ExecutionError: "ExtendablePromise|ExecutionError"; | ||
const InstantiationError: "ExtendablePromise|InstantiationError"; | ||
const ExecutionError: "*|ExecutionError"; | ||
const InstantiationError: "*|InstantiationError"; | ||
} | ||
import * as UniqueSymbols from '@js-bits/enumerate/types/unique-symbols'; |
15
index.js
@@ -13,2 +13,4 @@ import enumerate from '@js-bits/enumerate'; | ||
const ErrorPrefix = 'ExtendablePromise|'; | ||
const ERRORS = enumerate.ts( | ||
@@ -19,3 +21,3 @@ ` | ||
`, | ||
Prefix('ExtendablePromise|') | ||
Prefix(ErrorPrefix) | ||
); | ||
@@ -123,6 +125,13 @@ | ||
/** | ||
* @template T | ||
* @typedef {T extends `${ErrorPrefix}${infer S}` ? `*|${S}`: never} ErrorName | ||
*/ | ||
// Assigning properties one by one helps typescript to declare the namespace properly | ||
ExtendablePromise.ExecutionError = ERRORS.ExecutionError; | ||
ExtendablePromise.InstantiationError = ERRORS.InstantiationError; | ||
ExtendablePromise.ExecutionError = /** @type {ErrorName<typeof ERRORS.ExecutionError>} */ (ERRORS.ExecutionError); | ||
ExtendablePromise.InstantiationError = /** @type {ErrorName<typeof ERRORS.InstantiationError>} */ ( | ||
ERRORS.InstantiationError | ||
); | ||
export default ExtendablePromise; |
{ | ||
"name": "@js-bits/xpromise", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"description": "Extendable Promise", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28414
740