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

@dadajam4/async-combiner

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dadajam4/async-combiner - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

13

dist/async-combiner.common.js
/*!
* async-combiner v0.1.3
* (c) 2020 dadajam4
* async-combiner v0.2.0
* (c) 2021 dadajam4
* Released under the MIT License.

@@ -124,6 +124,5 @@ */

if (sameRunning) {
if (sameRunning.delay && !sameRunning.delay.triggered) {
sameRunning.delay.run();
}
// if (sameRunning.delay && !sameRunning.delay.triggered) {
// sameRunning.delay.run();
// }
sameRunning.resolvers.push(resolver);

@@ -154,3 +153,3 @@ return;

run() {
this.clear();
// this.clear();
this.timer = setTimeout(newRunning.exec, delay);

@@ -157,0 +156,0 @@ },

/*!
* async-combiner v0.1.3
* (c) 2020 dadajam4
* async-combiner v0.2.0
* (c) 2021 dadajam4
* Released under the MIT License.

@@ -120,6 +120,5 @@ */

if (sameRunning) {
if (sameRunning.delay && !sameRunning.delay.triggered) {
sameRunning.delay.run();
}
// if (sameRunning.delay && !sameRunning.delay.triggered) {
// sameRunning.delay.run();
// }
sameRunning.resolvers.push(resolver);

@@ -150,3 +149,3 @@ return;

run() {
this.clear();
// this.clear();
this.timer = setTimeout(newRunning.exec, delay);

@@ -153,0 +152,0 @@ },

/*!
* async-combiner v0.1.3
* (c) 2020 dadajam4
* async-combiner v0.2.0
* (c) 2021 dadajam4
* Released under the MIT License.

@@ -126,6 +126,5 @@ */

if (sameRunning) {
if (sameRunning.delay && !sameRunning.delay.triggered) {
sameRunning.delay.run();
}
// if (sameRunning.delay && !sameRunning.delay.triggered) {
// sameRunning.delay.run();
// }
sameRunning.resolvers.push(resolver);

@@ -156,3 +155,3 @@ return;

run() {
this.clear();
// this.clear();
this.timer = setTimeout(newRunning.exec, delay);

@@ -159,0 +158,0 @@ },

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).AsyncCombiner={})}(this,(function(e){"use strict";const n=["string","number","boolean","undefined"];function t(e){const t=typeof e;return!!n.includes(t)||(null===e||e instanceof Date)}function o(e,n,r){return t(e)&&(e={"_async-combiner-condition_":e}),Object.keys(e).forEach(c=>{let i,s=e[c];var l;i=void 0===r?c:r+"."+c,l=s,Array.isArray(l)||l&&"object"==typeof l&&"Object"===l.constructor.name?o(s,n,i):t(s)&&(s instanceof Date&&(s=s.toString()),n[i]=s)}),n}function r(...e){const n={};return o(e,n),n}function c(e,n){const t=Object.keys(e),o=Object.keys(n);return t.length===o.length&&t.every(t=>e[t]===n[t])}function i(e={}){const n=[],{clone:t=!0}=e;function r(e,t,o){const r=n.find(n=>c(n.condition,e));if(!r)return;const i="resolve"===t;r.resolvers.forEach(e=>{const n=r.clone&&i&&o&&"object"==typeof o?JSON.parse(JSON.stringify(o)):o;e[t](n)}),r.resolvers=[],n.splice(n.indexOf(r),1)}return{combine:function(i,s,l=t,u=e.delay){return new Promise((e,t)=>{const a={resolve:e,reject:t},f=function(e){const n={};return o(e,n),n}(i),d=n.find(e=>c(e.condition,f));if(d)return d.delay&&!d.delay.triggered&&d.delay.run(),void d.resolvers.push(a);const y={condition:f,resolvers:[a],clone:l,exec:()=>{y.delay&&(y.delay.clear(),y.delay.triggered=!0),s().then(e=>{r(f,"resolve",e)}).catch(e=>{r(f,"reject",e)})},delay:u?{timer:null,triggered:!1,run(){this.clear(),this.timer=setTimeout(y.exec,u)},clear(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)}}:null};n.push(y);try{y.delay?y.delay.run():y.exec()}catch(e){r(f,"reject",e)}})},_runnings:n,_resolveResolvers:r}}e.AsyncCombiner=class{constructor(){const e=i();this.$asyncCombinerContext=e,this.$asyncCombine=e.combine}},e.Combine=function(e){const n="function"==typeof e?{createCondition:e}:e||{},{createCondition:t=r}=n;return(e,o,r)=>{let c=r.value;if(!c)throw new TypeError("missing combine function");const s=i(n);r.value=function(...e){const o=t(...e);return s.combine(o,()=>c.call(this,...e),n.clone)}}},e.createCombinerContext=i,e.createCondition=r,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e=e||self).AsyncCombiner={})}(this,(function(e){"use strict";const n=["string","number","boolean","undefined"];function t(e){const t=typeof e;return!!n.includes(t)||(null===e||e instanceof Date)}function o(e,n,r){return t(e)&&(e={"_async-combiner-condition_":e}),Object.keys(e).forEach(c=>{let i,s=e[c];var u;i=void 0===r?c:r+"."+c,u=s,Array.isArray(u)||u&&"object"==typeof u&&"Object"===u.constructor.name?o(s,n,i):t(s)&&(s instanceof Date&&(s=s.toString()),n[i]=s)}),n}function r(...e){const n={};return o(e,n),n}function c(e,n){const t=Object.keys(e),o=Object.keys(n);return t.length===o.length&&t.every(t=>e[t]===n[t])}function i(e={}){const n=[],{clone:t=!0}=e;function r(e,t,o){const r=n.find(n=>c(n.condition,e));if(!r)return;const i="resolve"===t;r.resolvers.forEach(e=>{const n=r.clone&&i&&o&&"object"==typeof o?JSON.parse(JSON.stringify(o)):o;e[t](n)}),r.resolvers=[],n.splice(n.indexOf(r),1)}return{combine:function(i,s,u=t,l=e.delay){return new Promise((e,t)=>{const f={resolve:e,reject:t},a=function(e){const n={};return o(e,n),n}(i),d=n.find(e=>c(e.condition,a));if(d)return void d.resolvers.push(f);const y={condition:a,resolvers:[f],clone:u,exec:()=>{y.delay&&(y.delay.clear(),y.delay.triggered=!0),s().then(e=>{r(a,"resolve",e)}).catch(e=>{r(a,"reject",e)})},delay:l?{timer:null,triggered:!1,run(){this.timer=setTimeout(y.exec,l)},clear(){null!==this.timer&&(clearTimeout(this.timer),this.timer=null)}}:null};n.push(y);try{y.delay?y.delay.run():y.exec()}catch(e){r(a,"reject",e)}})},_runnings:n,_resolveResolvers:r}}e.AsyncCombiner=class{constructor(){const e=i();this.$asyncCombinerContext=e,this.$asyncCombine=e.combine}},e.Combine=function(e){const n="function"==typeof e?{createCondition:e}:e||{},{createCondition:t=r}=n;return(e,o,r)=>{let c=r.value;if(!c)throw new TypeError("missing combine function");const s=i(n);r.value=function(...e){const o=t(...e);return s.combine(o,()=>c.call(this,...e),n.clone)}}},e.createCombinerContext=i,e.createCondition=r,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@dadajam4/async-combiner",
"version": "0.1.3",
"version": "0.2.0",
"description": "Service that combines multiple asynchronous requests into one",

@@ -5,0 +5,0 @@ "main": "dist/async-combiner.common.js",

@@ -96,5 +96,5 @@ import {

if (sameRunning) {
if (sameRunning.delay && !sameRunning.delay.triggered) {
sameRunning.delay.run();
}
// if (sameRunning.delay && !sameRunning.delay.triggered) {
// sameRunning.delay.run();
// }
sameRunning.resolvers.push(resolver);

@@ -126,3 +126,3 @@ return;

run() {
this.clear();
// this.clear();
this.timer = setTimeout(newRunning.exec, delay) as any;

@@ -129,0 +129,0 @@ },

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