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

comsync

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comsync - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

2

dist/index.d.ts

@@ -5,5 +5,7 @@ import { Channel } from "sync-message";

readonly type = "InterruptError";
readonly name = "InterruptError";
}
export declare class NoChannelError extends Error {
readonly type = "NoChannelError";
readonly name = "NoChannelError";
}

@@ -10,0 +12,0 @@ export declare class SyncClient<T = any> {

2

dist/index.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("sync-message"),require("comlink")):"function"==typeof define&&define.amd?define(["sync-message","comlink"],t):"object"==typeof exports?exports.comsync=t(require("sync-message"),require("comlink")):e.comsync=t(e["sync-message"],e.comlink)}(self,(function(e,t){return(()=>{"use strict";var s={272:e=>{e.exports=t},746:t=>{t.exports=e}},r={};function i(e){var t=r[e];if(void 0!==t)return t.exports;var n=r[e]={exports:{}};return s[e](n,n.exports,i),n.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{InterruptError:()=>r,NoChannelError:()=>o,SyncClient:()=>a,syncExpose:()=>h});var e=i(746),t=i(272),s=function(e,t,s,r){return new(s||(s=Promise))((function(i,n){function o(e){try{h(r.next(e))}catch(e){n(e)}}function a(e){try{h(r.throw(e))}catch(e){n(e)}}function h(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}h((r=r.apply(e,t||[])).next())}))};class r extends Error{constructor(){super(...arguments),this.type="InterruptError"}}class o extends Error{constructor(){super(...arguments),this.type="NoChannelError"}}class a{constructor(e,t){this.workerCreator=e,this.channel=t,this.state="idle",this._messageIdBase="",this._messageIdSeq=0,this._start()}interrupt(){return s(this,void 0,void 0,(function*(){"idle"!==this.state&&("awaitingMessage"!==this.state&&"sleeping"!==this.state?this.interrupter?yield this.interrupter():(this.terminate(),this._start()):yield this._writeMessage({interrupted:!0}))}))}call(r,...i){return s(this,void 0,void 0,(function*(){if("idle"!==this.state)throw new Error(`State is ${this.state}, not idle`);let s=!0;this.state="running",this._messageIdBase=(0,e.uuidv4)(),this._messageIdSeq=0;const n=e=>{var t;s&&"init"!==e&&("reading"===e?(this.state="awaitingMessage",this._messageIdSeq++,null===(t=this._awaitingMessageResolve)||void 0===t||t.call(this)):"sleeping"===e?(this.state="sleeping",this._messageIdSeq++):"slept"===e&&(this.state="running"))};this._interruptPromise=new Promise(((e,t)=>this._interruptRejector=t));try{return yield Promise.race([r(this.channel,t.proxy(n),this._messageIdBase,...i),this._interruptPromise])}finally{s=!1,this._reset()}}))}writeMessage(e){return s(this,void 0,void 0,(function*(){if("idle"===this.state||!this._messageIdBase)throw new Error("No active call to send a message to.");if("awaitingMessage"!==this.state){if(this._awaitingMessageResolve)throw new Error("Not waiting for message, and another write is already queued.");yield new Promise((e=>{this._awaitingMessageResolve=e})),delete this._awaitingMessageResolve}yield this._writeMessage({message:e})}))}terminate(){var e;null===(e=this._interruptRejector)||void 0===e||e.call(this,new r("Worker terminated")),this.workerProxy[t.releaseProxy](),this.worker.terminate(),delete this.workerProxy,delete this.worker}_writeMessage(t){return s(this,void 0,void 0,(function*(){this.state="running";const s=l(this._messageIdBase,this._messageIdSeq);yield(0,e.writeMessage)(this.channel,t,s)}))}_start(){this._reset(),this.worker=this.workerCreator(),this.workerProxy=t.wrap(this.worker)}_reset(){this.state="idle",delete this._interruptPromise,delete this._interruptRejector,delete this._awaitingMessageResolve,delete this._messageIdBase}}function h(t){return function(i,n,a,...h){return s(this,void 0,void 0,(function*(){yield n("init");let s=0;function u(t,h){if(!i)throw new o;n(t);const u=l(a,++s),d=(0,e.readMessage)(i,u,h);if(d){const{message:e,interrupted:t}=d;if(t)throw new r;return e}"sleeping"===t&&n("slept")}return t({channel:i,readMessage:()=>u("reading"),syncSleep(e){e>0&&u("sleeping",{timeout:e})}},...h)}))}}function l(e,t){return`${e}-${t}`}})(),n})()}));
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("sync-message"),require("comlink")):"function"==typeof define&&define.amd?define(["sync-message","comlink"],t):"object"==typeof exports?exports.comsync=t(require("sync-message"),require("comlink")):e.comsync=t(e["sync-message"],e.comlink)}(self,(function(e,t){return(()=>{"use strict";var s={272:e=>{e.exports=t},746:t=>{t.exports=e}},r={};function i(e){var t=r[e];if(void 0!==t)return t.exports;var n=r[e]={exports:{}};return s[e](n,n.exports,i),n.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{i.r(n),i.d(n,{InterruptError:()=>r,NoChannelError:()=>o,SyncClient:()=>a,syncExpose:()=>h});var e=i(746),t=i(272),s=function(e,t,s,r){return new(s||(s=Promise))((function(i,n){function o(e){try{h(r.next(e))}catch(e){n(e)}}function a(e){try{h(r.throw(e))}catch(e){n(e)}}function h(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}h((r=r.apply(e,t||[])).next())}))};class r extends Error{constructor(){super(...arguments),this.type="InterruptError",this.name=this.type}}class o extends Error{constructor(){super(...arguments),this.type="NoChannelError",this.name=this.type}}class a{constructor(e,t){this.workerCreator=e,this.channel=t,this.state="idle",this._messageIdBase="",this._messageIdSeq=0,this._start()}interrupt(){return s(this,void 0,void 0,(function*(){"idle"!==this.state&&("awaitingMessage"!==this.state&&"sleeping"!==this.state?this.interrupter?yield this.interrupter():(this.terminate(),this._start()):yield this._writeMessage({interrupted:!0}))}))}call(r,...i){return s(this,void 0,void 0,(function*(){if("idle"!==this.state)throw new Error(`State is ${this.state}, not idle`);let s=!0;this.state="running",this._messageIdBase=(0,e.uuidv4)(),this._messageIdSeq=0;const n=e=>{var t;s&&"init"!==e&&("reading"===e?(this.state="awaitingMessage",this._messageIdSeq++,null===(t=this._awaitingMessageResolve)||void 0===t||t.call(this)):"sleeping"===e?(this.state="sleeping",this._messageIdSeq++):"slept"===e&&(this.state="running"))};this._interruptPromise=new Promise(((e,t)=>this._interruptRejector=t));try{return yield Promise.race([r(this.channel,t.proxy(n),this._messageIdBase,...i),this._interruptPromise])}finally{s=!1,this._reset()}}))}writeMessage(e){return s(this,void 0,void 0,(function*(){if("idle"===this.state||!this._messageIdBase)throw new Error("No active call to send a message to.");if("awaitingMessage"!==this.state){if(this._awaitingMessageResolve)throw new Error("Not waiting for message, and another write is already queued.");yield new Promise((e=>{this._awaitingMessageResolve=e})),delete this._awaitingMessageResolve}yield this._writeMessage({message:e})}))}terminate(){var e;null===(e=this._interruptRejector)||void 0===e||e.call(this,new r("Worker terminated")),this.workerProxy[t.releaseProxy](),this.worker.terminate(),delete this.workerProxy,delete this.worker}_writeMessage(t){return s(this,void 0,void 0,(function*(){this.state="running";const s=l(this._messageIdBase,this._messageIdSeq);yield(0,e.writeMessage)(this.channel,t,s)}))}_start(){this._reset(),this.worker=this.workerCreator(),this.workerProxy=t.wrap(this.worker)}_reset(){this.state="idle",delete this._interruptPromise,delete this._interruptRejector,delete this._awaitingMessageResolve,delete this._messageIdBase}}function h(t){return function(i,n,a,...h){return s(this,void 0,void 0,(function*(){yield n("init");let s=0;function u(t,h){if(!i)throw new o;n(t);const u=l(a,++s),d=(0,e.readMessage)(i,u,h);if(d){const{message:e,interrupted:t}=d;if(t)throw new r;return e}"sleeping"===t&&n("slept")}return t({channel:i,readMessage:()=>u("reading"),syncSleep(e){e>0&&u("sleeping",{timeout:e})}},...h)}))}}function l(e,t){return`${e}-${t}`}})(),n})()}));
//# sourceMappingURL=index.js.map

@@ -7,2 +7,3 @@ import {Channel, readMessage, uuidv4, writeMessage} from "sync-message";

public readonly type = "InterruptError";
public readonly name = this.type;
}

@@ -13,2 +14,3 @@

public readonly type = "NoChannelError";
public readonly name = this.type;
}

@@ -15,0 +17,0 @@

{
"name": "comsync",
"version": "0.0.8",
"version": "0.0.9",
"private": false,

@@ -5,0 +5,0 @@ "repository": {

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