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

@phosphor/disposable

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@phosphor/disposable - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

LICENSE

56

lib/index.d.ts
import { IterableOrArrayLike } from '@phosphor/algorithm';
import { ISignal } from '@phosphor/signaling';
/**

@@ -27,2 +28,11 @@ * An object which implements the disposable pattern.

/**
* A disposable object with an observable `disposed` signal.
*/
export interface IObservableDisposable extends IDisposable {
/**
* A signal emitted when the object is disposed.
*/
readonly disposed: ISignal<this, void>;
}
/**
* A disposable object which delegates to a callback function.

@@ -48,2 +58,16 @@ */

/**
* An observable disposable object which delegates to a callback function.
*/
export declare class ObservableDisposableDelegate extends DisposableDelegate implements IObservableDisposable {
/**
* A signal emitted when the delegate is disposed.
*/
readonly disposed: ISignal<this, void>;
/**
* Dispose of the delegate and invoke the callback function.
*/
dispose(): void;
private _disposed;
}
/**
* An object which manages a collection of disposable items.

@@ -97,3 +121,3 @@ */

clear(): void;
private _disposed;
private _isDisposed;
private _items;

@@ -114,1 +138,31 @@ }

}
/**
* An observable object which manages a collection of disposable items.
*/
export declare class ObservableDisposableSet extends DisposableSet implements IObservableDisposable {
/**
* A signal emitted when the set is disposed.
*/
readonly disposed: ISignal<this, void>;
/**
* Dispose of the set and the items it contains.
*
* #### Notes
* Items are disposed in the order they are added to the set.
*/
dispose(): void;
private _disposed;
}
/**
* The namespace for the `ObservableDisposableSet` class statics.
*/
export declare namespace ObservableDisposableSet {
/**
* Create an observable disposable set from an iterable of items.
*
* @param items - The iterable or array-like object of interest.
*
* @returns A new disposable initialized with the given items.
*/
function from(items: IterableOrArrayLike<IDisposable>): ObservableDisposableSet;
}
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
}
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });

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

var algorithm_1 = require("@phosphor/algorithm");
var signaling_1 = require("@phosphor/signaling");
/**

@@ -49,2 +63,36 @@ * A disposable object which delegates to a callback function.

/**
* An observable disposable object which delegates to a callback function.
*/
var ObservableDisposableDelegate = /** @class */ (function (_super) {
__extends(ObservableDisposableDelegate, _super);
function ObservableDisposableDelegate() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._disposed = new signaling_1.Signal(_this);
return _this;
}
Object.defineProperty(ObservableDisposableDelegate.prototype, "disposed", {
/**
* A signal emitted when the delegate is disposed.
*/
get: function () {
return this._disposed;
},
enumerable: true,
configurable: true
});
/**
* Dispose of the delegate and invoke the callback function.
*/
ObservableDisposableDelegate.prototype.dispose = function () {
if (this.isDisposed) {
return;
}
_super.prototype.dispose.call(this);
this._disposed.emit(undefined);
signaling_1.Signal.clearData(this);
};
return ObservableDisposableDelegate;
}(DisposableDelegate));
exports.ObservableDisposableDelegate = ObservableDisposableDelegate;
/**
* An object which manages a collection of disposable items.

@@ -57,3 +105,3 @@ */

function DisposableSet() {
this._disposed = false;
this._isDisposed = false;
this._items = new Set();

@@ -66,3 +114,3 @@ }

get: function () {
return this._disposed;
return this._isDisposed;
},

@@ -79,6 +127,6 @@ enumerable: true,

DisposableSet.prototype.dispose = function () {
if (this._disposed) {
if (this._isDisposed) {
return;
}
this._disposed = true;
this._isDisposed = true;
this._items.forEach(function (item) { item.dispose(); });

@@ -147,1 +195,57 @@ this._items.clear();

exports.DisposableSet = DisposableSet;
/**
* An observable object which manages a collection of disposable items.
*/
var ObservableDisposableSet = /** @class */ (function (_super) {
__extends(ObservableDisposableSet, _super);
function ObservableDisposableSet() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._disposed = new signaling_1.Signal(_this);
return _this;
}
Object.defineProperty(ObservableDisposableSet.prototype, "disposed", {
/**
* A signal emitted when the set is disposed.
*/
get: function () {
return this._disposed;
},
enumerable: true,
configurable: true
});
/**
* Dispose of the set and the items it contains.
*
* #### Notes
* Items are disposed in the order they are added to the set.
*/
ObservableDisposableSet.prototype.dispose = function () {
if (this.isDisposed) {
return;
}
_super.prototype.dispose.call(this);
this._disposed.emit(undefined);
signaling_1.Signal.clearData(this);
};
return ObservableDisposableSet;
}(DisposableSet));
exports.ObservableDisposableSet = ObservableDisposableSet;
/**
* The namespace for the `ObservableDisposableSet` class statics.
*/
(function (ObservableDisposableSet) {
/**
* Create an observable disposable set from an iterable of items.
*
* @param items - The iterable or array-like object of interest.
*
* @returns A new disposable initialized with the given items.
*/
function from(items) {
var set = new ObservableDisposableSet();
algorithm_1.each(items, function (item) { set.add(item); });
return set;
}
ObservableDisposableSet.from = from;
})(ObservableDisposableSet = exports.ObservableDisposableSet || (exports.ObservableDisposableSet = {}));
exports.ObservableDisposableSet = ObservableDisposableSet;

8

package.json
{
"name": "@phosphor/disposable",
"version": "1.1.3",
"version": "1.2.0",
"description": "PhosphorJS - Disposable",

@@ -43,3 +43,4 @@ "homepage": "https://github.com/phosphorjs/phosphor",

"dependencies": {
"@phosphor/algorithm": "^1.1.3"
"@phosphor/algorithm": "^1.1.3",
"@phosphor/signaling": "^1.2.3"
},

@@ -61,3 +62,4 @@ "devDependencies": {

"webpack": "^2.2.1"
}
},
"gitHead": "e68b5791676599c99afe6c3be6e64f02b6d01862"
}
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