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

2

lib/gc-commonjs.min.js

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

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))}
"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))}

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

declare type Action = () => void;
type Action = () => void;
/**

@@ -3,0 +3,0 @@ * Disposes an object

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

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

@@ -69,3 +69,3 @@ object[key] = void 0;

}
function disposeProperty({value}) {
function disposeProperty({ value }) {
if (typeof value === "object") {

@@ -72,0 +72,0 @@ dispose(value);

export * from "./gc";

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

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

@@ -15,7 +17,8 @@ "require": "./lib/gc-commonjs.min.js",

"scripts": {
"test": "run-s build:compile test:jest",
"test:jest": "jest bin",
"build": "run-s pre-clean:* post-clean:* test build:copy:* flowgen:* apidocs bundle-cjs bundle-esm build:remove-tests post-clean:*",
"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",
"build:fix-imports": "fix-tsc-esnext-imports lib",
"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\"",

@@ -34,3 +37,3 @@ "build:copy:dts": "cpy \"bin/**/*.d.ts\" \"lib\"",

"apidocs:typedoc": "typedoc --out docs_bin src/index.ts --excludePrivate --excludeExternals ",
"apidocs:copy": "cpy docs_bin/modules.md docs",
"apidocs:copy": "cpy docs_bin/modules.md docs --flat",
"pre-clean:docs": "del-cli docs",

@@ -56,24 +59,21 @@ "pre-clean:lib": "del-cli lib",

"devDependencies": {
"@babel/plugin-proposal-export-default-from": "^7.12.1",
"@babel/preset-env": "^7.12.11",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"babel-jest": "^25.5.1",
"cpy-cli": "^3.1.1",
"del-cli": "^3.0.1",
"esbuild": "^0.8.33",
"eslint": "^6.8.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-prettier": "^3.3.1",
"@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",
"fix-tsc-esnext-imports": "^1.0.5",
"flowgen": "^1.13.0",
"jest": "^25.5.4",
"flowgen": "^1.21.0",
"mocha": "^10.2.0",
"npm-run-all": "^4.1.5",
"prettier": "^1.19.1",
"replace": "^1.2.0",
"typedoc": "^0.20.16",
"typedoc-plugin-markdown": "^3.4.1",
"typescript": "~4.0.2",
"uglify-es": "^3.3.9",
"@types/jest": "^26.0.20"
"prettier": "^2.8.8",
"typedoc": "^0.24.7",
"typedoc-plugin-markdown": "^3.15.3",
"typescript": "~5.0.4"
},

@@ -80,0 +80,0 @@ "peerDependencies": {},

@@ -9,12 +9,16 @@ # Dispose

# Installation
npm install --save @tobes31415/dispose
```
npm install --save @tobes31415/dispose
```
# Basic Useage
import { onDispose, dispose } from "@tobes31415/dispose"
onDispose(foo, () => {
//release resources
//disconnect from servers, etc
});
dispose(foo);
```
import { onDispose, dispose } from "@tobes31415/dispose"
onDispose(foo, () => {
//release resources
//disconnect from servers, etc
});
dispose(foo);
```

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