@wixc3/patterns
Advanced tools
Comparing version 9.1.0 to 9.2.0
@@ -62,4 +62,8 @@ import { GroupConstraints } from './constraints'; | ||
registerGroup: (name: string, _constraints: GroupConstraints[] | GroupConstraints) => void; | ||
add: (disposable: Disposable, options?: DisposableOptions) => void; | ||
/** | ||
* @param disposable a function or object with a dispose method | ||
* @param options if string, will be used as group name | ||
*/ | ||
add: (disposable: Disposable, options?: DisposableOptions | string) => void; | ||
/** | ||
* removes a disposable from all disposal group | ||
@@ -66,0 +70,0 @@ */ |
@@ -74,3 +74,10 @@ "use strict"; | ||
}, | ||
/** | ||
* @param disposable a function or object with a dispose method | ||
* @param options if string, will be used as group name | ||
*/ | ||
add: (disposable, options) => { | ||
if (typeof options === 'string') { | ||
options = { group: options }; | ||
} | ||
const { group: groupName, name, timeout } = withDefaults(options); | ||
@@ -77,0 +84,0 @@ const group = groups.find((g) => g.name === groupName); |
@@ -62,4 +62,8 @@ import { GroupConstraints } from './constraints'; | ||
registerGroup: (name: string, _constraints: GroupConstraints[] | GroupConstraints) => void; | ||
add: (disposable: Disposable, options?: DisposableOptions) => void; | ||
/** | ||
* @param disposable a function or object with a dispose method | ||
* @param options if string, will be used as group name | ||
*/ | ||
add: (disposable: Disposable, options?: DisposableOptions | string) => void; | ||
/** | ||
* removes a disposable from all disposal group | ||
@@ -66,0 +70,0 @@ */ |
@@ -71,3 +71,10 @@ import { getValidatedConstantsGroups, normalizeConstraints } from './constraints'; | ||
}, | ||
/** | ||
* @param disposable a function or object with a dispose method | ||
* @param options if string, will be used as group name | ||
*/ | ||
add: (disposable, options) => { | ||
if (typeof options === 'string') { | ||
options = { group: options }; | ||
} | ||
const { group: groupName, name, timeout } = withDefaults(options); | ||
@@ -74,0 +81,0 @@ const group = groups.find((g) => g.name === groupName); |
{ | ||
"name": "@wixc3/patterns", | ||
"version": "9.1.0", | ||
"version": "9.2.0", | ||
"description": "A utility for saving objects to be disposed", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -93,3 +93,10 @@ import { DisposalGroup, getValidatedConstantsGroups, GroupConstraints, normalizeConstraints } from './constraints'; | ||
add: (disposable: Disposable, options?: DisposableOptions) => { | ||
/** | ||
* @param disposable a function or object with a dispose method | ||
* @param options if string, will be used as group name | ||
*/ | ||
add: (disposable: Disposable, options?: DisposableOptions | string) => { | ||
if (typeof options === 'string') { | ||
options = { group: options }; | ||
} | ||
const { group: groupName, name, timeout } = withDefaults(options); | ||
@@ -96,0 +103,0 @@ const group = groups.find((g) => g.name === groupName); |
@@ -74,2 +74,10 @@ import { expect, use } from 'chai'; | ||
}); | ||
describe('add', () => { | ||
describe('with a string as options', () => { | ||
const groups = createDisposables(); | ||
groups.registerGroup('first', { before: 'default' }); | ||
groups.add(() => void 0, 'first'); | ||
expect(groups.list().groups[0]?.disposables).to.have.length(1); | ||
}); | ||
}); | ||
describe('list', () => { | ||
@@ -76,0 +84,0 @@ it('returns the list of groups', () => { |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
160905
2941