Socket
Socket
Sign inDemoInstall

@furystack/utils

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@furystack/utils - npm Package Compare versions

Comparing version 2.0.5 to 2.1.0

2

dist/observable-value.d.ts

@@ -29,2 +29,4 @@ import { Disposable } from './disposable';

export declare class ObservableValue<T> implements Disposable {
get isDisposed(): boolean;
private _isDisposed;
/**

@@ -31,0 +33,0 @@ * Disposes the ObservableValue object, removes all observers

@@ -31,2 +31,3 @@ "use strict";

constructor(initialValue) {
this._isDisposed = false;
this.observers = new Set();

@@ -37,2 +38,5 @@ if (initialValue !== undefined) {

}
get isDisposed() {
return this._isDisposed;
}
/**

@@ -43,2 +47,3 @@ * Disposes the ObservableValue object, removes all observers

this.observers.clear();
this._isDisposed = true;
}

@@ -75,2 +80,5 @@ /**

getValue() {
if (this._isDisposed) {
throw new Error('ObservableValue is already disposed');
}
return this.currentValue;

@@ -84,2 +92,5 @@ }

setValue(newValue) {
if (this._isDisposed) {
throw new Error('ObservableValue is already disposed');
}
if (this.currentValue !== newValue) {

@@ -86,0 +97,0 @@ this.currentValue = newValue;

@@ -83,2 +83,12 @@ "use strict";

});
it('should throw an error for setValue() when the observer has been disposed', () => {
const v = new observable_value_1.ObservableValue(1);
v.dispose();
expect(() => v.setValue(3)).toThrowError('ObservableValue is already disposed');
});
it('should throw an error for setValue() when the observer has been disposed', () => {
const v = new observable_value_1.ObservableValue(1);
v.dispose();
expect(() => v.getValue()).toThrowError('ObservableValue is already disposed');
});
it('should remove the subscription only from the disposed Observer', (done) => {

@@ -85,0 +95,0 @@ class Alma {

2

package.json
{
"name": "@furystack/utils",
"version": "2.0.5",
"version": "2.1.0",
"description": "General utilities",

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

@@ -90,2 +90,14 @@ import { ObservableValue } from './observable-value'

it('should throw an error for setValue() when the observer has been disposed', () => {
const v = new ObservableValue(1)
v.dispose()
expect(() => v.setValue(3)).toThrowError('ObservableValue is already disposed')
})
it('should throw an error for setValue() when the observer has been disposed', () => {
const v = new ObservableValue(1)
v.dispose()
expect(() => v.getValue()).toThrowError('ObservableValue is already disposed')
})
it('should remove the subscription only from the disposed Observer', (done) => {

@@ -92,0 +104,0 @@ class Alma {

@@ -31,2 +31,8 @@ import { Disposable } from './disposable'

export class ObservableValue<T> implements Disposable {
public get isDisposed(): boolean {
return this._isDisposed
}
private _isDisposed = false
/**

@@ -37,2 +43,3 @@ * Disposes the ObservableValue object, removes all observers

this.observers.clear()
this._isDisposed = true
}

@@ -74,2 +81,5 @@ private observers: Set<ValueObserver<T>> = new Set()

public getValue(): T {
if (this._isDisposed) {
throw new Error('ObservableValue is already disposed')
}
return this.currentValue

@@ -84,2 +94,5 @@ }

public setValue(newValue: T) {
if (this._isDisposed) {
throw new Error('ObservableValue is already disposed')
}
if (this.currentValue !== newValue) {

@@ -86,0 +99,0 @@ this.currentValue = newValue

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