Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tobes31415/dispose

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tobes31415/dispose - npm Package Compare versions

Comparing version 2.0.5 to 3.0.0

41

docs/modules.md

@@ -17,3 +17,2 @@ [@tobes31415/dispose](README.md) / Exports

- [onDisposeUnsubscribe](modules.md#ondisposeunsubscribe)
- [watchForDispose](modules.md#watchfordispose)

@@ -43,3 +42,3 @@ ## Functions

Defined in: [gc.ts:57](https://github.com/tobes31415/dispose/blob/4d88519/src/gc.ts#L57)
Defined in: [gc.ts:57](https://github.com/tobes31415/dispose/blob/d29f9dd/src/gc.ts#L57)

@@ -68,3 +67,3 @@ ___

Defined in: [gc.ts:34](https://github.com/tobes31415/dispose/blob/4d88519/src/gc.ts#L34)
Defined in: [gc.ts:34](https://github.com/tobes31415/dispose/blob/d29f9dd/src/gc.ts#L34)

@@ -93,3 +92,3 @@ ___

Defined in: [gc.ts:48](https://github.com/tobes31415/dispose/blob/4d88519/src/gc.ts#L48)
Defined in: [gc.ts:48](https://github.com/tobes31415/dispose/blob/d29f9dd/src/gc.ts#L48)

@@ -121,3 +120,3 @@ ___

Defined in: [gc.ts:70](https://github.com/tobes31415/dispose/blob/4d88519/src/gc.ts#L70)
Defined in: [gc.ts:70](https://github.com/tobes31415/dispose/blob/d29f9dd/src/gc.ts#L70)

@@ -148,3 +147,3 @@ ___

Defined in: [gc.ts:84](https://github.com/tobes31415/dispose/blob/4d88519/src/gc.ts#L84)
Defined in: [gc.ts:84](https://github.com/tobes31415/dispose/blob/d29f9dd/src/gc.ts#L84)

@@ -173,3 +172,3 @@ ___

Defined in: [gc.ts:100](https://github.com/tobes31415/dispose/blob/4d88519/src/gc.ts#L100)
Defined in: [gc.ts:100](https://github.com/tobes31415/dispose/blob/d29f9dd/src/gc.ts#L100)

@@ -198,3 +197,3 @@ ___

Defined in: [gc.ts:92](https://github.com/tobes31415/dispose/blob/4d88519/src/gc.ts#L92)
Defined in: [gc.ts:92](https://github.com/tobes31415/dispose/blob/d29f9dd/src/gc.ts#L92)

@@ -224,26 +223,2 @@ ___

Defined in: [gc-rxjs.ts:51](https://github.com/tobes31415/dispose/blob/4d88519/src/gc-rxjs.ts#L51)
___
### watchForDispose
▸ **watchForDispose**<T\>(`object`: T): *Observable*<*void*\>
Emit an event when the object is disposed
#### Type parameters:
Name | Type |
------ | ------ |
`T` | *object* |
#### Parameters:
Name | Type | Description |
------ | ------ | ------ |
`object` | T | The object to be watched |
**Returns:** *Observable*<*void*\>
Defined in: [gc-rxjs.ts:25](https://github.com/tobes31415/dispose/blob/4d88519/src/gc-rxjs.ts#L25)
Defined in: [gc.ts:139](https://github.com/tobes31415/dispose/blob/d29f9dd/src/gc.ts#L139)

2

lib/gc-commonjs.min.js

@@ -1,1 +0,1 @@

var D=Object.create,i=Object.defineProperty,x=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty,T=Object.getOwnPropertyNames,g=Object.getOwnPropertyDescriptor;var f=e=>i(e,"__esModule",{value:!0});var v=(e,o)=>{f(e);for(var n in o)i(e,n,{get:o[n],enumerable:!0})},m=(e,o,n)=>{if(f(e),o&&typeof o=="object"||typeof o=="function")for(let s of T(o))!y.call(e,s)&&s!=="default"&&i(e,s,{get:()=>o[s],enumerable:!(n=g(o,s))||n.enumerable});return e},h=e=>e&&e.__esModule?e:m(i(e!=null?D(x(e)):{},"default",{value:e,enumerable:!0}),e);v(exports,{assertNotDisposed:()=>P,dispose:()=>u,isDisposed:()=>r,onDispose:()=>t,onDisposeChain:()=>_,onDisposeDeleteProperties:()=>j,onDisposeDisposeProperties:()=>C,onDisposeUnsubscribe:()=>w,watchForDispose:()=>O});var p=Symbol("gc");function d(e){return e[p]||(e[p]={onDispose:[]}),e[p]}function M(e){delete e.onDispose}function u(e){let o=d(e);o.isDisposed||(o.isDisposed=!0,o.onDispose.forEach(l),M(o))}function r(e){return!!d(e).isDisposed}function P(e,o){if(r(e))throw new Error(o||"Object has been disposed")}function t(e,o){let n=d(e);n.isDisposed?l(o):n.onDispose.push(o)}function _(e,o){t(e,u.bind(null,o))}function C(e){t(e,b.bind(null,e,A))}function j(e){t(e,b.bind(null,e,S))}function l(e){try{e()}catch(o){console.error("error occured inside a dispose handler",o.message||""+o),console.log(o)}}function b(e,o){Object.entries(e).forEach(([n,s])=>o({key:n,value:s,object:e}))}function S({key:e,object:o}){try{o[e]=void 0}catch(n){}try{delete o[e]}catch(n){}}function A({value:e}){typeof e=="object"&&u(e)}var c=h(require("rxjs")),a=Symbol("gc/rxjs");function G(e){return e[a]||(e[a]={}),e[a]}function E(e){delete e[a]}function O(e){if(r(e))return c.of(void 0);let o=G(e);if(o.observable)return o.observable;let n=new c.Subject;return o.observable=n,t(e,I.bind(null,n)),t(e,E.bind(null,e)),o.observable}function I(e){e.next(),e.complete()}function w(e,o){t(e,o.unsubscribe.bind(o))}
var c=Object.defineProperty;var u=e=>c(e,"__esModule",{value:!0});var b=(e,o)=>{u(e);for(var n in o)c(e,n,{get:o[n],enumerable:!0})};b(exports,{assertNotDisposed:()=>l,dispose:()=>r,isDisposed:()=>a,onDispose:()=>t,onDisposeChain:()=>y,onDisposeDeleteProperties:()=>P,onDisposeDisposeProperties:()=>x,onDisposeUnsubscribe:()=>g});var s=Symbol("gc");function i(e){return e[s]||(e[s]={onDispose:[]}),e[s]}function D(e){delete e.onDispose}function r(e){let o=i(e);o.isDisposed||(o.isDisposed=!0,o.onDispose.forEach(p),D(o))}function a(e){return!!i(e).isDisposed}function l(e,o){if(a(e))throw new Error(o||"Object has been disposed")}function t(e,o){let n=i(e);n.isDisposed?p(o):n.onDispose.push(o)}function y(e,o){t(e,r.bind(null,o))}function x(e){t(e,d.bind(null,e,T))}function P(e){t(e,d.bind(null,e,h))}function p(e){try{e()}catch(o){console.error("error occured inside a dispose handler",o.message||""+o),console.log(o)}}function d(e,o){Object.entries(e).forEach(([n,f])=>o({key:n,value:f,object:e}))}function h({key:e,object:o}){try{o[e]=void 0}catch(n){}try{delete o[e]}catch(n){}}function T({value:e}){typeof e=="object"&&r(e)}function g(e,o){t(e,o.unsubscribe.bind(o))}

@@ -42,2 +42,11 @@ declare type Action = () => void;

export declare function onDisposeDeleteProperties<T extends object>(object: T): void;
interface Subscription {
unsubscribe: () => void;
}
/**
* When the object is disposed, unsubscribe from the subscription
* @param object The object to be watched
* @param subscription The subscription that will be automatically unsubscribed
*/
export declare function onDisposeUnsubscribe<T extends object>(object: T, subscription: Subscription): void;
export {};

@@ -73,2 +73,5 @@ const GC_META = Symbol("gc");

}
function onDisposeUnsubscribe(object, subscription) {
onDispose(object, subscription.unsubscribe.bind(subscription));
}
export {

@@ -81,3 +84,4 @@ assertNotDisposed,

onDisposeDeleteProperties,
onDisposeDisposeProperties
onDisposeDisposeProperties,
onDisposeUnsubscribe
};
export * from "./gc";
export * from "./gc-rxjs";
export * from "./gc";
export * from "./gc-rxjs";
{
"name": "@tobes31415/dispose",
"version": "2.0.5",
"version": "3.0.0",
"description": "Dispose objects using the decorator pattern",

@@ -8,8 +8,5 @@ "main": "lib/gc-commonjs.min.js",

"types": "lib/index.d.ts",
"exports":{
"exports": {
"gc": {
"import": "./lib/gc.js"
},
"rxjs": {
"import": "./lib/gc-rxjs.js"
}

@@ -27,7 +24,6 @@ },

"prettier": "prettier --write \"src/**/*.ts\"",
"bundle-cjs": "esbuild src/index.ts --external:rxjs --minify --format=cjs --bundle --outfile=lib/gc-commonjs.min.js",
"bundle-cjs": "esbuild src/index.ts --minify --format=cjs --bundle --outfile=lib/gc-commonjs.min.js",
"bundle-esm": "esbuild src/*.ts --format=esm --outdir=lib",
"flowgen": "run-p flowgen:*",
"flowgen:gc": "flowgen flow/gc.d.ts -o lib/gc-commonjs.min.js.flow",
"flowgen:rxjs": "flowgen flow/gc-rxjs.d.ts -o lib/gc-rxjs.js.flow",
"flowgen:index": "flowgen flow/index.d.ts -o lib/index.js.flow",

@@ -82,7 +78,4 @@ "apidocs": "run-s apidocs:clean:* apidocs:typedoc apidocs:copy",

},
"peerDependencies": {
"rxjs": "^6.6.3"
},
"dependencies": {
}
}
"peerDependencies": {},
"dependencies": {}
}

@@ -128,2 +128,15 @@ type Action = () => void;

}
}
interface Subscription {
unsubscribe: () => void;
}
/**
* When the object is disposed, unsubscribe from the subscription
* @param object The object to be watched
* @param subscription The subscription that will be automatically unsubscribed
*/
export function onDisposeUnsubscribe<T extends object>(object: T, subscription: Subscription) {
onDispose(object, subscription.unsubscribe.bind(subscription));
}

@@ -1,2 +0,1 @@

export * from "./gc";
export * from "./gc-rxjs";
export * from "./gc";

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc