@guanghechen/disposable 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present guanghechen (https://github.com/guanghechen)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -112,22 +112,29 @@ Disposable pattern implementation for resource cleanup and memory management.
112
112
  - Utility functions:
113
113
 
114
114
  ```typescript
115
- import { disposeAll, isDisposable } from '@guanghechen/disposable'
115
+ import { Disposable, disposeAll, isDisposable } from '@guanghechen/disposable'
116
116
 
117
- const items = [
117
+ const items: unknown[] = [
118
118
  new Disposable(() => console.log('Disposed 1')),
119
119
  new Disposable(() => console.log('Disposed 2')),
120
120
  'not disposable'
121
121
  ]
122
122
 
123
+ // Check if an item is disposable
123
124
  items.forEach(item => {
124
125
  if (isDisposable(item)) {
125
126
  console.log('Item is disposable')
126
127
  }
127
128
  })
128
129
 
129
- disposeAll(items) // Disposes all disposable items in the array
130
+ // Filter and dispose only disposable items
131
+ const disposables = items.filter(isDisposable)
132
+ disposeAll(disposables) // Disposes all disposable items
130
133
  ```
131
134
 
135
+ ## Reference
136
+
137
+ - [homepage][homepage]
138
+
132
139
  [homepage]:
133
140
  https://github.com/guanghechen/sora/tree/@guanghechen/disposable@2.0.0/packages/disposable#readme
package/lib/cjs/index.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var disposable_types = require('@guanghechen/disposable.types');
4
-
5
3
  class SafeBatchHandler {
6
4
  _errors;
7
5
  _summary;
@@ -103,9 +101,3 @@ exports.Disposable = Disposable;
103
101
  exports.SafeBatchHandler = SafeBatchHandler;
104
102
  exports.disposeAll = disposeAll;
105
103
  exports.isDisposable = isDisposable;
106
- Object.keys(disposable_types).forEach(function (k) {
107
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
108
- enumerable: true,
109
- get: function () { return disposable_types[k]; }
110
- });
111
- });
package/lib/esm/index.mjs CHANGED
@@ -1,5 +1,3 @@
1
- export * from '@guanghechen/disposable.types';
2
-
3
1
  class SafeBatchHandler {
4
2
  _errors;
5
3
  _summary;
@@ -1,5 +1,4 @@
1
- import { IBatchDisposable, IDisposable } from '@guanghechen/disposable.types';
2
- export * from '@guanghechen/disposable.types';
1
+ import { IBatchDisposable, IDisposable } from '@guanghechen/types';
3
2
 
4
3
  declare class BatchDisposable implements IBatchDisposable {
5
4
  protected _disposed: boolean;
package/package.json CHANGED
@@ -1,37 +1,33 @@
1
1
  {
2
2
  "name": "@guanghechen/disposable",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "author": {
5
5
  "name": "guanghechen",
6
6
  "url": "https://github.com/guanghechen/"
7
7
  },
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/guanghechen/sora/tree/@guanghechen/disposable@1.0.3",
10
+ "url": "https://github.com/guanghechen/sora/tree/@guanghechen/disposable@2.0.0",
11
11
  "directory": "packages/disposable"
12
12
  },
13
- "homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/disposable@1.0.3/packages/disposable#readme",
13
+ "homepage": "https://github.com/guanghechen/sora/tree/@guanghechen/disposable@2.0.0/packages/disposable#readme",
14
14
  "keywords": [
15
15
  "disposable"
16
16
  ],
17
17
  "type": "module",
18
18
  "exports": {
19
- "types": "./lib/types/index.d.ts",
20
- "require": "./lib/cjs/index.cjs",
21
- "import": "./lib/esm/index.mjs"
19
+ ".": {
20
+ "types": "./lib/types/index.d.ts",
21
+ "source": "./src/index.ts",
22
+ "import": "./lib/esm/index.mjs",
23
+ "require": "./lib/cjs/index.cjs"
24
+ }
22
25
  },
23
26
  "types": "./lib/types/index.d.ts",
24
27
  "main": "./lib/cjs/index.cjs",
25
28
  "module": "./lib/esm/index.mjs",
26
29
  "source": "./src/index.ts",
27
30
  "license": "MIT",
28
- "scripts": {
29
- "build": "rollup -c ../../rollup.config.mjs",
30
- "clean": "rimraf lib",
31
- "test": "vitest run --config ../../vitest.config.ts",
32
- "test:coverage": "vitest run --config ../../vitest.config.ts --coverage",
33
- "test:update": "vitest run --config ../../vitest.config.ts -u"
34
- },
35
31
  "files": [
36
32
  "lib/",
37
33
  "!lib/**/*.map",
@@ -41,7 +37,13 @@
41
37
  "README.md"
42
38
  ],
43
39
  "dependencies": {
44
- "@guanghechen/disposable.types": "^2.0.0"
40
+ "@guanghechen/types": "^2.0.1"
45
41
  },
46
- "gitHead": "12990a720b31d50d217e2e17a6191256dc94eda6"
47
- }
42
+ "scripts": {
43
+ "build": "rollup -c ../../rollup.config.mjs",
44
+ "clean": "rimraf lib",
45
+ "test": "vitest run --config ../../vitest.config.ts",
46
+ "test:coverage": "vitest run --config ../../vitest.config.ts --coverage",
47
+ "test:update": "vitest run --config ../../vitest.config.ts -u"
48
+ }
49
+ }