Comparing version 2.5.0 to 2.6.2
@@ -32,2 +32,4 @@ import tslib from '../tslib.js'; | ||
__classPrivateFieldIn, | ||
__addDisposableResource, | ||
__disposeResources, | ||
} = tslib; | ||
@@ -64,2 +66,5 @@ export { | ||
__classPrivateFieldIn, | ||
__addDisposableResource, | ||
__disposeResources, | ||
}; | ||
export default tslib; |
@@ -5,3 +5,3 @@ { | ||
"homepage": "https://www.typescriptlang.org/", | ||
"version": "2.5.0", | ||
"version": "2.6.2", | ||
"license": "0BSD", | ||
@@ -32,4 +32,13 @@ "description": "Runtime library for TypeScript helper functions", | ||
".": { | ||
"module": "./tslib.es6.js", | ||
"import": "./modules/index.js", | ||
"module": { | ||
"types": "./modules/index.d.ts", | ||
"default": "./tslib.es6.mjs" | ||
}, | ||
"import": { | ||
"node": "./modules/index.js", | ||
"default": { | ||
"types": "./modules/index.d.ts", | ||
"default": "./tslib.es6.mjs" | ||
} | ||
}, | ||
"default": "./tslib.js" | ||
@@ -36,0 +45,0 @@ }, |
# tslib | ||
This is a runtime library for [TypeScript](http://www.typescriptlang.org/) that contains all of the TypeScript helper functions. | ||
This is a runtime library for [TypeScript](https://www.typescriptlang.org/) that contains all of the TypeScript helper functions. | ||
@@ -5,0 +5,0 @@ This library is primarily used by the `--importHelpers` flag in TypeScript. |
@@ -431,1 +431,24 @@ /****************************************************************************** | ||
export declare function __createBinding(object: object, target: object, key: PropertyKey, objectKey?: PropertyKey): void; | ||
/** | ||
* Adds a disposable resource to a resource-tracking environment object. | ||
* @param env A resource-tracking environment object. | ||
* @param value Either a Disposable or AsyncDisposable object, `null`, or `undefined`. | ||
* @param async When `true`, `AsyncDisposable` resources can be added. When `false`, `AsyncDisposable` resources cannot be added. | ||
* @returns The {@link value} argument. | ||
* | ||
* @throws {TypeError} If {@link value} is not an object, or if either `Symbol.dispose` or `Symbol.asyncDispose` are not | ||
* defined, or if {@link value} does not have an appropriate `Symbol.dispose` or `Symbol.asyncDispose` method. | ||
*/ | ||
export declare function __addDisposableResource<T>(env: { stack: { value?: unknown, dispose?: Function, async: boolean }[]; error: unknown; hasError: boolean; }, value: T, async: boolean): T; | ||
/** | ||
* Disposes all resources in a resource-tracking environment object. | ||
* @param env A resource-tracking environment object. | ||
* @returns A {@link Promise} if any resources in the environment were marked as `async` when added; otherwise, `void`. | ||
* | ||
* @throws {SuppressedError} if an error thrown during disposal would have suppressed a prior error from disposal or the | ||
* error recorded in the resource-tracking environment object. | ||
* @seealso {@link __addDisposableResource} | ||
*/ | ||
export declare function __disposeResources(env: { stack: { value?: unknown, dispose?: Function, async: boolean }[]; error: unknown; hasError: boolean; }): any; |
@@ -15,3 +15,3 @@ /****************************************************************************** | ||
***************************************************************************** */ | ||
/* global Reflect, Promise */ | ||
/* global Reflect, Promise, SuppressedError, Symbol */ | ||
@@ -84,6 +84,6 @@ var extendStatics = function(d, b) { | ||
if (_ = accept(result.set)) descriptor.set = _; | ||
if (_ = accept(result.init)) initializers.push(_); | ||
if (_ = accept(result.init)) initializers.unshift(_); | ||
} | ||
else if (_ = accept(result)) { | ||
if (kind === "field") initializers.push(_); | ||
if (kind === "field") initializers.unshift(_); | ||
else descriptor[key] = _; | ||
@@ -296,1 +296,78 @@ } | ||
} | ||
export function __addDisposableResource(env, value, async) { | ||
if (value !== null && value !== void 0) { | ||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); | ||
var dispose; | ||
if (async) { | ||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); | ||
dispose = value[Symbol.asyncDispose]; | ||
} | ||
if (dispose === void 0) { | ||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); | ||
dispose = value[Symbol.dispose]; | ||
} | ||
if (typeof dispose !== "function") throw new TypeError("Object not disposable."); | ||
env.stack.push({ value: value, dispose: dispose, async: async }); | ||
} | ||
else if (async) { | ||
env.stack.push({ async: true }); | ||
} | ||
return value; | ||
} | ||
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
export function __disposeResources(env) { | ||
function fail(e) { | ||
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; | ||
env.hasError = true; | ||
} | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
catch (e) { | ||
fail(e); | ||
} | ||
} | ||
if (env.hasError) throw env.error; | ||
} | ||
return next(); | ||
} | ||
export default { | ||
__extends: __extends, | ||
__assign: __assign, | ||
__rest: __rest, | ||
__decorate: __decorate, | ||
__param: __param, | ||
__metadata: __metadata, | ||
__awaiter: __awaiter, | ||
__generator: __generator, | ||
__createBinding: __createBinding, | ||
__exportStar: __exportStar, | ||
__values: __values, | ||
__read: __read, | ||
__spread: __spread, | ||
__spreadArrays: __spreadArrays, | ||
__spreadArray: __spreadArray, | ||
__await: __await, | ||
__asyncGenerator: __asyncGenerator, | ||
__asyncDelegator: __asyncDelegator, | ||
__asyncValues: __asyncValues, | ||
__makeTemplateObject: __makeTemplateObject, | ||
__importStar: __importStar, | ||
__importDefault: __importDefault, | ||
__classPrivateFieldGet: __classPrivateFieldGet, | ||
__classPrivateFieldSet: __classPrivateFieldSet, | ||
__classPrivateFieldIn: __classPrivateFieldIn, | ||
__addDisposableResource: __addDisposableResource, | ||
__disposeResources: __disposeResources, | ||
}; |
57
tslib.js
@@ -15,3 +15,3 @@ /****************************************************************************** | ||
***************************************************************************** */ | ||
/* global global, define, System, Reflect, Promise */ | ||
/* global global, define, Symbol, Reflect, Promise, SuppressedError */ | ||
var __extends; | ||
@@ -46,2 +46,4 @@ var __assign; | ||
var __createBinding; | ||
var __addDisposableResource; | ||
var __disposeResources; | ||
(function (factory) { | ||
@@ -131,6 +133,6 @@ var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {}; | ||
if (_ = accept(result.set)) descriptor.set = _; | ||
if (_ = accept(result.init)) initializers.push(_); | ||
if (_ = accept(result.init)) initializers.unshift(_); | ||
} | ||
else if (_ = accept(result)) { | ||
if (kind === "field") initializers.push(_); | ||
if (kind === "field") initializers.unshift(_); | ||
else descriptor[key] = _; | ||
@@ -344,2 +346,49 @@ } | ||
__addDisposableResource = function (env, value, async) { | ||
if (value !== null && value !== void 0) { | ||
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); | ||
var dispose; | ||
if (async) { | ||
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); | ||
dispose = value[Symbol.asyncDispose]; | ||
} | ||
if (dispose === void 0) { | ||
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); | ||
dispose = value[Symbol.dispose]; | ||
} | ||
if (typeof dispose !== "function") throw new TypeError("Object not disposable."); | ||
env.stack.push({ value: value, dispose: dispose, async: async }); | ||
} | ||
else if (async) { | ||
env.stack.push({ async: true }); | ||
} | ||
return value; | ||
}; | ||
var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { | ||
var e = new Error(message); | ||
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; | ||
}; | ||
__disposeResources = function (env) { | ||
function fail(e) { | ||
env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; | ||
env.hasError = true; | ||
} | ||
function next() { | ||
while (env.stack.length) { | ||
var rec = env.stack.pop(); | ||
try { | ||
var result = rec.dispose && rec.dispose.call(rec.value); | ||
if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); | ||
} | ||
catch (e) { | ||
fail(e); | ||
} | ||
} | ||
if (env.hasError) throw env.error; | ||
} | ||
return next(); | ||
}; | ||
exporter("__extends", __extends); | ||
@@ -374,2 +423,4 @@ exporter("__assign", __assign); | ||
exporter("__classPrivateFieldIn", __classPrivateFieldIn); | ||
exporter("__addDisposableResource", __addDisposableResource); | ||
exporter("__disposeResources", __disposeResources); | ||
}); |
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
83980
14
1568