Socket
Socket
Sign inDemoInstall

suub

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

suub - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

dist/examples/options.d.ts

1

dist/index.d.ts

@@ -24,1 +24,2 @@ export declare type SubscriptionCallback<T> = [T] extends [void] ? (() => void) : ((value: T) => void);

};
export {};

24

dist/suub.cjs.development.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var Subscription = {

@@ -59,24 +61,2 @@ create: function create(options) {

if (subId !== null) {
// if subId and listener is the same...
if (alreadySubscribed && alreadySubscribed.listener === listener) {
// just return the unsub
return alreadySubscribed.unsubscribe;
} // otherwise unsub the previous one
unsubscribe(subId);
}
if (subId === null) {
// if the listener is already sub, just return the unsub
var _alreadySubscribed = listeners.find(function (l) {
return l.listener === listener;
});
if (_alreadySubscribed) {
return _alreadySubscribed.unsubscribe;
}
}
var isSubscribed = true;

@@ -83,0 +63,0 @@ listeners.push({

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

"use strict";exports.Subscription={create:function(n){void 0===n&&(n={});var r=n.onFirstSubscription,i=n.onLastUnsubscribe,e=[],t=[];function u(n){if("string"!=typeof n){var r=e.find((function(r){return r.listener===n}));r&&r.unsubscribe()}else{var i=e.find((function(r){return r.subId===n}));i&&i.unsubscribe()}}return{subscribe:function(n,s){var f="string"==typeof n?n:null,c="string"==typeof n?s:n;if("function"!=typeof c)throw new Error("Expected the listener to be a function.");var o=e.find(null===f?function(n){return n.listener===c}:function(n){return n.subId===f});if(o){if(null===f||o.listener===c){var l=e.indexOf(o);return e.splice(l,1),e.push(o),o.unsubscribe}null!==f&&u(f)}if(null!==f){if(o&&o.listener===c)return o.unsubscribe;u(f)}if(null===f){var b=e.find((function(n){return n.listener===c}));if(b)return b.unsubscribe}var d=!0;function a(){if(d){d=!1;var n=e.findIndex((function(n){return n.listener===c}));n>=0&&e.splice(n,1),0===e.length&&i&&i();var r=t.findIndex((function(n){return n.listener===c}));r>=0&&t.splice(r,1)}}return e.push({subId:f,listener:c,unsubscribe:a}),1===e.length&&r&&r(),a},unsubscribe:u,unsubscribeAll:function(){for(;e.length>0;)e[0].unsubscribe()},isSubscribed:function(n){return"string"==typeof n?void 0!==e.find((function(r){return r.subId===n})):void 0!==e.find((function(r){return r.listener===n}))},call:function(n){for(t=[].concat(e);t.length>0;){var r=t.shift();r&&r.listener(n)}}}}};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Subscription={create:function(n){void 0===n&&(n={});var e=n.onFirstSubscription,r=n.onLastUnsubscribe,i=[],t=[];function u(n){if("string"!=typeof n){var e=i.find((function(e){return e.listener===n}));e&&e.unsubscribe()}else{var r=i.find((function(e){return e.subId===n}));r&&r.unsubscribe()}}return{subscribe:function(n,s){var c="string"==typeof n?n:null,f="string"==typeof n?s:n;if("function"!=typeof f)throw new Error("Expected the listener to be a function.");var o=i.find(null===c?function(n){return n.listener===f}:function(n){return n.subId===c});if(o){if(null===c||o.listener===f){var l=i.indexOf(o);return i.splice(l,1),i.push(o),o.unsubscribe}null!==c&&u(c)}var b=!0;function d(){if(b){b=!1;var n=i.findIndex((function(n){return n.listener===f}));n>=0&&i.splice(n,1),0===i.length&&r&&r();var e=t.findIndex((function(n){return n.listener===f}));e>=0&&t.splice(e,1)}}return i.push({subId:c,listener:f,unsubscribe:d}),1===i.length&&e&&e(),d},unsubscribe:u,unsubscribeAll:function(){for(;i.length>0;)i[0].unsubscribe()},isSubscribed:function(n){return"string"==typeof n?void 0!==i.find((function(e){return e.subId===n})):void 0!==i.find((function(e){return e.listener===n}))},call:function(n){for(t=[].concat(i);t.length>0;){var e=t.shift();e&&e.listener(n)}}}}};
//# sourceMappingURL=suub.cjs.production.min.js.map

@@ -57,24 +57,2 @@ var Subscription = {

if (subId !== null) {
// if subId and listener is the same...
if (alreadySubscribed && alreadySubscribed.listener === listener) {
// just return the unsub
return alreadySubscribed.unsubscribe;
} // otherwise unsub the previous one
unsubscribe(subId);
}
if (subId === null) {
// if the listener is already sub, just return the unsub
var _alreadySubscribed = listeners.find(function (l) {
return l.listener === listener;
});
if (_alreadySubscribed) {
return _alreadySubscribed.unsubscribe;
}
}
var isSubscribed = true;

@@ -81,0 +59,0 @@ listeners.push({

{
"name": "suub",
"version": "1.4.2",
"version": "1.5.0",
"license": "MIT",

@@ -16,3 +16,3 @@ "author": "Etienne Dldc <e.deladonchamps@gmail.com>",

"test": "tsdx test",
"pub": "np",
"pub": "yarn build && np",
"examples": "ts-node ./scripts/run-examples.ts"

@@ -24,10 +24,10 @@ },

"@types/inquirer": "^6.5.0",
"@types/jest": "^24.0.19",
"@types/jest": "^24.9.0",
"fs-extra": "^8.1.0",
"inquirer": "^7.0.0",
"np": "^5.1.3",
"ts-node": "^8.4.1",
"tsdx": "^0.10.5",
"inquirer": "^7.0.3",
"np": "^5.2.1",
"ts-node": "^8.6.2",
"tsdx": "^0.12.3",
"tslib": "^1.10.0",
"typescript": "^3.6.4"
"typescript": "^3.7.5"
},

@@ -34,0 +34,0 @@ "description": "A simple pub/sub written in Typescript",

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