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

@wixc3/patterns

Package Overview
Dependencies
Maintainers
68
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 9.2.0 to 9.2.1

1

dist/cjs/disposables/disposable.d.ts

@@ -11,3 +11,2 @@ /**

remove(disposable: Disposable): void;
remove(name: string): void;
list(): {

@@ -14,0 +13,0 @@ name: string;

17

dist/cjs/disposables/disposable.js

@@ -16,3 +16,3 @@ "use strict";

constructor() {
this.disposables = new Map();
this.disposables = new Set();
}

@@ -27,17 +27,10 @@ async dispose() {

add(disposable, timeout, name) {
if (this.disposables.has(name)) {
throw new Error(`Disposable with name "${name}" already exists`);
}
this.disposables.set(name, { dispose: disposable, timeout, name });
this.disposables.add({ dispose: disposable, timeout, name });
}
remove(target) {
var _a;
const name = typeof target === 'string' ? target : (_a = (0, common_1.find)(this.disposables, ([_, d]) => d.dispose === target)) === null || _a === void 0 ? void 0 : _a[0];
if (!name) {
const oldSize = this.disposables.size;
this.disposables = new Set((0, common_1.filter)(this.disposables, (d) => d.dispose !== target));
if (oldSize === this.disposables.size) {
throw new Error(`Disposable not found`);
}
if (!this.disposables.has(name)) {
throw new Error(`Disposable with name "${name}" not found`);
}
this.disposables.delete(name);
}

@@ -44,0 +37,0 @@ list() {

@@ -11,3 +11,2 @@ /**

remove(disposable: Disposable): void;
remove(name: string): void;
list(): {

@@ -14,0 +13,0 @@ name: string;

@@ -1,2 +0,2 @@

import { find } from '@wixc3/common';
import { filter } from '@wixc3/common';
import { timeout } from 'promise-assist';

@@ -12,3 +12,3 @@ /**

constructor() {
this.disposables = new Map();
this.disposables = new Set();
}

@@ -23,17 +23,10 @@ async dispose() {

add(disposable, timeout, name) {
if (this.disposables.has(name)) {
throw new Error(`Disposable with name "${name}" already exists`);
}
this.disposables.set(name, { dispose: disposable, timeout, name });
this.disposables.add({ dispose: disposable, timeout, name });
}
remove(target) {
var _a;
const name = typeof target === 'string' ? target : (_a = find(this.disposables, ([_, d]) => d.dispose === target)) === null || _a === void 0 ? void 0 : _a[0];
if (!name) {
const oldSize = this.disposables.size;
this.disposables = new Set(filter(this.disposables, (d) => d.dispose !== target));
if (oldSize === this.disposables.size) {
throw new Error(`Disposable not found`);
}
if (!this.disposables.has(name)) {
throw new Error(`Disposable with name "${name}" not found`);
}
this.disposables.delete(name);
}

@@ -40,0 +33,0 @@ list() {

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

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

@@ -1,2 +0,2 @@

import { find } from '@wixc3/common';
import { filter } from '@wixc3/common';
import { timeout } from 'promise-assist';

@@ -13,3 +13,3 @@

export class Disposables {
private disposables = new Map<string, NamedDisposable>();
private disposables = new Set<NamedDisposable>();
async dispose() {

@@ -28,20 +28,12 @@ const _disposables = Array.from(this.disposables.values()).reverse();

add(disposable: Disposable, timeout: number, name: string) {
if (this.disposables.has(name)) {
throw new Error(`Disposable with name "${name}" already exists`);
}
this.disposables.set(name, { dispose: disposable, timeout, name });
this.disposables.add({ dispose: disposable, timeout, name });
}
remove(disposable: Disposable): void;
remove(name: string): void;
remove(target: string | Disposable): void {
const name =
typeof target === 'string' ? target : find(this.disposables, ([_, d]) => d.dispose === target)?.[0];
if (!name) {
remove(target: Disposable): void {
const oldSize = this.disposables.size;
this.disposables = new Set(filter(this.disposables, (d) => d.dispose !== target));
if (oldSize === this.disposables.size) {
throw new Error(`Disposable not found`);
}
if (!this.disposables.has(name)) {
throw new Error(`Disposable with name "${name}" not found`);
}
this.disposables.delete(name);
}

@@ -48,0 +40,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

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