Socket
Socket
Sign inDemoInstall

@lumino/signaling

Package Overview
Dependencies
Maintainers
7
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lumino/signaling - npm Package Compare versions

Comparing version 1.10.2 to 1.11.0

54

dist/index.es6.js
import { find, each, ArrayExt } from '@lumino/algorithm';
import { AttachedProperty } from '@lumino/properties';

@@ -60,5 +61,23 @@ // Copyright (c) Jupyter Development Team.

function Signal(sender) {
this._blockedCount = 0;
this.sender = sender;
}
/**
* Block the signal during the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param fn The callback during which the signal is blocked
*/
Signal.prototype.block = function (fn) {
this._blockedCount++;
try {
fn();
}
finally {
this._blockedCount--;
}
};
/**
* Connect a slot to the signal.

@@ -100,3 +119,5 @@ *

Signal.prototype.emit = function (args) {
Private.emit(this, args);
if (!this._blockedCount) {
Private.emit(this, args);
}
};

@@ -110,2 +131,23 @@ return Signal;

/**
* Block all signals emitted by an object during
* the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param sender The signals sender
* @param fn The callback during which all signals are blocked
*/
function blockAll(sender, fn) {
var blockedProperty = Private.blockedProperty;
blockedProperty.set(sender, blockedProperty.get(sender) + 1);
try {
fn();
}
finally {
blockedProperty.set(sender, blockedProperty.get(sender) - 1);
}
}
Signal.blockAll = blockAll;
/**
* Remove all connections between a sender and receiver.

@@ -409,2 +451,5 @@ *

function emit(signal, args) {
if (Private.blockedProperty.get(signal.sender) > 0) {
return;
}
// If there are no receivers, there is nothing to do.

@@ -513,2 +558,9 @@ var receivers = receiversForSender.get(signal.sender);

}
/**
* A property indicating a sender has been blocked if its value is not 0.
*/
Private.blockedProperty = new AttachedProperty({
name: 'blocked',
create: function () { return 0; }
});
})(Private || (Private = {}));

