destroyable
Advanced tools
Comparing version 0.12.0 to 0.12.2
@@ -1,6 +0,3 @@ | ||
/** | ||
* @collboard-modules-sdk | ||
*/ | ||
export declare class AlreadyDestroyedError extends Error { | ||
readonly name = "AlreadyDestroyedError"; | ||
} |
"use strict"; | ||
/** | ||
* @collboard-modules-sdk | ||
*/ | ||
var __extends = (this && this.__extends) || (function () { | ||
@@ -6,0 +3,0 @@ var extendStatics = function (d, b) { |
import { IDestroyable } from './IDestroyable'; | ||
import { INotDestroyed } from './INotDestroyed'; | ||
import { ITeardownLogic } from './TeardownLogic'; | ||
/** | ||
* Generic implementation of the IDestroyable | ||
* | ||
* @collboard-modules-sdk | ||
*/ | ||
@@ -28,5 +27,4 @@ export declare abstract class Destroyable implements IDestroyable { | ||
* @param errorMessage Message that will replace default one before error | ||
* @param runBeforeError Callback runed before error is thrown; typically this can be some logging | ||
*/ | ||
protected checkWhetherNotDestroyed(errorMessage?: string, runBeforeError?: () => void): void; | ||
protected assertNotDestroyed(errorMessage?: string): asserts this is INotDestroyed; | ||
} |
@@ -44,4 +44,2 @@ "use strict"; | ||
* Generic implementation of the IDestroyable | ||
* | ||
* @collboard-modules-sdk | ||
*/ | ||
@@ -76,3 +74,3 @@ var Destroyable = /** @class */ (function () { | ||
case 0: | ||
this.checkWhetherNotDestroyed(); | ||
this.assertNotDestroyed(); | ||
this._isDestroyed = true; | ||
@@ -113,10 +111,7 @@ _i = 0, _a = this.subdestroyable; | ||
* @param errorMessage Message that will replace default one before error | ||
* @param runBeforeError Callback runed before error is thrown; typically this can be some logging | ||
*/ | ||
Destroyable.prototype.checkWhetherNotDestroyed = function (errorMessage, runBeforeError) { | ||
Destroyable.prototype.assertNotDestroyed = function (errorMessage) { | ||
if (errorMessage === void 0) { errorMessage = "This object is already destroyed."; } | ||
if (this._isDestroyed) { | ||
if (runBeforeError) { | ||
runBeforeError(); | ||
} | ||
throw new AlreadyDestroyedError_1.AlreadyDestroyedError(errorMessage || "This object is already destroyed."); | ||
throw new AlreadyDestroyedError_1.AlreadyDestroyedError(errorMessage); | ||
} | ||
@@ -123,0 +118,0 @@ }; |
import { Destroyable } from './Destroyable'; | ||
/** | ||
* @collboard-modules-sdk | ||
*/ | ||
export declare class DestroyableLoop extends Destroyable { | ||
constructor(executor: (amIDestroyed: () => boolean) => Promise<void>); | ||
} |
@@ -20,5 +20,2 @@ "use strict"; | ||
var Destroyable_1 = require("./Destroyable"); | ||
/** | ||
* @collboard-modules-sdk | ||
*/ | ||
var DestroyableLoop = /** @class */ (function (_super) { | ||
@@ -25,0 +22,0 @@ __extends(DestroyableLoop, _super); |
/** | ||
* @collboard-modules-sdk | ||
* Represents a collision error ⁘ | ||
* | ||
* @extends Error | ||
*/ | ||
@@ -4,0 +6,0 @@ export declare class CollisionError extends Error { |
@@ -20,3 +20,5 @@ "use strict"; | ||
/** | ||
* @collboard-modules-sdk | ||
* Represents a collision error ⁘ | ||
* | ||
* @extends Error | ||
*/ | ||
@@ -23,0 +25,0 @@ var CollisionError = /** @class */ (function (_super) { |
/** | ||
* @collboard-modules-sdk | ||
* Represents an error when a resource is not found ⁘ | ||
* | ||
* @extends Error | ||
*/ | ||
@@ -4,0 +6,0 @@ export declare class NotFoundError extends Error { |
@@ -20,3 +20,5 @@ "use strict"; | ||
/** | ||
* @collboard-modules-sdk | ||
* Represents an error when a resource is not found ⁘ | ||
* | ||
* @extends Error | ||
*/ | ||
@@ -23,0 +25,0 @@ var NotFoundError = /** @class */ (function (_super) { |
import { Promisable } from "type-fest"; | ||
/** | ||
* Interface, all destroyable objects implement | ||
* | ||
* @collboard-modules-sdk | ||
* Represents object that can be destrioyed | ||
*/ | ||
@@ -7,0 +5,0 @@ export interface IDestroyable { |
@@ -7,2 +7,4 @@ import { AlreadyDestroyedError } from './AlreadyDestroyedError'; | ||
import { IDestroyable } from './IDestroyable'; | ||
import { IDestroyed } from './IDestroyed'; | ||
import { INotDestroyed } from './INotDestroyed'; | ||
import { IRegisterItemsOptions } from './IRegisterItemsOptions'; | ||
@@ -20,2 +22,2 @@ import { ISubscription } from './ISubscription'; | ||
import { teardown } from './TeardownLogic'; | ||
export { ITick, IWork, IWaiter, teardown, softDestroy, Destroyable, Registration, IDestroyable, ISubscription, NotFoundError, ITeardownLogic, CollisionError, DestroyableLoop, registerItemsInArray, registerPairsInObject, IRegisterItemsOptions, AlreadyDestroyedError, registerItemsInSubjectOfArrays }; | ||
export { ITick, IWork, IWaiter, teardown, IDestroyed, softDestroy, Destroyable, Registration, IDestroyable, ISubscription, INotDestroyed, NotFoundError, ITeardownLogic, CollisionError, DestroyableLoop, registerItemsInArray, registerPairsInObject, IRegisterItemsOptions, AlreadyDestroyedError, registerItemsInSubjectOfArrays }; |
/** | ||
* @collboard-modules-sdk | ||
* Interface for registering items options ⁘ | ||
* | ||
* @template TBaseType - The base type of the items. | ||
* @template TItem - The type of the items. | ||
*/ | ||
@@ -4,0 +7,0 @@ export interface IRegisterItemsOptions<TBaseType, TItem> { |
/** | ||
* @collboard-modules-sdk | ||
* Represents a subscription to an event or data stream ⁘ | ||
* | ||
* @interface | ||
*/ | ||
@@ -4,0 +6,0 @@ export interface ISubscription { |
@@ -6,5 +6,3 @@ import { IRegisterItemsOptions } from './IRegisterItemsOptions'; | ||
* Warning: this utility makes mutations on base record object | ||
* | ||
* @collboard-modules-sdk | ||
*/ | ||
export declare function registerItemsInArray<TItem>({ base, add, compare, collisionStrategy, }: IRegisterItemsOptions<TItem[], TItem>): Registration; |
@@ -9,4 +9,2 @@ "use strict"; | ||
* Warning: this utility makes mutations on base record object | ||
* | ||
* @collboard-modules-sdk | ||
*/ | ||
@@ -13,0 +11,0 @@ function registerItemsInArray(_a) { |
@@ -5,6 +5,5 @@ import { IRegisterItemsOptions } from './IRegisterItemsOptions'; | ||
* Push item into record object and return object representing this pushment that can be destroyed | ||
* | ||
* Warning: this utility makes mutations on base record object | ||
* | ||
* @collboard-modules-sdk | ||
*/ | ||
export declare function registerPairsInObject<TItem>({ base, add, collisionStrategy, }: Omit<IRegisterItemsOptions<Record<string, TItem>, TItem>, 'compare'>): Registration; |
@@ -9,5 +9,4 @@ "use strict"; | ||
* Push item into record object and return object representing this pushment that can be destroyed | ||
* | ||
* Warning: this utility makes mutations on base record object | ||
* | ||
* @collboard-modules-sdk | ||
*/ | ||
@@ -14,0 +13,0 @@ function registerPairsInObject(_a) { |
@@ -9,6 +9,2 @@ import { Promisable } from 'type-fest'; | ||
* This object will be returned by register functions to unregister things | ||
* TODO: Unite Registration and Destroyable | ||
* TODO: Maybe create some Registration.create helper for MobX observe/intercept | ||
* | ||
* @collboard-modules-sdk | ||
*/ | ||
@@ -60,1 +56,5 @@ export declare class Registration extends Destroyable implements IDestroyable { | ||
} | ||
/** | ||
* TODO: Unite Registration and Destroyable | ||
* TODO: Maybe create some Registration.create helper for MobX observe/intercept | ||
*/ |
@@ -59,6 +59,2 @@ "use strict"; | ||
* This object will be returned by register functions to unregister things | ||
* TODO: Unite Registration and Destroyable | ||
* TODO: Maybe create some Registration.create helper for MobX observe/intercept | ||
* | ||
* @collboard-modules-sdk | ||
*/ | ||
@@ -245,3 +241,7 @@ var Registration = /** @class */ (function (_super) { | ||
*/ | ||
*/ | ||
/** | ||
* TODO: Unite Registration and Destroyable | ||
* TODO: Maybe create some Registration.create helper for MobX observe/intercept | ||
*/ | ||
//# sourceMappingURL=Registration.js.map |
import { Promisable } from 'type-fest'; | ||
import { IDestroyable } from './IDestroyable'; | ||
/** | ||
* Asynchronously destroys a destroyable object ⁘ | ||
* | ||
* @collboard-modules-sdk | ||
* @async | ||
* @function softDestroy | ||
* @param {Promisable<IDestroyable>} destroyable - The destroyable object to be destroyed. | ||
* @returns {Promise<void>} A Promise that resolves when the destroyable object has been destroyed. | ||
*/ | ||
export declare function softDestroy(destroyable: Promisable<IDestroyable>): Promise<void>; |
@@ -41,4 +41,8 @@ "use strict"; | ||
/** | ||
* Asynchronously destroys a destroyable object ⁘ | ||
* | ||
* @collboard-modules-sdk | ||
* @async | ||
* @function softDestroy | ||
* @param {Promisable<IDestroyable>} destroyable - The destroyable object to be destroyed. | ||
* @returns {Promise<void>} A Promise that resolves when the destroyable object has been destroyed. | ||
*/ | ||
@@ -45,0 +49,0 @@ function softDestroy(destroyable) { |
import { IDestroyable } from './IDestroyable'; | ||
import { IWork } from './IWork'; | ||
/** | ||
* @collboard-modules-sdk | ||
* @@@ | ||
*/ | ||
export declare type ITeardownLogic = IWork | IDestroyable; | ||
/** | ||
* Asynchronously tears down a component or service using the provided teardown logic ⁘ | ||
* | ||
* @collboard-modules-sdk | ||
* @async | ||
* @function | ||
* @param {ITeardownLogic | void} [teardownLogic] - The teardown logic to use. If not provided, the function returns immediately. | ||
* @returns {Promise<void>} A promise that resolves when the teardown is complete. | ||
*/ | ||
export declare function teardown(teardownLogic?: ITeardownLogic | void): Promise<void>; |
@@ -41,4 +41,8 @@ "use strict"; | ||
/** | ||
* Asynchronously tears down a component or service using the provided teardown logic ⁘ | ||
* | ||
* @collboard-modules-sdk | ||
* @async | ||
* @function | ||
* @param {ITeardownLogic | void} [teardownLogic] - The teardown logic to use. If not provided, the function returns immediately. | ||
* @returns {Promise<void>} A promise that resolves when the teardown is complete. | ||
*/ | ||
@@ -45,0 +49,0 @@ function teardown(teardownLogic) { |
{ | ||
"name": "destroyable", | ||
"version": "0.12.0", | ||
"version": "0.12.2", | ||
"description": "Library for managing misc stuff that can be destroyed after the creation", | ||
@@ -54,4 +54,4 @@ "author": "Pavol Hejný <pavol@collboard.com> (https://pavolhejny.com)", | ||
"typedoc": "0.22.11", | ||
"waitasecond": "1.0.0" | ||
"waitasecond": "1.11.1" | ||
} | ||
} |
@@ -19,2 +19,9 @@ # 💥 Destroyable | ||
<!--Wallpaper--> | ||
<!--⚠️WARNING: This section was generated by https://github.com/hejny/batch-project-editor/blob/main/src//workflows/315-ai-generated-wallpaper/4-aiGeneratedWallpaperUseInReadme.ts so every manual change will be overwritten.--> | ||
[![Wallpaper of 💥 Destroyable](assets/ai/wallpaper/gallery/68bd00ee-2249-4113-ba30-569faa7fa4b8-0_0.png)](https://www.midjourney.com/app/jobs/68bd00ee-2249-4113-ba30-569faa7fa4b8) | ||
<!--/Wallpaper--> | ||
TODO: Write some usage and description | ||
@@ -49,11 +56,11 @@ | ||
<a href="https://collboard.com/"> | ||
<img src="https://collboard.fra1.cdn.digitaloceanspaces.com/assets/18.12.1/logo-small.png" alt="Collboard logo" width="50" /> | ||
<img src="https://collboard.fra1.cdn.digitaloceanspaces.com/assets/18.12.1/logo-small.png" alt="Collboard logo" width="50" /> | ||
</a> | ||
| ||
<a href="https://czech.events/"> | ||
<img src="https://czech.events/design/logos/czech.events.transparent-logo.png" alt="Czech.events logo" width="50" /> | ||
<img src="https://czech.events/design/logos/czech.events.transparent-logo.png" alt="Czech.events logo" width="50" /> | ||
</a> | ||
| ||
<a href="https://sigmastamp.ml/"> | ||
<img src="https://www.sigmastamp.ml/sigmastamp-logo.white.svg" alt="SigmaStamp logo" width="50" /> | ||
<img src="https://www.sigmastamp.ml/sigmastamp-logo.white.svg" alt="SigmaStamp logo" width="50" /> | ||
</a> | ||
@@ -60,0 +67,0 @@ |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
44422772
123
2557
70