@guanghechen/disposable 2.0.0 → 2.1.0
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/CHANGELOG.md +49 -0
- package/LICENSE +21 -0
- package/README.md +10 -3
- package/lib/cjs/index.cjs +0 -8
- package/lib/esm/index.mjs +0 -2
- package/lib/types/index.d.ts +1 -2
- package/package.json +18 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,57 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- ### @guanghechen/reporter
|
|
8
|
+
- feat: add `setLevel` method for dynamic log level change
|
|
9
|
+
- refactor: split source into modular files (`level.ts`, `chalk.ts`, `types.ts`, `reporter.ts`)
|
|
10
|
+
- refactor: move `IReporter` types from `@guanghechen/types` to `@guanghechen/reporter`
|
|
11
|
+
- export: add level utilities (`LogLevelEnum`, `ILogLevel`, `LOG_LEVELS`, `LOG_LEVEL_VALUES`,
|
|
12
|
+
`isLogLevel`, `getLogLevelValue`, `resolveLogLevel`)
|
|
13
|
+
- export: add chalk utilities (`ANSI`, `formatTag`)
|
|
14
|
+
|
|
15
|
+
### @guanghechen/types
|
|
16
|
+
- refactor: remove `IReporter` and `IReporterLevel` exports (moved to `@guanghechen/reporter`)
|
|
17
|
+
|
|
18
|
+
### @guanghechen/commander
|
|
19
|
+
- feat: add predefined options `logLevelOption` and `silentOption` with `apply` callback support
|
|
20
|
+
- refactor: use `ILogLevel` from `@guanghechen/reporter` instead of `IReporterLevel`
|
|
21
|
+
|
|
22
|
+
### Dependent packages
|
|
23
|
+
- chore: bump version for packages depending on `@guanghechen/types`, `@guanghechen/reporter`, or
|
|
24
|
+
`@guanghechen/commander`
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies:
|
|
29
|
+
- @guanghechen/types@2.2.0
|
|
30
|
+
|
|
3
31
|
All notable changes to this project will be documented in this file. See
|
|
4
32
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
33
|
|
|
34
|
+
## 2.0.1 (2025-02-07)
|
|
35
|
+
|
|
36
|
+
### Improvements
|
|
37
|
+
|
|
38
|
+
- Clean up build configs and standardize package exports
|
|
39
|
+
|
|
40
|
+
### Documentation
|
|
41
|
+
|
|
42
|
+
- Update README.md
|
|
43
|
+
|
|
44
|
+
### Miscellaneous
|
|
45
|
+
|
|
46
|
+
- Add LICENSE file
|
|
47
|
+
- Migrate from lerna to changesets
|
|
48
|
+
|
|
49
|
+
## 2.0.0 (2025-01-15)
|
|
50
|
+
|
|
51
|
+
### Breaking Changes
|
|
52
|
+
|
|
53
|
+
- Move disposable types to @guanghechen/types
|
|
54
|
+
|
|
6
55
|
## 1.0.0-alpha.5 (2024-09-18)
|
|
7
56
|
|
|
8
57
|
- :wrench: chore: upgrade devDependencies and fix configs
|
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
|
-
|
|
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
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IBatchDisposable, IDisposable } from '@guanghechen/
|
|
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.
|
|
3
|
+
"version": "2.1.0",
|
|
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@
|
|
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@
|
|
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
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
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/
|
|
40
|
+
"@guanghechen/types": "^2.2.0"
|
|
45
41
|
},
|
|
46
|
-
"
|
|
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
|
+
}
|