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

@wixc3/patterns

Package Overview
Dependencies
Maintainers
70
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.2.0 to 13.3.0

src/test/disposables-group.unit.ts

10

dist/cjs/disposables/constraints.d.ts

@@ -22,3 +22,11 @@ import type { DisposablesGroup } from './disposables-group';

};
export declare const normalizeConstraints: (constraints: GroupConstraints | GroupConstraints[], name: string, groups: DisposalGroup[]) => GroupConstraints[];
export declare const normalizeConstraints: (constraints: GroupConstraints | GroupConstraints[], name: string, groups: DisposalGroup[]) => ({
before: string;
after?: string | undefined;
name: string;
} | {
after: string;
before?: string | undefined;
name: string;
})[];
//# sourceMappingURL=constraints.d.ts.map

2

dist/cjs/disposables/constraints.js

@@ -44,5 +44,5 @@ "use strict";

}
return _constraints;
return _constraints.map((c) => ({ name, ...c }));
};
exports.normalizeConstraints = normalizeConstraints;
//# sourceMappingURL=constraints.js.map

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

*/
export declare function createDisposables(): Disposables;
export declare function createDisposables(allowUnnamedDisposables?: boolean): Disposables;
export declare class Disposables {
readonly allowUnnamedDisposables: boolean;
private readonly groups;
private readonly constrains;
constructor(allowUnnamedDisposables?: boolean);
/**

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

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

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

@@ -63,0 +64,0 @@ this.constrains = [];

@@ -22,3 +22,4 @@ /**

name: string;
stack: string;
};
//# sourceMappingURL=disposables-group.d.ts.map

@@ -17,10 +17,17 @@ "use strict";

for (const [disposable, details] of _disposables) {
await (0, promise_assist_1.timeout)(disposeOf(disposable), details.timeout, `Disposal timed out: "${details.name}" after ${details.timeout}ms`);
await (0, promise_assist_1.timeout)(disposeOf(disposable), details.timeout, `Disposal timed out: "${details.name}" after ${details.timeout}ms`).catch((e) => {
e.stack = `Error: ${e.message}${details.stack}`;
throw e;
});
}
}
add(disposable, timeout, name) {
var _a;
if (this.disposables.has(disposable)) {
throw new Error(`Disposable already added`);
}
this.disposables.set(disposable, { timeout, name });
const [_0, _1, _2, ...userCode] = ((_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split(/\n\s+at\s+/)) || ['No stacktrace :('];
userCode.unshift('');
const stack = userCode.join('\n at ');
this.disposables.set(disposable, { timeout, name, stack });
return () => this.disposables.delete(disposable);

@@ -27,0 +34,0 @@ }

@@ -22,3 +22,11 @@ import type { DisposablesGroup } from './disposables-group';

};
export declare const normalizeConstraints: (constraints: GroupConstraints | GroupConstraints[], name: string, groups: DisposalGroup[]) => GroupConstraints[];
export declare const normalizeConstraints: (constraints: GroupConstraints | GroupConstraints[], name: string, groups: DisposalGroup[]) => ({
before: string;
after?: string | undefined;
name: string;
} | {
after: string;
before?: string | undefined;
name: string;
})[];
//# sourceMappingURL=constraints.d.ts.map

@@ -40,4 +40,4 @@ /**

}
return _constraints;
return _constraints.map((c) => ({ name, ...c }));
};
//# sourceMappingURL=constraints.js.map

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

*/
export declare function createDisposables(): Disposables;
export declare function createDisposables(allowUnnamedDisposables?: boolean): Disposables;
export declare class Disposables {
readonly allowUnnamedDisposables: boolean;
private readonly groups;
private readonly constrains;
constructor(allowUnnamedDisposables?: boolean);
/**

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

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

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

@@ -59,0 +60,0 @@ this.constrains = [];

@@ -22,3 +22,4 @@ /**

name: string;
stack: string;
};
//# sourceMappingURL=disposables-group.d.ts.map

@@ -14,10 +14,17 @@ import { timeout } from 'promise-assist';

for (const [disposable, details] of _disposables) {
await timeout(disposeOf(disposable), details.timeout, `Disposal timed out: "${details.name}" after ${details.timeout}ms`);
await timeout(disposeOf(disposable), details.timeout, `Disposal timed out: "${details.name}" after ${details.timeout}ms`).catch((e) => {
e.stack = `Error: ${e.message}${details.stack}`;
throw e;
});
}
}
add(disposable, timeout, name) {
var _a;
if (this.disposables.has(disposable)) {
throw new Error(`Disposable already added`);
}
this.disposables.set(disposable, { timeout, name });
const [_0, _1, _2, ...userCode] = ((_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split(/\n\s+at\s+/)) || ['No stacktrace :('];
userCode.unshift('');
const stack = userCode.join('\n at ');
this.disposables.set(disposable, { timeout, name, stack });
return () => this.disposables.delete(disposable);

@@ -24,0 +31,0 @@ }

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

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

"dependencies": {
"@wixc3/common": "^13.2.0",
"@wixc3/common": "^13.3.0",
"promise-assist": "^2.0.1"
}
}

@@ -56,3 +56,3 @@ import type { DisposablesGroup } from './disposables-group';

}
return _constraints;
return _constraints.map((c) => ({ name, ...c }));
};

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

*/
export function createDisposables() {
return new Disposables();
export function createDisposables(allowUnnamedDisposables = true) {
return new Disposables(allowUnnamedDisposables);
}

@@ -82,2 +82,4 @@

constructor(readonly allowUnnamedDisposables = true) {}
/**

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

@@ -17,3 +17,6 @@ import { timeout } from 'promise-assist';

`Disposal timed out: "${details.name}" after ${details.timeout}ms`
);
).catch((e: Error) => {
e.stack = `Error: ${e.message}${details.stack}`;
throw e;
});
}

@@ -26,3 +29,7 @@ }

}
this.disposables.set(disposable, { timeout, name });
const [_0, _1, _2, ...userCode] = new Error().stack?.split(/\n\s+at\s+/) || ['No stacktrace :('];
userCode.unshift('');
const stack = userCode.join('\n at ');
this.disposables.set(disposable, { timeout, name, stack });
return () => this.disposables.delete(disposable);

@@ -46,2 +53,3 @@ }

name: string;
stack: string;
};

@@ -48,0 +56,0 @@

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