@@ -515,0 +567,0 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@lumino/algorithm')) :
typeof define === 'function' && define.amd ? define(['exports', '@lumino/algorithm'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.lumino_signaling = {}, global.lumino_algorithm));
}(this, (function (exports, algorithm) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@lumino/algorithm'), require('@lumino/properties')) :
typeof define === 'function' && define.amd ? define(['exports', '@lumino/algorithm', '@lumino/properties'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.lumino_signaling = {}, global.lumino_algorithm, global.lumino_properties));
}(this, (function (exports, algorithm, properties) { 'use strict';

@@ -64,5 +64,23 @@ // Copyright (c) Jupyter Development Team.

function Signal(sender) {
this._blockedCount = 0;
this.sender = sender;
}
/**
* Block the signal during the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param fn The callback during which the signal is blocked
*/
Signal.prototype.block = function (fn) {
this._blockedCount++;
try {
fn();
}
finally {
this._blockedCount--;
}
};
/**
* Connect a slot to the signal.

@@ -104,3 +122,5 @@ *

Signal.prototype.emit = function (args) {
Private.emit(this, args);
if (!this._blockedCount) {
Private.emit(this, args);
}
};

@@ -114,2 +134,23 @@ return Signal;

/**
* Block all signals emitted by an object during
* the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param sender The signals sender
* @param fn The callback during which all signals are blocked
*/
function blockAll(sender, fn) {
var blockedProperty = Private.blockedProperty;
blockedProperty.set(sender, blockedProperty.get(sender) + 1);
try {
fn();
}
finally {
blockedProperty.set(sender, blockedProperty.get(sender) - 1);
}
}
Signal.blockAll = blockAll;
/**
* Remove all connections between a sender and receiver.

@@ -413,2 +454,5 @@ *

function emit(signal, args) {
if (Private.blockedProperty.get(signal.sender) > 0) {
return;
}
// If there are no receivers, there is nothing to do.

@@ -517,2 +561,9 @@ var receivers = receiversForSender.get(signal.sender);

}
/**
* A property indicating a sender has been blocked if its value is not 0.
*/
Private.blockedProperty = new properties.AttachedProperty({
name: 'blocked',
create: function () { return 0; }
});
})(Private || (Private = {}));

@@ -519,0 +570,0 @@

2

dist/index.min.js

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

!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@lumino/algorithm")):"function"==typeof define&&define.amd?define(["exports","@lumino/algorithm"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).lumino_signaling={},n.lumino_algorithm)}(this,(function(n,e){"use strict";var t,i;n.Signal=function(){function n(n){this.sender=n}return n.prototype.connect=function(n,e){return i.connect(this,n,e)},n.prototype.disconnect=function(n,e){return i.disconnect(this,n,e)},n.prototype.emit=function(n){i.emit(this,n)},n}(),(t=n.Signal||(n.Signal={})).disconnectBetween=function(n,e){i.disconnectBetween(n,e)},t.disconnectSender=function(n){i.disconnectSender(n)},t.disconnectReceiver=function(n){i.disconnectReceiver(n)},t.disconnectAll=function(n){i.disconnectAll(n)},t.clearData=function(n){i.disconnectAll(n)},t.getExceptionHandler=function(){return i.exceptionHandler},t.setExceptionHandler=function(n){var e=i.exceptionHandler;return i.exceptionHandler=n,e},function(n){function t(n){var t=o.get(n);t&&0!==t.length&&(e.each(t,(function(n){if(n.signal){var e=n.thisArg||n.slot;n.signal=null,u(r.get(e))}})),u(t))}function i(n){var t=r.get(n);t&&0!==t.length&&(e.each(t,(function(n){if(n.signal){var e=n.signal.sender;n.signal=null,u(o.get(e))}})),u(t))}n.exceptionHandler=function(n){console.error(n)},n.connect=function(n,e,t){t=t||void 0;var i=o.get(n.sender);if(i||(i=[],o.set(n.sender,i)),a(i,n,e,t))return!1;var c=t||e,l=r.get(c);l||(l=[],r.set(c,l));var s={signal:n,slot:e,thisArg:t};return i.push(s),l.push(s),!0},n.disconnect=function(n,e,t){t=t||void 0;var i=o.get(n.sender);if(!i||0===i.length)return!1;var c=a(i,n,e,t);if(!c)return!1;var l=t||e,s=r.get(l);return c.signal=null,u(i),u(s),!0},n.disconnectBetween=function(n,t){var i=o.get(n);if(i&&0!==i.length){var c=r.get(t);c&&0!==c.length&&(e.each(c,(function(e){e.signal&&e.signal.sender===n&&(e.signal=null)})),u(i),u(c))}},n.disconnectSender=t,n.disconnectReceiver=i,n.disconnectAll=function(n){t(n),i(n)},n.emit=function(n,e){var t=o.get(n.sender);if(t&&0!==t.length)for(var i=0,r=t.length;i<r;++i){var c=t[i];c.signal===n&&s(c,e)}};var o=new WeakMap,r=new WeakMap,c=new Set,l="function"==typeof requestAnimationFrame?requestAnimationFrame:setImmediate;function a(n,t,i,o){return e.find(n,(function(n){return n.signal===t&&n.slot===i&&n.thisArg===o}))}function s(e,t){var i=e.signal,o=e.slot,r=e.thisArg;try{o.call(r,i.sender,t)}catch(e){n.exceptionHandler(e)}}function u(n){0===c.size&&l(f),c.add(n)}function f(){c.forEach(d),c.clear()}function d(n){e.ArrayExt.removeAllWhere(n,g)}function g(n){return null===n.signal}}(i||(i={})),Object.defineProperty(n,"__esModule",{value:!0})}));
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@lumino/algorithm"),require("@lumino/properties")):"function"==typeof define&&define.amd?define(["exports","@lumino/algorithm","@lumino/properties"],e):e((n="undefined"!=typeof globalThis?globalThis:n||self).lumino_signaling={},n.lumino_algorithm,n.lumino_properties)}(this,(function(n,e,t){"use strict";var i,o;n.Signal=function(){function n(n){this._blockedCount=0,this.sender=n}return n.prototype.block=function(n){this._blockedCount++;try{n()}finally{this._blockedCount--}},n.prototype.connect=function(n,e){return o.connect(this,n,e)},n.prototype.disconnect=function(n,e){return o.disconnect(this,n,e)},n.prototype.emit=function(n){this._blockedCount||o.emit(this,n)},n}(),(i=n.Signal||(n.Signal={})).blockAll=function(n,e){var t=o.blockedProperty;t.set(n,t.get(n)+1);try{e()}finally{t.set(n,t.get(n)-1)}},i.disconnectBetween=function(n,e){o.disconnectBetween(n,e)},i.disconnectSender=function(n){o.disconnectSender(n)},i.disconnectReceiver=function(n){o.disconnectReceiver(n)},i.disconnectAll=function(n){o.disconnectAll(n)},i.clearData=function(n){o.disconnectAll(n)},i.getExceptionHandler=function(){return o.exceptionHandler},i.setExceptionHandler=function(n){var e=o.exceptionHandler;return o.exceptionHandler=n,e},function(n){function i(n){var t=r.get(n);t&&0!==t.length&&(e.each(t,(function(n){if(n.signal){var e=n.thisArg||n.slot;n.signal=null,f(c.get(e))}})),f(t))}function o(n){var t=c.get(n);t&&0!==t.length&&(e.each(t,(function(n){if(n.signal){var e=n.signal.sender;n.signal=null,f(r.get(e))}})),f(t))}n.exceptionHandler=function(n){console.error(n)},n.connect=function(n,e,t){t=t||void 0;var i=r.get(n.sender);if(i||(i=[],r.set(n.sender,i)),u(i,n,e,t))return!1;var o=t||e,l=c.get(o);l||(l=[],c.set(o,l));var s={signal:n,slot:e,thisArg:t};return i.push(s),l.push(s),!0},n.disconnect=function(n,e,t){t=t||void 0;var i=r.get(n.sender);if(!i||0===i.length)return!1;var o=u(i,n,e,t);if(!o)return!1;var l=t||e,s=c.get(l);return o.signal=null,f(i),f(s),!0},n.disconnectBetween=function(n,t){var i=r.get(n);if(i&&0!==i.length){var o=c.get(t);o&&0!==o.length&&(e.each(o,(function(e){e.signal&&e.signal.sender===n&&(e.signal=null)})),f(i),f(o))}},n.disconnectSender=i,n.disconnectReceiver=o,n.disconnectAll=function(n){i(n),o(n)},n.emit=function(e,t){if(!(n.blockedProperty.get(e.sender)>0)){var i=r.get(e.sender);if(i&&0!==i.length)for(var o=0,c=i.length;o<c;++o){var l=i[o];l.signal===e&&a(l,t)}}};var r=new WeakMap,c=new WeakMap,l=new Set,s="function"==typeof requestAnimationFrame?requestAnimationFrame:setImmediate;function u(n,t,i,o){return e.find(n,(function(n){return n.signal===t&&n.slot===i&&n.thisArg===o}))}function a(e,t){var i=e.signal,o=e.slot,r=e.thisArg;try{o.call(r,i.sender,t)}catch(e){n.exceptionHandler(e)}}function f(n){0===l.size&&s(d),l.add(n)}function d(){l.forEach(g),l.clear()}function g(n){e.ArrayExt.removeAllWhere(n,p)}function p(n){return null===n.signal}n.blockedProperty=new t.AttachedProperty({name:"blocked",create:function(){return 0}})}(o||(o={})),Object.defineProperty(n,"__esModule",{value:!0})}));
//# sourceMappingURL=index.min.js.map
{
"name": "@lumino/signaling",
"version": "1.10.2",
"version": "1.11.0",
"description": "Lumino Signals and Slots",

@@ -49,3 +49,4 @@ "homepage": "https://github.com/jupyterlab/lumino",

"dependencies": {
"@lumino/algorithm": "^1.9.2"
"@lumino/algorithm": "^1.9.2",
"@lumino/properties": "^1.8.2"
},

@@ -52,0 +53,0 @@ "devDependencies": {

@@ -11,2 +11,3 @@ // Copyright (c) Jupyter Development Team.

import { ArrayExt, each, find } from '@lumino/algorithm';
import { AttachedProperty } from '@lumino/properties';

@@ -36,2 +37,12 @@ /**

/**
* Block the signal during the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param fn The callback during which the signal is blocked
*/
block(fn: () => void): void;
/**
* Connect a slot to the signal.

@@ -143,2 +154,19 @@ *

/**
* Block the signal during the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param fn The callback during which the signal is blocked
*/
block(fn: () => void): void {
this._blockedCount++;
try {
fn();
} finally {
this._blockedCount--;
}
}
/**
* Connect a slot to the signal.

@@ -182,4 +210,8 @@ *

emit(args: U): void {
Private.emit(this, args);
if (!this._blockedCount) {
Private.emit(this, args);
}
}
private _blockedCount = 0;
}

@@ -192,2 +224,22 @@

/**
* Block all signals emitted by an object during
* the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param sender The signals sender
* @param fn The callback during which all signals are blocked
*/
export function blockAll(sender: unknown, fn: () => void): void {
const { blockedProperty } = Private;
blockedProperty.set(sender, blockedProperty.get(sender) + 1);
try {
fn();
} finally {
blockedProperty.set(sender, blockedProperty.get(sender) - 1);
}
}
/**
* Remove all connections between a sender and receiver.

@@ -532,2 +584,6 @@ *

export function emit<T, U>(signal: Signal<T, U>, args: U): void {
if (Private.blockedProperty.get(signal.sender) > 0) {
return;
}
// If there are no receivers, there is nothing to do.

@@ -674,2 +730,10 @@ let receivers = receiversForSender.get(signal.sender);

}
/**
* A property indicating a sender has been blocked if its value is not 0.
*/
export const blockedProperty = new AttachedProperty<unknown, number>({
name: 'blocked',
create: () => 0
});
}

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

/**
* Block the signal during the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param fn The callback during which the signal is blocked
*/
block(fn: () => void): void;
/**
* Connect a slot to the signal.

@@ -124,2 +133,11 @@ *

/**
* Block the signal during the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param fn The callback during which the signal is blocked
*/
block(fn: () => void): void;
/**
* Connect a slot to the signal.

@@ -157,2 +175,3 @@ *

emit(args: U): void;
private _blockedCount;
}

@@ -164,2 +183,13 @@ /**

/**
* Block all signals emitted by an object during
* the execution of a callback.
*
* ### Notes
* The callback function must be synchronous.
*
* @param sender The signals sender
* @param fn The callback during which all signals are blocked
*/
function blockAll(sender: unknown, fn: () => void): void;
/**
* Remove all connections between a sender and receiver.

@@ -166,0 +196,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

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