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

react-hooks-worker

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hooks-worker - npm Package Compare versions

Comparing version 1.0.0-alpha.1 to 1.0.0-alpha.2

dist/index.modern.js

2

dist/index.umd.js

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

!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((n=n||self).reactHooksWorker={},n.react)}(this,function(n,t){var r={};function e(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function o(n,t,r){if(!n.s){if(r instanceof i){if(!r.s)return void(r.o=o.bind(null,n,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(o.bind(null,n,t),o.bind(null,n,2));n.s=t,n.v=r;var e=n.o;e&&e(n)}}var i=function(){function n(){}return n.prototype.then=function(t,r){var e=new n,i=this.s;if(i){var u=1&i?t:r;if(u){try{o(e,1,u(this.v))}catch(n){o(e,2,n)}return e}return this}return this.o=function(n){try{var i=n.v;1&n.s?o(e,1,t?t(i):i):r?o(e,1,r(i)):o(e,2,i)}catch(n){o(e,2,n)}},e},n}();function u(n){return n instanceof i&&1&n.s}function f(n,t){try{var r=n()}catch(n){return t(!0,n)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}n.exposeWorker=function(n){self.onmessage=function(t){try{var r=n(t.data);return Promise.resolve(function(){if(r[Symbol.asyncIterator]){var n,t=!0,a=!1;return f(function(){return function(n,e){try{var f=function(){var n,e,f=function(n){var t;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(t=n[Symbol.asyncIterator]))return t.call(n);if(Symbol.iterator&&null!=(t=n[Symbol.iterator]))return t.call(n)}throw new TypeError("Object is not async iterable")}(r),a=function(n,t,r){for(var e;;){var f=n();if(u(f)&&(f=f.v),!f)return a;if(f.then){e=0;break}var a=r();if(a&&a.then){if(!u(a)){e=1;break}a=a.s}if(t){var c=t();if(c&&c.then&&!u(c)){e=2;break}}}var s=new i,l=o.bind(null,s,2);return(0===e?f.then(v):1===e?a.then(h):c.then(d)).then(void 0,l),s;function h(e){a=e;do{if(t&&(c=t())&&c.then&&!u(c))return void c.then(d).then(void 0,l);if(!(f=n())||u(f)&&!f.v)return void o(s,1,a);if(f.then)return void f.then(v).then(void 0,l);u(a=r())&&(a=a.v)}while(!a||!a.then);a.then(h).then(void 0,l)}function v(n){n?(a=r())&&a.then?a.then(h).then(void 0,l):h(a):o(s,1,a)}function d(){(f=n())?f.then?f.then(v).then(void 0,l):v(f):o(s,1,a)}}(function(){return!!Promise.resolve(f.next()).then(function(r){return t=n.done,n=r,Promise.resolve(n.value).then(function(n){return e=n,!t})})},function(){return!!(t=!0)},function(){self.postMessage(e)});if(a&&a.then)return a.then(function(){})}()}catch(n){return e(n)}return f&&f.then?f.then(void 0,e):f}(0,function(t){a=!0,n=t})},function(r,e){function o(n){if(r)throw e;return e}var i=f(function(){var n=function(){if(!t&&null!=_iterator.return)return Promise.resolve(_iterator.return()).then(function(){})}();if(n&&n.then)return n.then(function(){})},function(t,r){if(a)throw n;if(t)throw r;return r});return i&&i.then?i.then(o):o()})}var c=function(){if(!r[Symbol.iterator]){var n=self,t=n.postMessage;return Promise.resolve(r).then(function(r){t.call(n,r)})}for(var o,i=function(n,t){var r;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(r=function(n,t){if(n){if("string"==typeof n)return e(n,void 0);var r=Object.prototype.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(n,void 0):void 0}}(n))){r&&(n=r);var o=0;return function(){return o>=n.length?{done:!0}:{done:!1,value:n[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=n[Symbol.iterator]()).next.bind(r)}(r);!(o=i()).done;)self.postMessage(o.value)}();if(c&&c.then)return c.then(function(){})}())}catch(t){return Promise.reject(t)}}},n.useWorker=function(n,e){var o=t.useState(r),i=o[0],u=o[1],f=t.useMemo(n,[n]),a=t.useRef();return t.useEffect(function(){a.current=f;var n=function(n){return u(n)};return f.onmessage=function(t){return n({result:t.data})},f.onerror=function(){return n({error:"error"})},f.onmessageerror=function(){return n({error:"messageerror"})},function(){n=function(){return null},f.terminate(),u(r)}},[f]),t.useEffect(function(){a.current&&a.current.postMessage(e)},[e]),i}});
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((n=n||self).reactHooksWorker={},n.react)}(this,function(n,t){var r={};function e(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=new Array(t);r<t;r++)e[r]=n[r];return e}function o(n,t,r){if(!n.s){if(r instanceof i){if(!r.s)return void(r.o=o.bind(null,n,t));1&t&&(t=r.s),r=r.v}if(r&&r.then)return void r.then(o.bind(null,n,t),o.bind(null,n,2));n.s=t,n.v=r;var e=n.o;e&&e(n)}}var i=function(){function n(){}return n.prototype.then=function(t,r){var e=new n,i=this.s;if(i){var u=1&i?t:r;if(u){try{o(e,1,u(this.v))}catch(n){o(e,2,n)}return e}return this}return this.o=function(n){try{var i=n.v;1&n.s?o(e,1,t?t(i):i):r?o(e,1,r(i)):o(e,2,i)}catch(n){o(e,2,n)}},e},n}();function u(n){return n instanceof i&&1&n.s}function f(n,t){try{var r=n()}catch(n){return t(!0,n)}return r&&r.then?r.then(t.bind(null,!1),t.bind(null,!0)):t(!1,r)}n.exposeWorker=function(n){self.onmessage=function(t){try{var r=n(t.data);return Promise.resolve(function(){if(r[Symbol.asyncIterator]){var n,t=!0,a=!1;return f(function(){return function(n,e){try{var f=function(){var n,e,f=function(n){var t;if("undefined"!=typeof Symbol){if(Symbol.asyncIterator&&null!=(t=n[Symbol.asyncIterator]))return t.call(n);if(Symbol.iterator&&null!=(t=n[Symbol.iterator]))return t.call(n)}throw new TypeError("Object is not async iterable")}(r),a=function(n,t,r){for(var e;;){var f=n();if(u(f)&&(f=f.v),!f)return a;if(f.then){e=0;break}var a=r();if(a&&a.then){if(!u(a)){e=1;break}a=a.s}if(t){var c=t();if(c&&c.then&&!u(c)){e=2;break}}}var s=new i,l=o.bind(null,s,2);return(0===e?f.then(v):1===e?a.then(h):c.then(d)).then(void 0,l),s;function h(e){a=e;do{if(t&&(c=t())&&c.then&&!u(c))return void c.then(d).then(void 0,l);if(!(f=n())||u(f)&&!f.v)return void o(s,1,a);if(f.then)return void f.then(v).then(void 0,l);u(a=r())&&(a=a.v)}while(!a||!a.then);a.then(h).then(void 0,l)}function v(n){n?(a=r())&&a.then?a.then(h).then(void 0,l):h(a):o(s,1,a)}function d(){(f=n())?f.then?f.then(v).then(void 0,l):v(f):o(s,1,a)}}(function(){return!!Promise.resolve(f.next()).then(function(r){return t=n.done,n=r,Promise.resolve(n.value).then(function(n){return e=n,!t})})},function(){return!!(t=!0)},function(){self.postMessage(e)});if(a&&a.then)return a.then(function(){})}()}catch(n){return e(n)}return f&&f.then?f.then(void 0,e):f}(0,function(t){a=!0,n=t})},function(r,e){function o(n){if(r)throw e;return e}var i=f(function(){var n=function(){if(!t&&null!=_iterator.return)return Promise.resolve(_iterator.return()).then(function(){})}();if(n&&n.then)return n.then(function(){})},function(t,r){if(a)throw n;if(t)throw r;return r});return i&&i.then?i.then(o):o()})}var c=function(){if(!r[Symbol.iterator]){var n=self,t=n.postMessage;return Promise.resolve(r).then(function(r){t.call(n,r)})}for(var o,i=function(n,t){var r;if("undefined"==typeof Symbol||null==n[Symbol.iterator]){if(Array.isArray(n)||(r=function(n,t){if(n){if("string"==typeof n)return e(n,void 0);var r=Object.prototype.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(n,void 0):void 0}}(n))){r&&(n=r);var o=0;return function(){return o>=n.length?{done:!0}:{done:!1,value:n[o++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=n[Symbol.iterator]()).next.bind(r)}(r);!(o=i()).done;)self.postMessage(o.value)}();if(c&&c.then)return c.then(function(){})}())}catch(t){return Promise.reject(t)}}},n.useWorker=function(n,e){var o=t.useState(r),i=o[0],u=o[1],f=t.useMemo(n,[n]),a=t.useRef(f);return t.useEffect(function(){a.current=f;var n=function(n){return u(n)};return f.onmessage=function(t){return n({result:t.data})},f.onerror=function(){return n({error:"error"})},f.onmessageerror=function(){return n({error:"messageerror"})},function(){n=function(){return null},f.terminate(),u(r)}},[f]),t.useEffect(function(){a.current.postMessage(e)},[e]),i}});
//# sourceMappingURL=index.umd.js.map
{
"name": "react-hooks-worker",
"description": "React custom hooks for web workers",
"version": "1.0.0-alpha.1",
"version": "1.0.0-alpha.2",
"publishConfig": {

@@ -14,5 +14,4 @@ "tag": "next"

"source": "./src/index.ts",
"main": "./dist/index.js",
"module": "./dist/index.esm.js",
"browser": "./dist/index.umd.js",
"main": "./dist/index.umd.js",
"module": "./dist/index.modern.js",
"types": "./dist/src/index.d.ts",

@@ -25,3 +24,3 @@ "sideEffects": false,

"scripts": {
"compile": "microbundle build --format cjs,es,umd",
"compile": "microbundle build -f modern,umd",
"test": "npm run eslint && npm run tsc-test && npm run jest",

@@ -28,0 +27,0 @@ "eslint": "eslint --ext .js,.ts,.tsx --ignore-pattern dist .",

@@ -36,3 +36,3 @@ import {

const worker = useMemo(createWorker, [createWorker]);
const lastWorker = useRef<Worker>();
const lastWorker = useRef<Worker>(worker);
useEffect(() => {

@@ -52,7 +52,5 @@ lastWorker.current = worker;

useEffect(() => {
if (lastWorker.current) {
lastWorker.current.postMessage(input);
}
lastWorker.current.postMessage(input);
}, [input]);
return state;
}

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