New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cdellacqua/signals

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cdellacqua/signals - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

6

dist/index.d.ts

@@ -28,8 +28,2 @@ /** A generic subscriber that takes a value emitted by a signal as its only parameter. */

emit(v: T): void;
/**
* Emit a value to a specific subscriber of this signal.
* @param subscriber the subscriber that will receive the value.
* @param v the value to emit.
*/
emitFor(subscriber: Subscriber<T>, v: T): void;
};

@@ -36,0 +30,0 @@ /**

@@ -64,8 +64,2 @@ function deriveSignal(signal$, transform) {

}
function emitFor(subscriber, v) {
const index = subscribers.indexOf(subscriber);
if (index !== -1) {
subscriber(v);
}
}
function unsubscribe(subscriber) {

@@ -86,3 +80,2 @@ const index = subscribers.indexOf(subscriber);

emit,
emitFor,
subscribe,

@@ -89,0 +82,0 @@ get nOfSubscriptions() {

2

dist/index.umd.js

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

(function(s,r){typeof exports=="object"&&typeof module!="undefined"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(s=typeof globalThis!="undefined"?globalThis:s||self,r(s.signals={}))})(this,function(s){"use strict";function r(i,u){const c=b(),o=e=>{c.emit(u(e))},t=()=>{n&&c.nOfSubscriptions===0&&(n(),n=null)};let n=null;return{get nOfSubscriptions(){return c.nOfSubscriptions},subscribe:e=>{const f=c.subscribe(e);return n||(n=i.subscribe(o)),()=>{f(),t()}}}}function l(i){const u=b(),c=n=>{u.emit(n)},o=()=>{t&&u.nOfSubscriptions===0&&(t.forEach(n=>n()),t=null)};let t=null;return{get nOfSubscriptions(){return u.nOfSubscriptions},subscribe:n=>{const e=u.subscribe(n);return t||(t=i.map(f=>f.subscribe(c))),()=>{e(),o()}}}}function b(){const i=[];function u(n){for(const e of i)e(n)}function c(n,e){i.indexOf(n)!==-1&&n(e)}function o(n){const e=i.indexOf(n);e!==-1&&i.splice(e,1)}function t(n){return i.indexOf(n)===-1&&i.push(n),()=>o(n)}return{emit:u,emitFor:c,subscribe:t,get nOfSubscriptions(){return i.length}}}s.coalesceSignals=l,s.deriveSignal=r,s.makeSignal=b,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="Module"});
(function(s,c){typeof exports=="object"&&typeof module!="undefined"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(s=typeof globalThis!="undefined"?globalThis:s||self,c(s.signals={}))})(this,function(s){"use strict";function c(i,t){const u=b(),r=o=>{u.emit(t(o))},e=()=>{n&&u.nOfSubscriptions===0&&(n(),n=null)};let n=null;return{get nOfSubscriptions(){return u.nOfSubscriptions},subscribe:o=>{const f=u.subscribe(o);return n||(n=i.subscribe(r)),()=>{f(),e()}}}}function l(i){const t=b(),u=n=>{t.emit(n)},r=()=>{e&&t.nOfSubscriptions===0&&(e.forEach(n=>n()),e=null)};let e=null;return{get nOfSubscriptions(){return t.nOfSubscriptions},subscribe:n=>{const o=t.subscribe(n);return e||(e=i.map(f=>f.subscribe(u))),()=>{o(),r()}}}}function b(){const i=[];function t(e){for(const n of i)n(e)}function u(e){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}function r(e){return i.indexOf(e)===-1&&i.push(e),()=>u(e)}return{emit:t,subscribe:r,get nOfSubscriptions(){return i.length}}}s.coalesceSignals=l,s.deriveSignal=c,s.makeSignal=b,Object.defineProperty(s,"__esModule",{value:!0}),s[Symbol.toStringTag]="Module"});

@@ -5,3 +5,3 @@ {

"description": "A simple signal pattern implementation that enables reactive programming",
"version": "3.0.1",
"version": "4.0.0",
"type": "module",

@@ -8,0 +8,0 @@ "types": "dist/index.d.ts",

@@ -32,3 +32,2 @@ # @cdellacqua/signals

- `emit(value)`, to emit a value to all subscribers;
- `emitFor(subscriber, value)`, to emit a value to a specific subscriber;

@@ -144,7 +143,7 @@ When you subscribe to a signal, you get a unsubscribe function, e.g.:

When you coalesce or derive a signal, you get back a `ReadonlySignal<T>`.
This type lacks the `emit` and `emitFor` methods.
This type lacks the `emit` method.
A `Signal<T>` is in fact an extension of a `ReadonlySignal<T>` that adds the aforementioned methods.
A `Signal<T>` is in fact an extension of a `ReadonlySignal<T>` that adds the `emit` method.
As a rule of thumb, it is preferable to pass around `ReadonlySignal<T>`s,
to better encapsulate your signals and prevent unwanted `emit`s.

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