Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wixc3/patterns

Package Overview
Dependencies
Maintainers
64
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wixc3/patterns - npm Package Compare versions

Comparing version 13.3.2 to 13.4.0

3

dist/cjs/disposables/create-disposables.d.ts

@@ -56,6 +56,7 @@ import { GroupConstraints } from './constraints';

*/
export declare function createDisposables(): Disposables;
export declare function createDisposables(initialGroups?: string[]): Disposables;
export declare class Disposables {
private readonly groups;
private readonly constrains;
constructor(initialGroups?: string[]);
/**

@@ -62,0 +63,0 @@ * register a new constrained disposal group

@@ -55,8 +55,8 @@ "use strict";

*/
function createDisposables() {
return new Disposables();
function createDisposables(initialGroups = []) {
return new Disposables(initialGroups);
}
exports.createDisposables = createDisposables;
class Disposables {
constructor() {
constructor(initialGroups = []) {
this.groups = [createGroup(exports.DEFAULT_GROUP)];

@@ -73,2 +73,3 @@ this.constrains = [];

};
this.groups.push(...initialGroups.map(createGroup));
}

@@ -75,0 +76,0 @@ /**

@@ -56,6 +56,7 @@ import { GroupConstraints } from './constraints';

*/
export declare function createDisposables(): Disposables;
export declare function createDisposables(initialGroups?: string[]): Disposables;
export declare class Disposables {
private readonly groups;
private readonly constrains;
constructor(initialGroups?: string[]);
/**

@@ -62,0 +63,0 @@ * register a new constrained disposal group

@@ -52,7 +52,7 @@ import { getGroupConstrainedIndex, normalizeConstraints } from './constraints';

*/
export function createDisposables() {
return new Disposables();
export function createDisposables(initialGroups = []) {
return new Disposables(initialGroups);
}
export class Disposables {
constructor() {
constructor(initialGroups = []) {
this.groups = [createGroup(DEFAULT_GROUP)];

@@ -69,2 +69,3 @@ this.constrains = [];

};
this.groups.push(...initialGroups.map(createGroup));
}

@@ -71,0 +72,0 @@ /**

{
"name": "@wixc3/patterns",
"version": "13.3.2",
"version": "13.4.0",
"description": "A utility for saving objects to be disposed",

@@ -21,5 +21,5 @@ "main": "dist/cjs/index.js",

"dependencies": {
"@wixc3/common": "^13.3.2",
"@wixc3/common": "^13.4.0",
"promise-assist": "^2.0.1"
}
}

@@ -73,4 +73,4 @@ import { DisposalGroup, getGroupConstrainedIndex, GroupConstraints, normalizeConstraints } from './constraints';

*/
export function createDisposables() {
return new Disposables();
export function createDisposables(initialGroups: string[] = []) {
return new Disposables(initialGroups);
}

@@ -81,3 +81,5 @@

private readonly constrains: GroupConstraints[] = [];
constructor(initialGroups: string[] = []) {
this.groups.push(...initialGroups.map(createGroup));
}
/**

@@ -84,0 +86,0 @@ * register a new constrained disposal group

@@ -43,3 +43,22 @@ import { expect, use } from 'chai';

});
describe('initial disposal group', () => {
it('disposes in insertion order', async () => {
const disposed: number[] = [];
const disposables = createDisposables(['A', 'B']);
disposables.add(() => disposed.push(2), 'B');
disposables.add(() => disposed.push(1), 'A');
await disposables.dispose();
expect(disposed).to.deep.equal([1, 2]);
});
it('allow adding additional groups', async () => {
const disposed: number[] = [];
const disposables = createDisposables(['A', 'C']);
disposables.registerGroup('B', { before: 'C' });
disposables.add(() => disposed.push(1), 'A');
disposables.add(() => disposed.push(2), 'B');
disposables.add(() => disposed.push(3), 'C');
await disposables.dispose();
expect(disposed).to.deep.equal([1, 2, 3]);
});
});
describe('disposal groups', () => {

@@ -46,0 +65,0 @@ describe('constraints validation', () => {

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

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

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

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

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