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 5.0.0 to 5.0.1

2

lib/gc-commonjs.min.js

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

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

@@ -1,3 +0,6 @@

type Action = () => void;
/**
* An action is any function which can be invoked synchronously and will not return any value
*/
export type Action = () => void;
/**
* Disposes an object

@@ -23,3 +26,3 @@ * @param object The object to be disposed

* @param object The object to subscribe to
* @param fnRef A callback function that will be invoked when the object is disposed
* @param action A callback function that will be invoked when the object is disposed
*/

@@ -29,6 +32,6 @@ export declare function onDispose<T extends object>(object: T, action: Action): void;

* When objectA is disposed, objectB will also be disposed
* @param objectA The object to be watched
* @param objectB The object to chain the dipose to
* @param trigger The object to be watched
* @param triggee The object to chain the dipose to
*/
export declare function onDisposeChain<T1 extends object, T2 extends object>(triger: T1, trigee: T2): void;
export declare function onDisposeChain<T1 extends object, T2 extends object>(trigger: T1, triggee: T2): void;
/**

@@ -44,3 +47,6 @@ * When the object is disposed, enumerate it's properties and call dispose on them

export declare function onDisposeDeleteProperties<T extends object>(object: T): void;
interface Subscription {
/**
* An object receipt from a call to subscribe. This object is used to unsubscribe
*/
export interface Subscription {
unsubscribe: () => void;

@@ -54,2 +60,1 @@ }

export declare function onDisposeUnsubscribe<T extends object>(object: T, subscription: Subscription): void;
export {};

@@ -38,4 +38,4 @@ const GC_META = Symbol("gc");

}
function onDisposeChain(triger, trigee) {
onDispose(triger, dispose.bind(null, trigee));
function onDisposeChain(trigger, triggee) {
onDispose(trigger, dispose.bind(null, triggee));
}

@@ -52,3 +52,6 @@ function onDisposeDisposeProperties(object) {

} catch (err) {
console.error("error occured inside a dispose handler", err.message || "" + err);
console.error(
"error occured inside a dispose handler",
err.message || "" + err
);
console.log(err);

@@ -58,3 +61,5 @@ }

function forEachProperty(object, action) {
Object.entries(object).forEach(([key, value]) => action({ key, value, object }));
Object.entries(object).forEach(
([key, value]) => action({ key, value, object })
);
}

@@ -61,0 +66,0 @@ function deleteProperty({ key, object }) {

{
"name": "@tobes31415/dispose",
"version": "5.0.0",
"version": "5.0.1",
"description": "Dispose objects using the decorator pattern",
"type": "module",
"files": ["lib"],
"files": [
"lib"
],
"main": "lib/gc-commonjs.min.js",
"module": "lib/index.js",
"types": "lib/index.d.ts",
"exports":{
"exports": {
".": {

@@ -17,27 +19,34 @@ "require": "./lib/gc-commonjs.min.js",

"scripts": {
"test": "run-s build:compile build:fix-imports:b test:mocha",
"test:mocha": "mocha bin",
"build": "run-s pre-clean:* post-clean:* test build:copy:* flowgen:* bundle-cjs bundle-esm build:fix-imports:l build:remove-tests post-clean:*",
"build:compile": "tsc --declaration",
"clean": "run-p pre-clean post-clean",
"pre-clean": "run-p pre-clean:*",
"post-clean": "run-p post-clean:*",
"pre-clean:docs": "del-cli docs",
"pre-clean:lib": "del-cli lib",
"post-clean:bin": "del-cli bin",
"post-clean:docs_bin": "del-cli docs_bin",
"post-clean:flow": "del-cli flow",
"assemble": "run-s build-and-test bundle type-defs apidocs post-clean",
"build": "run-s clean build:tsc build:fix-imports:b",
"build-and-test": "run-s build test:vitest",
"test:vitest": "vitest run bin",
"build:tsc": "tsc --declaration",
"build:fix-imports:b": "fix-tsc-esnext-imports bin",
"build:fix-imports:l": "fix-tsc-esnext-imports lib",
"build:copy:flow": "cpy \"bin/**/!(*.test){*.js,*.d.ts}\" \"flow\"",
"build:copy:dts": "cpy \"bin/**/*.d.ts\" \"lib\"",
"build:remove-tests": "del-cli lib/*test*",
"prettier": "prettier --write \"src/**/*.ts\"",
"bundle": "run-s bundle-cjs bundle-esm build:fix-imports:l",
"bundle-cjs": "esbuild src/index.ts --minify --format=cjs --bundle --outfile=lib/gc-commonjs.min.js",
"bundle-esm": "esbuild src/index.ts src/gc.ts --format=esm --outdir=lib",
"type-defs": "run-s copy:dts flowgen",
"copy:dts": "cpy \"bin/**/!(*.test).d.ts\" \"lib\"",
"flowgen": "run-p flowgen:*",
"flowgen:gc": "flowgen flow/gc.d.ts -o lib/gc-commonjs.min.js.flow",
"flowgen:index": "flowgen flow/index.d.ts -o lib/index.js.flow",
"apidocs": "run-s apidocs:clean:* apidocs:typedoc apidocs:copy",
"apidocs:clean:docs": "del-cli docs",
"apidocs:clean:docsbin": "del-cli docs_bin",
"apidocs:typedoc": "typedoc --out docs_bin src/index.ts --excludePrivate --excludeExternals ",
"apidocs:copy": "cpy docs_bin/modules.md docs --flat",
"pre-clean:docs": "del-cli docs",
"pre-clean:lib": "del-cli lib",
"post-clean:bin": "del-cli bin",
"post-clean:docs_bin": "del-cli docs_bin",
"post-clean:flow": "del-cli flow"
"flowgen:gc": "flowgen bin/gc.d.ts -o lib/gc-commonjs.min.js.flow --add-flow-header",
"flowgen:index": "flowgen bin/index.d.ts -o lib/index.js.flow --add-flow-header",
"apidocs": "run-s apidocs:clean apidocs:typedoc",
"apidocs:clean": "del-cli docs",
"apidocs:typedoc": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts --excludePrivate --excludeExternals ",
"": "",
"prettier": "prettier --write ./src/*",
"eslint": "eslint --fix ./src/*",
"assert-prettier": "prettier --check ./src/*",
"assert-eslint": "eslint ./src/*",
"pre-commit": "run-p assert-prettier assert-eslint"
},

@@ -58,24 +67,19 @@ "keywords": [

"devDependencies": {
"@types/expect.js": "^0.3.29",
"@types/mocha": "^10.0.1",
"@typescript-eslint/eslint-plugin": "^5.59.5",
"@typescript-eslint/parser": "^5.59.5",
"cpy-cli": "^4.2.0",
"del-cli": "^5.0.0",
"esbuild": "^0.17.18",
"eslint": "^8.40.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-prettier": "^4.2.1",
"expect.js": "^0.3.1",
"@eslint/js": "^9.2.0",
"cpy-cli": "^5.0.0",
"del-cli": "^5.1.0",
"esbuild": "^0.20.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"fix-tsc-esnext-imports": "^1.0.5",
"flowgen": "^1.21.0",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"typedoc": "^0.24.7",
"typedoc-plugin-markdown": "^3.15.3",
"typescript": "~5.0.4"
},
"peerDependencies": {},
"dependencies": {}
"globals": "^15.1.0",
"npm-run-all2": "^6.1.2",
"prettier": "^3.2.5",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^4.0.0",
"typescript": "^5.4.5",
"typescript-eslint": "^7.8.0",
"vitest": "^1.6.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

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