From f0dbae1853519ce1f2db49773f7e23c50e3b922a Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 16:29:32 -0700 Subject: [PATCH 001/151] Refreshed for next publish. --- .github/workflows/publish.yml | 34 +++++++++++-------- .../dictionaries/{essence.xml => shared.xml} | 2 +- LICENSE | 4 +-- dist/ObjectDisposedException.d.ts | 1 - dist/ObjectDisposedException.js | 1 - dist/ObjectDisposedException.js.map | 2 +- package.json | 1 + 7 files changed, 25 insertions(+), 20 deletions(-) rename .idea/dictionaries/{essence.xml => shared.xml} (82%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 0190951..c178fba 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,19 +1,25 @@ -name: Publish - +name: npm-publish on: - release: - types: [published] - + push: + branches: + - master # Change this to your default branch jobs: - build: + npm-publish: + name: npm-publish runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - uses: actions/setup-node@v1 + - name: Checkout repository + uses: actions/checkout@master + - name: Set up Node.js + uses: actions/setup-node@master with: - node-version: 12 - registry-url: https://registry.npmjs.org/ - - run: yarn install - - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + node-version: 10.0.0 + - name: Publish if version has been updated + uses: pascalgn/npm-publish-action@4f4bf159e299f65d21cd1cbd96fc5d53228036df + with: # All of theses inputs are optional + tag_name: "v%s" + tag_message: "v%s" + commit_pattern: "^Release (\\S+)" + env: # More info about the environment variables in the README + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated + NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings diff --git a/.idea/dictionaries/essence.xml b/.idea/dictionaries/shared.xml similarity index 82% rename from .idea/dictionaries/essence.xml rename to .idea/dictionaries/shared.xml index acdbffe..d504af1 100644 --- a/.idea/dictionaries/essence.xml +++ b/.idea/dictionaries/shared.xml @@ -1,5 +1,5 @@ - + noninfringement tsdotnet diff --git a/LICENSE b/LICENSE index 830236d..3419fd4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -The MIT License (MIT) +MIT License -Copyright (c) 2020 Oren Ferrari (electricessence) +Copyright (c) 2020 electricessence (Oren F.) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dist/ObjectDisposedException.d.ts b/dist/ObjectDisposedException.d.ts index 52ac6aa..d3a7f94 100644 --- a/dist/ObjectDisposedException.d.ts +++ b/dist/ObjectDisposedException.d.ts @@ -1,7 +1,6 @@ /*! * @author electricessence / https://github.com/electricessence/ * Licensing: MIT - * Based upon: https://msdn.microsoft.com/en-us/library/System.Exception%28v=vs.110%29.aspx */ import IDisposableAware from './IDisposableAware'; export default class ObjectDisposedException extends Error { diff --git a/dist/ObjectDisposedException.js b/dist/ObjectDisposedException.js index f5a375e..4866bb6 100644 --- a/dist/ObjectDisposedException.js +++ b/dist/ObjectDisposedException.js @@ -1,7 +1,6 @@ /*! * @author electricessence / https://github.com/electricessence/ * Licensing: MIT - * Based upon: https://msdn.microsoft.com/en-us/library/System.Exception%28v=vs.110%29.aspx */ export default class ObjectDisposedException extends Error { constructor(objectName, message) { diff --git a/dist/ObjectDisposedException.js.map b/dist/ObjectDisposedException.js.map index b9b714b..029fa10 100644 --- a/dist/ObjectDisposedException.js.map +++ b/dist/ObjectDisposedException.js.map @@ -1 +1 @@ -{"version":3,"file":"ObjectDisposedException.js","sourceRoot":"","sources":["../src/ObjectDisposedException.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,KAAK;IAGzD,YAAY,UAAkB,EAAE,OAAgB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,UAA4B,EAAE,UAAkB,EAAE,OAAgB;QACxF,IAAI,UAAU,CAAC,WAAW;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACb,CAAC;CACD"} \ No newline at end of file +{"version":3,"file":"ObjectDisposedException.js","sourceRoot":"","sources":["../src/ObjectDisposedException.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,KAAK;IAGzD,YAAY,UAAkB,EAAE,OAAgB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,UAA4B,EAAE,UAAkB,EAAE,OAAgB;QACxF,IAAI,UAAU,CAAC,WAAW;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACb,CAAC;CACD"} \ No newline at end of file diff --git a/package.json b/package.json index e08d737..cbef4d0 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "bump": "npm version patch", "format": "prettier --write \"src/**/*.ts\"", "lint": "eslint src/**/*.ts", + "precommit": "npm run format && npm run lint && npm run build", "prepublishOnly": "npm run build && npm run lint", "preversion": "npm run lint", "postversion": "git push && git push --tags" From f34f01b5f18a41157301f17bcc52bca59ebc846a Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 16:31:01 -0700 Subject: [PATCH 002/151] Allow for shared dictionary. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 0ee250e..6adf739 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ # Nodejs node_modules +.idea/dictionaries/* +!.idea/dictionaries/shared.xml From b275c9ed2b7b95a1b3a8632602904c4ac79ab597 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 16:31:41 -0700 Subject: [PATCH 003/151] 1.0.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6273735..d6da995 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index cbef4d0..e75e885 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.1", + "version": "1.0.2", "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", "author": "electricessence", "license": "MIT", From 591ae6b03081154eab268ee263fc1c0cf141c21a Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 16:34:06 -0700 Subject: [PATCH 004/151] 1.0.3 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index d6da995..7f0fb27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e75e885..44a7fec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.2", + "version": "1.0.3", "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", "author": "electricessence", "license": "MIT", From 5571a262f7ce96079df5e816d7ccfb137fd06906 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 16:39:04 -0700 Subject: [PATCH 005/151] Reformatted package.json --- package.json | 100 +++++++++++++++++++++++++-------------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/package.json b/package.json index 44a7fec..8e5893e 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,52 @@ { - "name": "@tsdotnet/disposable", - "version": "1.0.3", - "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", - "author": "electricessence", - "license": "MIT", - "types": "dist/index.d.ts", - "main": "dist/index.js", - "keywords": [ - "dispose", - "disposal", - "disposable", - "IDisposable", - "DisposableBase", - "ObjectDisposedException" - ], - "scripts": { - "clean": "rimraf dist/*", - "build": "npm run clean && copyfiles -u 1 src/**/*.d.ts dist && tsc", - "bump": "npm version patch", - "format": "prettier --write \"src/**/*.ts\"", - "lint": "eslint src/**/*.ts", - "precommit": "npm run format && npm run lint && npm run build", - "prepublishOnly": "npm run build && npm run lint", - "preversion": "npm run lint", - "postversion": "git push && git push --tags" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/tsdotnet/disposable.git" - }, - "bugs": { - "url": "https://github.com/tsdotnet/disposable/issues" - }, - "homepage": "https://github.com/tsdotnet/disposable#readme", - "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.30.0", - "@typescript-eslint/parser": "^2.30.0", - "copyfiles": "^2.2.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.11.0", - "eslint-config-standard": "^14.1.1", - "eslint-plugin-import": "^2.20.2", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-standard": "^4.0.1", - "prettier": "^2.0.5", - "rimraf": "^3.0.2", - "ts-node": "^8.9.0", - "typescript": "^3.8.3" - } + "name": "@tsdotnet/disposable", + "version": "1.0.3", + "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", + "author": "electricessence", + "license": "MIT", + "types": "dist/index.d.ts", + "main": "dist/index.js", + "keywords": [ + "dispose", + "disposal", + "disposable", + "IDisposable", + "DisposableBase", + "ObjectDisposedException" + ], + "scripts": { + "clean": "rimraf dist/*", + "build": "npm run clean && copyfiles -u 1 src/**/*.d.ts dist && tsc", + "bump": "npm version patch", + "format": "prettier --write \"src/**/*.ts\"", + "lint": "eslint src/**/*.ts", + "precommit": "npm run format && npm run lint && npm run build", + "prepublishOnly": "npm run build && npm run lint", + "preversion": "npm run lint", + "postversion": "git push && git push --tags" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/tsdotnet/disposable.git" + }, + "bugs": { + "url": "https://github.com/tsdotnet/disposable/issues" + }, + "homepage": "https://github.com/tsdotnet/disposable#readme", + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^2.30.0", + "@typescript-eslint/parser": "^2.30.0", + "copyfiles": "^2.2.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.11.0", + "eslint-config-standard": "^14.1.1", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.1", + "prettier": "^2.0.5", + "rimraf": "^3.0.2", + "ts-node": "^8.9.0", + "typescript": "^3.8.3" + } } From 2731bd74b7ae119d71d7d596063df322d062fb04 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 16:43:36 -0700 Subject: [PATCH 006/151] Standardized JSON formatting to 2 spaces. --- .eslintrc.json | 66 +++++++++++------------ .idea/codeStyles/Project.xml | 4 +- package.json | 100 +++++++++++++++++------------------ 3 files changed, 85 insertions(+), 85 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 0c3b134..ecedff7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,36 +1,36 @@ { - "env": { - "browser": true, - "es6": true, - "node": true - }, - "extends": [ - "standard" + "env": { + "browser": true, + "es6": true, + "node": true + }, + "extends": [ + "standard" + ], + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": "error", + "@typescript-eslint/semi": "error", + "semi": "off", + "no-tabs": "off", + "indent": [ + "error", + "tab" ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "no-unused-vars": "off", - "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/semi": "error", - "semi": "off", - "no-tabs": "off", - "indent": [ - "error", - "tab" - ], - "space-before-function-paren": "off", - "no-inner-declarations": "off", - "no-redeclare": "off" - } + "space-before-function-paren": "off", + "no-inner-declarations": "off", + "no-redeclare": "off" + } } diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index db01684..620a6e1 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -24,8 +24,8 @@ - diff --git a/package.json b/package.json index 8e5893e..44a7fec 100644 --- a/package.json +++ b/package.json @@ -1,52 +1,52 @@ { - "name": "@tsdotnet/disposable", - "version": "1.0.3", - "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", - "author": "electricessence", - "license": "MIT", - "types": "dist/index.d.ts", - "main": "dist/index.js", - "keywords": [ - "dispose", - "disposal", - "disposable", - "IDisposable", - "DisposableBase", - "ObjectDisposedException" - ], - "scripts": { - "clean": "rimraf dist/*", - "build": "npm run clean && copyfiles -u 1 src/**/*.d.ts dist && tsc", - "bump": "npm version patch", - "format": "prettier --write \"src/**/*.ts\"", - "lint": "eslint src/**/*.ts", - "precommit": "npm run format && npm run lint && npm run build", - "prepublishOnly": "npm run build && npm run lint", - "preversion": "npm run lint", - "postversion": "git push && git push --tags" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/tsdotnet/disposable.git" - }, - "bugs": { - "url": "https://github.com/tsdotnet/disposable/issues" - }, - "homepage": "https://github.com/tsdotnet/disposable#readme", - "devDependencies": { - "@typescript-eslint/eslint-plugin": "^2.30.0", - "@typescript-eslint/parser": "^2.30.0", - "copyfiles": "^2.2.0", - "eslint": "^6.8.0", - "eslint-config-prettier": "^6.11.0", - "eslint-config-standard": "^14.1.1", - "eslint-plugin-import": "^2.20.2", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-standard": "^4.0.1", - "prettier": "^2.0.5", - "rimraf": "^3.0.2", - "ts-node": "^8.9.0", - "typescript": "^3.8.3" - } + "name": "@tsdotnet/disposable", + "version": "1.0.3", + "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", + "author": "electricessence", + "license": "MIT", + "types": "dist/index.d.ts", + "main": "dist/index.js", + "keywords": [ + "dispose", + "disposal", + "disposable", + "IDisposable", + "DisposableBase", + "ObjectDisposedException" + ], + "scripts": { + "clean": "rimraf dist/*", + "build": "npm run clean && copyfiles -u 1 src/**/*.d.ts dist && tsc", + "bump": "npm version patch", + "format": "prettier --write \"src/**/*.ts\"", + "lint": "eslint src/**/*.ts", + "precommit": "npm run format && npm run lint && npm run build", + "prepublishOnly": "npm run build && npm run lint", + "preversion": "npm run lint", + "postversion": "git push && git push --tags" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/tsdotnet/disposable.git" + }, + "bugs": { + "url": "https://github.com/tsdotnet/disposable/issues" + }, + "homepage": "https://github.com/tsdotnet/disposable#readme", + "devDependencies": { + "@typescript-eslint/eslint-plugin": "^2.30.0", + "@typescript-eslint/parser": "^2.30.0", + "copyfiles": "^2.2.0", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.11.0", + "eslint-config-standard": "^14.1.1", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-standard": "^4.0.1", + "prettier": "^2.0.5", + "rimraf": "^3.0.2", + "ts-node": "^8.9.0", + "typescript": "^3.8.3" + } } From 8530062d3bdeb51f4724efcc4b24a6d1b0576793 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 16:44:48 -0700 Subject: [PATCH 007/151] 1.0.4 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f0fb27..8e89f4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 44a7fec..2ceecdb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.3", + "version": "1.0.4", "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", "author": "electricessence", "license": "MIT", From 4b86b592943a5ab1172ab023e18abd6cd6a542fa Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 17:05:23 -0700 Subject: [PATCH 008/151] Standardized JSON formatting to 2 spaces. --- .eslintrc.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index ecedff7..ecdd373 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -20,10 +20,14 @@ "@typescript-eslint" ], "rules": { + "no-dupe-class-members": "off", + "no-useless-constructor": "off", "no-unused-vars": "off", + "semi": "off", + "@typescript-eslint/no-dupe-class-members": "error", "@typescript-eslint/no-unused-vars": "error", + "@typescript-eslint/no-useless-constructor": "error", "@typescript-eslint/semi": "error", - "semi": "off", "no-tabs": "off", "indent": [ "error", @@ -31,6 +35,7 @@ ], "space-before-function-paren": "off", "no-inner-declarations": "off", - "no-redeclare": "off" + "no-redeclare": "off", + "one-var": "off" } } From f2ce5e81344af5b46a25b8c8619b166dde650ce5 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 17:05:39 -0700 Subject: [PATCH 009/151] 1.0.5 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8e89f4a..5d0c45d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.4", + "version": "1.0.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2ceecdb..869457d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.4", + "version": "1.0.5", "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", "author": "electricessence", "license": "MIT", From b56a1829add3e93428d04e9e2a723e3701a01226 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 17:06:34 -0700 Subject: [PATCH 010/151] Cleanup unused inspection ignore. --- dist/DisposableBase.js | 1 - dist/DisposableBase.js.map | 2 +- src/DisposableBase.ts | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/dist/DisposableBase.js b/dist/DisposableBase.js index 3d62eb3..5583500 100644 --- a/dist/DisposableBase.js +++ b/dist/DisposableBase.js @@ -5,7 +5,6 @@ */ import ObjectDisposedException from './ObjectDisposedException'; class DisposableBase { - // eslint-disable-next-line no-useless-constructor constructor(_disposableObjectName, __finalizer) { this._disposableObjectName = _disposableObjectName; this.__finalizer = __finalizer; diff --git a/dist/DisposableBase.js.map b/dist/DisposableBase.js.map index 701260f..8cdea4f 100644 --- a/dist/DisposableBase.js.map +++ b/dist/DisposableBase.js.map @@ -1 +1 @@ -{"version":3,"file":"DisposableBase.js","sourceRoot":"","sources":["../src/DisposableBase.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC;;;GAGG;AAGH,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,MAAe,cAAc;IAC5B,kDAAkD;IAClD,YAAgC,qBAA6B,EAAmB,WAA+B;QAA/E,0BAAqB,GAArB,qBAAqB,CAAQ;QAAmB,gBAAW,GAAX,WAAW,CAAoB;QAEvG,kBAAa,GAAY,KAAK,CAAC;IAF2E,CAAC;IAInH,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACO,eAAe,CAAC,OAAgB,EAAE,aAAqB,IAAI,CAAC,qBAAqB;QAC1F,IAAI,IAAI,CAAC,aAAa;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC;IACb,CAAC;IAED,mEAAmE;IACnE,OAAO;QACN,MAAM,CAAC,GAAG,IAAI,CAAC;QACf,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE;YACrB,uEAAuE;YACvE,8EAA8E;YAC9E,CAAC,CAAC,aAAa,GAAG,IAAI,CAAC;YACvB,IAAI;gBACH,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,sBAAsB;aACtC;oBAAS;gBACT,IAAI,CAAC,CAAC,WAAW,EAAE;oBAClB,uBAAuB;oBACvB,CAAC,CAAC,WAAW,EAAE,CAAC;oBACf,CAAS,CAAC,WAAW,GAAG,SAAS,CAAC;iBACnC;aACD;SACD;IACF,CAAC;IAED,6BAA6B;IAC7B,oCAAoC;IACpC;;;;OAIG;IACO,UAAU,KAAU,CAAC;CAC/B;AAED,eAAe,cAAc,CAAC"} \ No newline at end of file +{"version":3,"file":"DisposableBase.js","sourceRoot":"","sources":["../src/DisposableBase.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC;;;GAGG;AAGH,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,MAAe,cAAc;IAC5B,YAAgC,qBAA6B,EAAmB,WAA+B;QAA/E,0BAAqB,GAArB,qBAAqB,CAAQ;QAAmB,gBAAW,GAAX,WAAW,CAAoB;QAEvG,kBAAa,GAAY,KAAK,CAAC;IAF2E,CAAC;IAInH,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACO,eAAe,CAAC,OAAgB,EAAE,aAAqB,IAAI,CAAC,qBAAqB;QAC1F,IAAI,IAAI,CAAC,aAAa;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC;IACb,CAAC;IAED,mEAAmE;IACnE,OAAO;QACN,MAAM,CAAC,GAAG,IAAI,CAAC;QACf,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE;YACrB,uEAAuE;YACvE,8EAA8E;YAC9E,CAAC,CAAC,aAAa,GAAG,IAAI,CAAC;YACvB,IAAI;gBACH,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,sBAAsB;aACtC;oBAAS;gBACT,IAAI,CAAC,CAAC,WAAW,EAAE;oBAClB,uBAAuB;oBACvB,CAAC,CAAC,WAAW,EAAE,CAAC;oBACf,CAAS,CAAC,WAAW,GAAG,SAAS,CAAC;iBACnC;aACD;SACD;IACF,CAAC;IAED,6BAA6B;IAC7B,oCAAoC;IACpC;;;;OAIG;IACO,UAAU,KAAU,CAAC;CAC/B;AAED,eAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/src/DisposableBase.ts b/src/DisposableBase.ts index ece0541..54f1f34 100644 --- a/src/DisposableBase.ts +++ b/src/DisposableBase.ts @@ -8,7 +8,6 @@ import IDisposableAware from './IDisposableAware'; import ObjectDisposedException from './ObjectDisposedException'; abstract class DisposableBase implements IDisposableAware { - // eslint-disable-next-line no-useless-constructor protected constructor(protected _disposableObjectName: string, private readonly __finalizer?: () => void | null) {} private __wasDisposed: boolean = false; From 62f4e9c3fb6fb14fbacfd02a13c443168b6cd9c0 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 17:06:54 -0700 Subject: [PATCH 011/151] 1.0.6 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5d0c45d..97cb0ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 869457d..c70d338 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.5", + "version": "1.0.6", "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", "author": "electricessence", "license": "MIT", From 54280795ab0f73a3e61dd6c24b401a758bbf8c92 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 18:21:52 -0700 Subject: [PATCH 012/151] Removed prettier. Revised interface names. --- .eslintrc.json | 60 ++++------ .idea/codeStyles/Project.xml | 113 +++++++++++++----- .prettierrc | 7 -- dist/{IDisposable.d.ts => Disposable.d.ts} | 5 +- .../DisposableAware.d.ts | 6 +- dist/DisposableBase.d.ts | 8 +- dist/DisposableBase.js | 36 +++--- dist/DisposableBase.js.map | 2 +- dist/ObjectDisposedException.d.ts | 4 +- dist/ObjectDisposedException.js.map | 2 +- dist/dispose.d.ts | 6 +- dist/dispose.js | 1 + dist/dispose.js.map | 2 +- dist/index.d.ts | 6 +- dist/index.js.map | 2 +- package-lock.json | 35 +----- package.json | 9 +- src/{IDisposable.d.ts => Disposable.d.ts} | 5 +- .../DisposableAware.d.ts | 6 +- src/DisposableBase.ts | 71 ++++++----- src/ObjectDisposedException.ts | 17 ++- src/dispose.ts | 92 ++++++++------ src/index.ts | 6 +- 23 files changed, 278 insertions(+), 223 deletions(-) delete mode 100644 .prettierrc rename dist/{IDisposable.d.ts => Disposable.d.ts} (79%) rename src/IDisposableAware.d.ts => dist/DisposableAware.d.ts (54%) rename src/{IDisposable.d.ts => Disposable.d.ts} (79%) rename dist/IDisposableAware.d.ts => src/DisposableAware.d.ts (54%) diff --git a/.eslintrc.json b/.eslintrc.json index ecdd373..ffebbed 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,41 +1,25 @@ { - "env": { - "browser": true, - "es6": true, - "node": true - }, - "extends": [ - "standard" - ], - "globals": { - "Atomics": "readonly", - "SharedArrayBuffer": "readonly" - }, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module" - }, - "plugins": [ - "@typescript-eslint" - ], - "rules": { - "no-dupe-class-members": "off", - "no-useless-constructor": "off", - "no-unused-vars": "off", - "semi": "off", - "@typescript-eslint/no-dupe-class-members": "error", - "@typescript-eslint/no-unused-vars": "error", - "@typescript-eslint/no-useless-constructor": "error", - "@typescript-eslint/semi": "error", - "no-tabs": "off", - "indent": [ - "error", - "tab" + "env": { + "browser": true, + "es6": true, + "node": true + }, + "extends": [ + "typescript" ], - "space-before-function-paren": "off", - "no-inner-declarations": "off", - "no-redeclare": "off", - "one-var": "off" - } + "globals": { + "Atomics": "readonly", + "SharedArrayBuffer": "readonly" + }, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/no-inferrable-types": "off" + } } diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 620a6e1..a4ce7cd 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -1,64 +1,123 @@ + - - - diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index e814f2f..0000000 --- a/.prettierrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "printWidth": 120, - "singleQuote": true, - "useTabs": true, - "tabWidth": 4, - "arrowParens": "avoid" -} diff --git a/dist/IDisposable.d.ts b/dist/Disposable.d.ts similarity index 79% rename from dist/IDisposable.d.ts rename to dist/Disposable.d.ts index 3187687..1828e5a 100644 --- a/dist/IDisposable.d.ts +++ b/dist/Disposable.d.ts @@ -4,6 +4,7 @@ */ // Allows for simple type checking that includes types that don't declare themselves as IDisposable but do have a dispose() method. -export default interface IDisposable { - dispose(): void; +export default interface Disposable +{ + dispose (): void; } diff --git a/src/IDisposableAware.d.ts b/dist/DisposableAware.d.ts similarity index 54% rename from src/IDisposableAware.d.ts rename to dist/DisposableAware.d.ts index 7102823..98e385e 100644 --- a/src/IDisposableAware.d.ts +++ b/dist/DisposableAware.d.ts @@ -3,8 +3,10 @@ * Licensing: MIT */ -import IDisposable from './IDisposable'; +import Disposable from './Disposable'; -export default interface IDisposableAware extends IDisposable { +export default interface DisposableAware + extends Disposable +{ readonly wasDisposed: boolean; } diff --git a/dist/DisposableBase.d.ts b/dist/DisposableBase.d.ts index b4c47ac..2dd004d 100644 --- a/dist/DisposableBase.d.ts +++ b/dist/DisposableBase.d.ts @@ -2,20 +2,20 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT */ -import IDisposableAware from './IDisposableAware'; -declare abstract class DisposableBase implements IDisposableAware { +import DisposableAware from './DisposableAware'; +declare abstract class DisposableBase implements DisposableAware { protected _disposableObjectName: string; private readonly __finalizer?; - protected constructor(_disposableObjectName: string, __finalizer?: (() => void | null) | undefined); private __wasDisposed; + protected constructor(_disposableObjectName: string, __finalizer?: (() => void | null) | undefined); get wasDisposed(): boolean; + dispose(): void; /** * Utility for throwing exception when this object is accessed. * @param message * @param objectName Optional object name override. */ protected throwIfDisposed(message?: string, objectName?: string): true | never; - dispose(): void; /** * Is called when this object is disposed. Should not be called directly. * Override this method to handle disposal. diff --git a/dist/DisposableBase.js b/dist/DisposableBase.js index 5583500..aba1b44 100644 --- a/dist/DisposableBase.js +++ b/dist/DisposableBase.js @@ -1,4 +1,3 @@ -/* tslint:disable:variable-name */ /*! * @author electricessence / https://github.com/electricessence/ * Licensing: MIT @@ -13,37 +12,36 @@ class DisposableBase { get wasDisposed() { return this.__wasDisposed; } - /** - * Utility for throwing exception when this object is accessed. - * @param message - * @param objectName Optional object name override. - */ - throwIfDisposed(message, objectName = this._disposableObjectName) { - if (this.__wasDisposed) - throw new ObjectDisposedException(objectName); - return true; - } // NOTE: Do not override this method. Override _onDispose instead. dispose() { - const _ = this; - if (!_.__wasDisposed) { + if (!this.__wasDisposed) { // Preemptively set wasDisposed in order to prevent repeated disposing. // NOTE: in true multi-threaded scenarios, this would need to be synchronized. - _.__wasDisposed = true; + this.__wasDisposed = true; try { - _._onDispose(); // Protected override. + this._onDispose(); // Protected override. } finally { - if (_.__finalizer) { + if (this.__finalizer) { // Private finalizer... - _.__finalizer(); - _.__finalizer = undefined; + this.__finalizer(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + this.__finalizer = undefined; } } } } + /** + * Utility for throwing exception when this object is accessed. + * @param message + * @param objectName Optional object name override. + */ + throwIfDisposed(message, objectName = this._disposableObjectName) { + if (this.__wasDisposed) + throw new ObjectDisposedException(objectName); + return true; + } // Placeholder for overrides. - // tslint:disable-next-line:no-empty /** * Is called when this object is disposed. Should not be called directly. * Override this method to handle disposal. diff --git a/dist/DisposableBase.js.map b/dist/DisposableBase.js.map index 8cdea4f..8dc1c87 100644 --- a/dist/DisposableBase.js.map +++ b/dist/DisposableBase.js.map @@ -1 +1 @@ -{"version":3,"file":"DisposableBase.js","sourceRoot":"","sources":["../src/DisposableBase.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC;;;GAGG;AAGH,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,MAAe,cAAc;IAC5B,YAAgC,qBAA6B,EAAmB,WAA+B;QAA/E,0BAAqB,GAArB,qBAAqB,CAAQ;QAAmB,gBAAW,GAAX,WAAW,CAAoB;QAEvG,kBAAa,GAAY,KAAK,CAAC;IAF2E,CAAC;IAInH,IAAI,WAAW;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACO,eAAe,CAAC,OAAgB,EAAE,aAAqB,IAAI,CAAC,qBAAqB;QAC1F,IAAI,IAAI,CAAC,aAAa;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,CAAC;QACtE,OAAO,IAAI,CAAC;IACb,CAAC;IAED,mEAAmE;IACnE,OAAO;QACN,MAAM,CAAC,GAAG,IAAI,CAAC;QACf,IAAI,CAAC,CAAC,CAAC,aAAa,EAAE;YACrB,uEAAuE;YACvE,8EAA8E;YAC9E,CAAC,CAAC,aAAa,GAAG,IAAI,CAAC;YACvB,IAAI;gBACH,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,sBAAsB;aACtC;oBAAS;gBACT,IAAI,CAAC,CAAC,WAAW,EAAE;oBAClB,uBAAuB;oBACvB,CAAC,CAAC,WAAW,EAAE,CAAC;oBACf,CAAS,CAAC,WAAW,GAAG,SAAS,CAAC;iBACnC;aACD;SACD;IACF,CAAC;IAED,6BAA6B;IAC7B,oCAAoC;IACpC;;;;OAIG;IACO,UAAU,KAAU,CAAC;CAC/B;AAED,eAAe,cAAc,CAAC"} \ No newline at end of file +{"version":3,"file":"DisposableBase.js","sourceRoot":"","sources":["../src/DisposableBase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAEhE,MAAe,cAAc;IAK5B,YACW,qBAA6B,EACtB,WAA+B;QADtC,0BAAqB,GAArB,qBAAqB,CAAQ;QACtB,gBAAW,GAAX,WAAW,CAAoB;QAJzC,kBAAa,GAAY,KAAK,CAAC;IAKtC,CAAC;IAEF,IAAI,WAAW;QAEd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B,CAAC;IAED,mEAAmE;IACnE,OAAO;QAEN,IAAG,CAAC,IAAI,CAAC,aAAa,EACtB;YACC,uEAAuE;YACvE,8EAA8E;YAC9E,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC1B,IACA;gBACC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,sBAAsB;aACzC;oBAED;gBACC,IAAG,IAAI,CAAC,WAAW,EACnB;oBACC,uBAAuB;oBACvB,IAAI,CAAC,WAAW,EAAE,CAAC;oBACnB,8DAA8D;oBAC7D,IAAY,CAAC,WAAW,GAAG,SAAS,CAAC;iBACtC;aACD;SACD;IACF,CAAC;IAED;;;;OAIG;IACO,eAAe,CACxB,OAAgB,EAChB,aAAqB,IAAI,CAAC,qBAAqB;QAE/C,IAAG,IAAI,CAAC,aAAa;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;IACb,CAAC;IAED,6BAA6B;IAC7B;;;;OAIG;IACO,UAAU,KAEnB,CAAC;CACF;AAED,eAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/dist/ObjectDisposedException.d.ts b/dist/ObjectDisposedException.d.ts index d3a7f94..38e71d1 100644 --- a/dist/ObjectDisposedException.d.ts +++ b/dist/ObjectDisposedException.d.ts @@ -2,9 +2,9 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT */ -import IDisposableAware from './IDisposableAware'; +import DisposableAware from './DisposableAware'; export default class ObjectDisposedException extends Error { readonly objectName: string; constructor(objectName: string, message?: string); - static throwIfDisposed(disposable: IDisposableAware, objectName: string, message?: string): true | never; + static throwIfDisposed(disposable: DisposableAware, objectName: string, message?: string): true | never; } diff --git a/dist/ObjectDisposedException.js.map b/dist/ObjectDisposedException.js.map index 029fa10..43b2afa 100644 --- a/dist/ObjectDisposedException.js.map +++ b/dist/ObjectDisposedException.js.map @@ -1 +1 @@ -{"version":3,"file":"ObjectDisposedException.js","sourceRoot":"","sources":["../src/ObjectDisposedException.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,KAAK;IAGzD,YAAY,UAAkB,EAAE,OAAgB;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,UAA4B,EAAE,UAAkB,EAAE,OAAgB;QACxF,IAAI,UAAU,CAAC,WAAW;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACnF,OAAO,IAAI,CAAC;IACb,CAAC;CACD"} \ No newline at end of file +{"version":3,"file":"ObjectDisposedException.js","sourceRoot":"","sources":["../src/ObjectDisposedException.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,CAAC,OAAO,OAAO,uBACpB,SAAQ,KAAK;IAIb,YAAa,UAAkB,EAAE,OAAgB;QAEhD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,eAAe,CACrB,UAA2B,EAC3B,UAAkB,EAClB,OAAgB;QAEhB,IAAG,UAAU,CAAC,WAAW;YAAE,MAAM,IAAI,uBAAuB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QAClF,OAAO,IAAI,CAAC;IACb,CAAC;CACD"} \ No newline at end of file diff --git a/dist/dispose.d.ts b/dist/dispose.d.ts index a5176ce..4cd3989 100644 --- a/dist/dispose.d.ts +++ b/dist/dispose.d.ts @@ -2,8 +2,8 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT */ -import IDisposable from './IDisposable'; -export declare type DisposableItem = IDisposable | null | undefined; +import Disposable from './Disposable'; +export declare type DisposableItem = Disposable | null | undefined; export declare type DisposableItemArray = DisposableItem[] | null | undefined; /** * Takes any number of disposables as arguments and attempts to dispose them. @@ -79,5 +79,5 @@ export declare namespace dispose { * @param closure Function call to execute. * @returns {TReturn} Returns whatever the closure's return value is. */ -export declare function using(disposable: TDisposable, closure: (disposable: TDisposable) => TReturn): TReturn; +export declare function using(disposable: TDisposable, closure: (disposable: TDisposable) => TReturn): TReturn; export default dispose; diff --git a/dist/dispose.js b/dist/dispose.js index da763a2..c4b4239 100644 --- a/dist/dispose.js +++ b/dist/dispose.js @@ -2,6 +2,7 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT */ +/* eslint-disable @typescript-eslint/no-use-before-define,@typescript-eslint/no-namespace,no-inner-declarations */ /** * Takes any number of disposables as arguments and attempts to dispose them. * Any exceptions thrown within a dispose are not trapped. diff --git a/dist/dispose.js.map b/dist/dispose.js.map index 6d77391..c7c1a0d 100644 --- a/dist/dispose.js.map +++ b/dist/dispose.js.map @@ -1 +1 @@ -{"version":3,"file":"dispose.js","sourceRoot":"","sources":["../src/dispose.ts"],"names":[],"mappings":"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"} \ No newline at end of file +{"version":3,"file":"dispose.js","sourceRoot":"","sources":["../src/dispose.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts index baa328e..8c9177d 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -2,10 +2,10 @@ * @author electricessence / https://github.com/electricessence/ * Licensing: MIT */ -import IDisposable from './IDisposable'; -import IDisposableAware from './IDisposableAware'; +import Disposable from './Disposable'; +import DisposableAware from './DisposableAware'; import ObjectDisposedException from './ObjectDisposedException'; import DisposableBase from './DisposableBase'; import dispose from './dispose'; -export { IDisposable, IDisposableAware, ObjectDisposedException, dispose, DisposableBase }; +export { Disposable, DisposableAware, ObjectDisposedException, dispose, DisposableBase }; export default DisposableBase; diff --git a/dist/index.js.map b/dist/index.js.map index b69b9f8..3d23110 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAiC,uBAAuB,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;AAE3F,eAAe,cAAc,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,uBAAuB,MAAM,2BAA2B,CAAC;AAChE,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,OAAO,EAA8B,uBAAuB,EAAE,OAAO,EAAE,cAAc,EAAC,CAAC;AAEvF,eAAe,cAAc,CAAC"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 97cb0ce..f94c754 100644 --- a/package-lock.json +++ b/package-lock.json @@ -525,19 +525,10 @@ } } }, - "eslint-config-prettier": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz", - "integrity": "sha512-oB8cpLWSAjOVFEJhhyMZh6NOEOtBVziaqdDQ86+qhDHFbZXoRTM7pNSvFRfW/W/L/LrQ38C99J5CGuRBBzBsdA==", - "dev": true, - "requires": { - "get-stdin": "^6.0.0" - } - }, - "eslint-config-standard": { - "version": "14.1.1", - "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-14.1.1.tgz", - "integrity": "sha512-Z9B+VR+JIXRxz21udPTL9HpFMyoMUEeX1G251EQ6e05WD9aPVtVBn09XUmZ259wCMlCDmYDSZG62Hhm+ZTJcUg==", + "eslint-config-typescript": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/eslint-config-typescript/-/eslint-config-typescript-3.0.0.tgz", + "integrity": "sha512-CwC2cQ29OLE1OUw0k+Twpc6wpCdenG8rrErl89sWrzmMpWfkulyeQS1HJhhjU0B3Tb4k41zdei4LtX26x5m60Q==", "dev": true }, "eslint-import-resolver-node": { @@ -679,12 +670,6 @@ "integrity": "sha512-VoM09vT7bfA7D+upt+FjeBO5eHIJQBUWki1aPvB+vbNiHS3+oGIJGIeyBtKQTME6UPXXy3vV07OL1tHd3ANuDw==", "dev": true }, - "eslint-plugin-standard": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-4.0.1.tgz", - "integrity": "sha512-v/KBnfyaOMPmZc/dmc6ozOdWqekGp7bBGq4jLAecEfPGmfKiWS4sA8sC0LqiV9w5qmXAtXVn4M3p1jSyhY85SQ==", - "dev": true - }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", @@ -873,12 +858,6 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, - "get-stdin": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", - "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", - "dev": true - }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", @@ -1474,12 +1453,6 @@ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, - "prettier": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", - "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", - "dev": true - }, "process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", diff --git a/package.json b/package.json index c70d338..6405393 100644 --- a/package.json +++ b/package.json @@ -18,10 +18,8 @@ "clean": "rimraf dist/*", "build": "npm run clean && copyfiles -u 1 src/**/*.d.ts dist && tsc", "bump": "npm version patch", - "format": "prettier --write \"src/**/*.ts\"", "lint": "eslint src/**/*.ts", - "precommit": "npm run format && npm run lint && npm run build", - "prepublishOnly": "npm run build && npm run lint", + "prepublishOnly": "npm run lint && npm run build", "preversion": "npm run lint", "postversion": "git push && git push --tags" }, @@ -38,13 +36,10 @@ "@typescript-eslint/parser": "^2.30.0", "copyfiles": "^2.2.0", "eslint": "^6.8.0", - "eslint-config-prettier": "^6.11.0", - "eslint-config-standard": "^14.1.1", + "eslint-config-typescript": "^3.0.0", "eslint-plugin-import": "^2.20.2", "eslint-plugin-node": "^11.1.0", "eslint-plugin-promise": "^4.2.1", - "eslint-plugin-standard": "^4.0.1", - "prettier": "^2.0.5", "rimraf": "^3.0.2", "ts-node": "^8.9.0", "typescript": "^3.8.3" diff --git a/src/IDisposable.d.ts b/src/Disposable.d.ts similarity index 79% rename from src/IDisposable.d.ts rename to src/Disposable.d.ts index 3187687..1828e5a 100644 --- a/src/IDisposable.d.ts +++ b/src/Disposable.d.ts @@ -4,6 +4,7 @@ */ // Allows for simple type checking that includes types that don't declare themselves as IDisposable but do have a dispose() method. -export default interface IDisposable { - dispose(): void; +export default interface Disposable +{ + dispose (): void; } diff --git a/dist/IDisposableAware.d.ts b/src/DisposableAware.d.ts similarity index 54% rename from dist/IDisposableAware.d.ts rename to src/DisposableAware.d.ts index 7102823..98e385e 100644 --- a/dist/IDisposableAware.d.ts +++ b/src/DisposableAware.d.ts @@ -3,8 +3,10 @@ * Licensing: MIT */ -import IDisposable from './IDisposable'; +import Disposable from './Disposable'; -export default interface IDisposableAware extends IDisposable { +export default interface DisposableAware + extends Disposable +{ readonly wasDisposed: boolean; } diff --git a/src/DisposableBase.ts b/src/DisposableBase.ts index 54f1f34..ac16b84 100644 --- a/src/DisposableBase.ts +++ b/src/DisposableBase.ts @@ -1,58 +1,73 @@ -/* tslint:disable:variable-name */ /*! * @author electricessence / https://github.com/electricessence/ * Licensing: MIT */ -import IDisposableAware from './IDisposableAware'; +import DisposableAware from './DisposableAware'; import ObjectDisposedException from './ObjectDisposedException'; -abstract class DisposableBase implements IDisposableAware { - protected constructor(protected _disposableObjectName: string, private readonly __finalizer?: () => void | null) {} - +abstract class DisposableBase + implements DisposableAware +{ private __wasDisposed: boolean = false; - get wasDisposed(): boolean { - return this.__wasDisposed; - } + protected constructor ( + protected _disposableObjectName: string, + private readonly __finalizer?: () => void | null) + {} - /** - * Utility for throwing exception when this object is accessed. - * @param message - * @param objectName Optional object name override. - */ - protected throwIfDisposed(message?: string, objectName: string = this._disposableObjectName): true | never { - if (this.__wasDisposed) throw new ObjectDisposedException(objectName); - return true; + get wasDisposed (): boolean + { + return this.__wasDisposed; } // NOTE: Do not override this method. Override _onDispose instead. - dispose(): void { - const _ = this; - if (!_.__wasDisposed) { + dispose (): void + { + if(!this.__wasDisposed) + { // Preemptively set wasDisposed in order to prevent repeated disposing. // NOTE: in true multi-threaded scenarios, this would need to be synchronized. - _.__wasDisposed = true; - try { - _._onDispose(); // Protected override. - } finally { - if (_.__finalizer) { + this.__wasDisposed = true; + try + { + this._onDispose(); // Protected override. + } + finally + { + if(this.__finalizer) + { // Private finalizer... - _.__finalizer(); - (_ as any).__finalizer = undefined; + this.__finalizer(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (this as any).__finalizer = undefined; } } } } + /** + * Utility for throwing exception when this object is accessed. + * @param message + * @param objectName Optional object name override. + */ + protected throwIfDisposed ( + message?: string, + objectName: string = this._disposableObjectName): true | never + { + if(this.__wasDisposed) throw new ObjectDisposedException(objectName); + return true; + } + // Placeholder for overrides. - // tslint:disable-next-line:no-empty /** * Is called when this object is disposed. Should not be called directly. * Override this method to handle disposal. * @private */ - protected _onDispose(): void {} + protected _onDispose (): void + // eslint-disable-next-line @typescript-eslint/no-empty-function + {} } export default DisposableBase; diff --git a/src/ObjectDisposedException.ts b/src/ObjectDisposedException.ts index 2c16e1f..7c6b9a6 100644 --- a/src/ObjectDisposedException.ts +++ b/src/ObjectDisposedException.ts @@ -3,18 +3,25 @@ * Licensing: MIT */ -import IDisposableAware from './IDisposableAware'; +import DisposableAware from './DisposableAware'; -export default class ObjectDisposedException extends Error { +export default class ObjectDisposedException + extends Error +{ readonly objectName: string; - constructor(objectName: string, message?: string) { + constructor (objectName: string, message?: string) + { super(message); this.objectName = objectName; } - static throwIfDisposed(disposable: IDisposableAware, objectName: string, message?: string): true | never { - if (disposable.wasDisposed) throw new ObjectDisposedException(objectName, message); + static throwIfDisposed ( + disposable: DisposableAware, + objectName: string, + message?: string): true | never + { + if(disposable.wasDisposed) throw new ObjectDisposedException(objectName, message); return true; } } diff --git a/src/dispose.ts b/src/dispose.ts index 16ed47e..fda665c 100644 --- a/src/dispose.ts +++ b/src/dispose.ts @@ -3,33 +3,36 @@ * Licensing: MIT */ -/* eslint-disable import/export */ - -import IDisposable from './IDisposable'; +import Disposable from './Disposable'; // Allows for more flexible parameters. -export type DisposableItem = IDisposable | null | undefined; +export type DisposableItem = Disposable | null | undefined; export type DisposableItemArray = DisposableItem[] | null | undefined; +/* eslint-disable @typescript-eslint/no-use-before-define,@typescript-eslint/no-namespace,no-inner-declarations */ + /** * Takes any number of disposables as arguments and attempts to dispose them. * Any exceptions thrown within a dispose are not trapped. * Use 'dispose.withoutException' to automatically trap exceptions. * @param disposables The objects to dispose of. Can accept and will ignore objects that don't have a dispose() method. */ -export function dispose(...disposables: DisposableItem[]): void { +export function dispose (...disposables: DisposableItem[]): void +{ // The disposables arguments array is effectively localized so it's safe. theseUnsafe(disposables, false); } -export namespace dispose { +export namespace dispose +{ /** * Use this when only disposing one object to avoid creation of arrays. * @param disposable * @param trapException */ - export function single(disposable: DisposableItem, trapException: boolean = false): void { - if (disposable) singleUnsafe(disposable, trapException); + export function single (disposable: DisposableItem, trapException: boolean = false): void + { + if(disposable) singleUnsafe(disposable, trapException); } /** @@ -37,7 +40,8 @@ export namespace dispose { * All exceptions are logged but not thrown. * @param disposables The objects to dispose of. Can accept and will ignore objects that don't have a dispose() method. */ - export function deferred(...disposables: DisposableItem[]): void { + export function deferred (...disposables: DisposableItem[]): void + { // The disposables arguments array is effectively localized so it's safe. these.deferred.unsafe(disposables); } @@ -47,7 +51,8 @@ export namespace dispose { * Returns an array of the exceptions thrown. * @param disposables The objects to dispose of. Can accept and will ignore objects that don't have a dispose() method. */ - export function withoutException(...disposables: DisposableItem[]): void { + export function withoutException (...disposables: DisposableItem[]): void + { // The disposables arguments array is effectively localized so it's safe. theseUnsafe(disposables, true); } @@ -57,12 +62,14 @@ export namespace dispose { * @param disposables The objects to dispose of. Can accept and will ignore objects that don't have a dispose() method. * @param trapExceptions If true, prevents exceptions from being thrown when disposing. */ - export function these(disposables: DisposableItemArray, trapExceptions?: boolean): void { - if (!disposables || !disposables.length) return; + export function these (disposables: DisposableItemArray, trapExceptions?: boolean): void + { + if(!disposables || !disposables.length) return; theseUnsafe(disposables.slice(), trapExceptions); } - export namespace these { + export namespace these + { /** * Takes any number of disposables as arguments and attempts to dispose them after a zero timeout. * Exceptions are logged but not thrown. @@ -70,11 +77,13 @@ export namespace dispose { * @param delay Milliseconds to wait before disposing. Default is zero (0). A higher number could have detrimental consequences or could improve foreground performance. */ // tslint:disable-next-line:no-shadowed-variable - export function deferred(disposables: DisposableItemArray, delay: number = 0): void { + export function deferred (disposables: DisposableItemArray, delay: number = 0): void + { deferredUnsafe(disposables && disposables.length ? disposables.slice() : null, delay); } - export namespace deferred { + export namespace deferred + { /** * Takes any number of disposables as arguments and attempts to dispose them after a zero timeout. * Exceptions are logged but not thrown. @@ -82,7 +91,8 @@ export namespace dispose { * @param disposables The objects to dispose of. Can accept and will ignore objects that don't have a dispose() method. * @param delay Milliseconds to wait before disposing. Default is zero (0). A higher number could have detrimental consequences or could improve foreground performance. */ - export function unsafe(disposables: DisposableItemArray, delay: number = 0): void { + export function unsafe (disposables: DisposableItemArray, delay: number = 0): void + { deferredUnsafe(disposables, delay); } } @@ -93,7 +103,8 @@ export namespace dispose { * @param disposables The objects to dispose of. Can accept and will ignore objects that don't have a dispose() method. * @param trapExceptions If true, prevents exceptions from being thrown when disposing. */ - export function unsafe(disposables: DisposableItemArray, trapExceptions?: boolean): void { + export function unsafe (disposables: DisposableItemArray, trapExceptions?: boolean): void + { theseUnsafe(disposables, trapExceptions); } } @@ -114,13 +125,17 @@ export namespace dispose { * @param closure Function call to execute. * @returns {TReturn} Returns whatever the closure's return value is. */ -export function using( +export function using ( disposable: TDisposable, closure: (disposable: TDisposable) => TReturn -): TReturn { - try { +): TReturn +{ + try + { return closure(disposable); - } finally { + } + finally + { singleUnsafe(disposable, false); } } @@ -129,16 +144,23 @@ export function using( * This private function makes disposing more robust for when there's no type checking. * If trapException is 'true' it logs any exception instead of throwing. */ -function singleUnsafe(disposable: DisposableItem, trapException?: boolean): void { - if (disposable && typeof disposable === 'object') { - if (typeof disposable.dispose !== 'function') return; - if (trapException) { - try { +function singleUnsafe (disposable: DisposableItem, trapException?: boolean): void +{ + if(disposable && typeof disposable==='object') + { + if(typeof disposable.dispose!=='function') return; + if(trapException) + { + try + { disposable.dispose(); - } catch (ex) { + } + catch(ex) + { console.error(ex); } - } else disposable.dispose(); + } + else disposable.dispose(); } } @@ -146,14 +168,16 @@ function singleUnsafe(disposable: DisposableItem, trapException?: boolean): void * The following dispose methods assume they're working on a local arrayCopy and it's unsafe for external use. */ -function theseUnsafe(disposables: DisposableItemArray, trapExceptions?: boolean): void { - if (!disposables) return; - for (const d of disposables) singleUnsafe(d, trapExceptions); +function theseUnsafe (disposables: DisposableItemArray, trapExceptions?: boolean): void +{ + if(!disposables) return; + for(const d of disposables) singleUnsafe(d, trapExceptions); } -function deferredUnsafe(disposables: DisposableItemArray, delay: number = 0): void { - if (!disposables || !disposables.length) return; - setTimeout(theseUnsafe, delay && delay > 0 ? delay : 0, disposables, true); +function deferredUnsafe (disposables: DisposableItemArray, delay: number = 0): void +{ + if(!disposables || !disposables.length) return; + setTimeout(theseUnsafe, delay && delay>0 ? delay : 0, disposables, true); } export default dispose; diff --git a/src/index.ts b/src/index.ts index 08f3451..fc972cb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,12 +3,12 @@ * Licensing: MIT */ -import IDisposable from './IDisposable'; -import IDisposableAware from './IDisposableAware'; +import Disposable from './Disposable'; +import DisposableAware from './DisposableAware'; import ObjectDisposedException from './ObjectDisposedException'; import DisposableBase from './DisposableBase'; import dispose from './dispose'; -export { IDisposable, IDisposableAware, ObjectDisposedException, dispose, DisposableBase }; +export {Disposable, DisposableAware, ObjectDisposedException, dispose, DisposableBase}; export default DisposableBase; From 0cb7693c351a00fa113dbe3edc559c21c871ddb3 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 18:23:36 -0700 Subject: [PATCH 013/151] 1.0.7 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f94c754..26c6f48 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.6", + "version": "1.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 6405393..2d91c5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.6", + "version": "1.0.7", "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", "author": "electricessence", "license": "MIT", From 6eab67f967fb90ab72174bcdaf0b8b45fe1cbffb Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 19:37:31 -0700 Subject: [PATCH 014/151] Fixed publish script. --- .github/workflows/publish.yml | 42 +++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c178fba..b853ef7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,25 +1,39 @@ name: npm-publish + on: push: branches: - - master # Change this to your default branch + - master + jobs: + npm-publish: - name: npm-publish + + name: Publish to NPM runs-on: ubuntu-latest + steps: - name: Checkout repository uses: actions/checkout@master - - name: Set up Node.js - uses: actions/setup-node@master with: - node-version: 10.0.0 - - name: Publish if version has been updated - uses: pascalgn/npm-publish-action@4f4bf159e299f65d21cd1cbd96fc5d53228036df - with: # All of theses inputs are optional - tag_name: "v%s" - tag_message: "v%s" - commit_pattern: "^Release (\\S+)" - env: # More info about the environment variables in the README - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated - NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings + ref: master + + - name: Check version changes + uses: EndBug/version-check@v1 + id: check + + - name: Set up Node.js for NPM + if: steps.check.outputs.changed == 'true' + uses: actions/setup-node@v1 + with: + registry-url: "https://registry.npmjs.org" + + - name: Install dependencies + if: steps.check.outputs.changed == 'true' + run: npm install --only=prod + + - name: Publish package to NPM + if: steps.check.outputs.changed == 'true' + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} From caf9b1e980e6ad7151d39699e89184397572dcc9 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 19:37:37 -0700 Subject: [PATCH 015/151] 1.0.8 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 26c6f48..1210d08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.7", + "version": "1.0.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2d91c5a..053a57f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.7", + "version": "1.0.8", "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", "author": "electricessence", "license": "MIT", From 8ad858bd47ead3ec4f10a0866435e4daa417c205 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 19:40:20 -0700 Subject: [PATCH 016/151] Eliminated eslint hook. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 053a57f..f6221e0 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build": "npm run clean && copyfiles -u 1 src/**/*.d.ts dist && tsc", "bump": "npm version patch", "lint": "eslint src/**/*.ts", - "prepublishOnly": "npm run lint && npm run build", + "precommit": "npm run lint && npm run build", "preversion": "npm run lint", "postversion": "git push && git push --tags" }, From 48ff4e051a89af783afdbfd7f31c842f38b8d488 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 19:40:32 -0700 Subject: [PATCH 017/151] 1.1.0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1210d08..df166ef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.8", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index f6221e0..71f2c97 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tsdotnet/disposable", - "version": "1.0.8", + "version": "1.1.0", "description": "A disposable base class and minimal set of interfaces to properly implement an object disposal pattern.", "author": "electricessence", "license": "MIT", From 4153652fc9beb2a0d0464daaf333fbb73f01c085 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Wed, 29 Apr 2020 21:00:54 -0700 Subject: [PATCH 018/151] Disabled tslint --- .idea/inspectionProfiles/Project_Default.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml index 245ebf3..aeda62e 100644 --- a/.idea/inspectionProfiles/Project_Default.xml +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -4,6 +4,5 @@ - \ No newline at end of file From cc12683408aba619683235431ea73cd324234a6e Mon Sep 17 00:00:00 2001 From: electricessence <5899455+electricessence@users.noreply.github.com> Date: Wed, 29 Apr 2020 22:44:01 -0700 Subject: [PATCH 019/151] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a3e5cc7..1296d26 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # ![alt text](https://avatars1.githubusercontent.com/u/64487547?s=30&v=4 "tsdotnet") tsdotnet / disposable [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/tsdotnet/disposable/blob/master/LICENSE) -![Publish](https://github.com/tsdotnet/disposable/workflows/Publish/badge.svg) +![npm-publish](https://github.com/tsdotnet/disposable/workflows/npm-publish/badge.svg) [![npm version](https://img.shields.io/npm/v/@tsdotnet/disposable.svg?style=flat-square)](https://www.npmjs.com/package/@tsdotnet/disposable) A disposable base class and minimal set of interfaces to properly implement an object disposal pattern. From 732cde8093536485c31699abb857af81119e2014 Mon Sep 17 00:00:00 2001 From: "Oren (electricessence)" Date: Thu, 30 Apr 2020 11:16:03 -0700 Subject: [PATCH 020/151] Updated configuration. --- .eslintrc.json | 3 ++- .github/workflows/publish.yml | 4 ---- .gitignore | 1 + .idea/codeStyles/Project.xml | 10 ++++++++++ .idea/dictionaries/shared.xml | 5 +++++ .idea/disposable.iml | 2 ++ package-lock.json | 22 ++++++++++++++++++++++ package.json | 12 ++++++++---- 8 files changed, 50 insertions(+), 9 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index ffebbed..fa6e8f5 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -20,6 +20,7 @@ "@typescript-eslint" ], "rules": { - "@typescript-eslint/no-inferrable-types": "off" + "@typescript-eslint/no-inferrable-types": "off", + "@typescript-eslint/no-explicit-any": "off" } } diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b853ef7..7bfcb5d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,10 +28,6 @@ jobs: with: registry-url: "https://registry.npmjs.org" - - name: Install dependencies - if: steps.check.outputs.changed == 'true' - run: npm install --only=prod - - name: Publish package to NPM if: steps.check.outputs.changed == 'true' run: npm publish --access public diff --git a/.gitignore b/.gitignore index 6adf739..3a37f4e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ node_modules .idea/dictionaries/* !.idea/dictionaries/shared.xml +!.idea/dictionaries/local.xml diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index a4ce7cd..6d5105d 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -14,8 +14,12 @@ @@ -30,6 +34,12 @@ + + + +