{"_id":"@art-suite/web-worker","_rev":"3-9128cbb793669932415844ceb2859489","name":"@art-suite/web-worker","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@art-suite/web-worker","version":"1.0.0","author":{"name":"Shane Brinkman-Davis Delamore, Imikimi LLC"},"license":"ISC","_id":"@art-suite/web-worker@1.0.0","maintainers":[{"name":"shanebdavis","email":"shanebdavis@gmail.com"}],"homepage":"https://github.com/art-suite/art-suite-foundations","bugs":{"url":"https://github.com/art-suite/art-suite-foundations/issues"},"dist":{"shasum":"1f92cc814dc327e87f68a3012fe2bbc5a2f8407f","tarball":"https://registry.npmjs.org/@art-suite/web-worker/-/web-worker-1.0.0.tgz","fileCount":23,"integrity":"sha512-xd5MtGLsLq16r/0dEgW1sZHa54XBaiE1x+N9e5IAXy+GCxUKQ81BuaLB5tR4mJYtElvrGki+tpxgDSEj/BpUZg==","signatures":[{"sig":"MEUCIGmTN5r3Z3GPGnjHLhKkfbUststpjyVNlvHsQUFP8IUUAiEAvlxCZQl4EV+K5fJlvNKHqykuRecLTOJgXkPy0X641JQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33072,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhAjnGCRA9TVsSAnZWagAA+awP/jFVkSTj6Ey6+wo1P2Hz\n93w3bgp9HQnKMM5Wy3tRGFnWdJuy/Xcd7AGmtbjnAp1eXeqHvQkoEypUGbYP\nz09tyZu+RlEHQIlmTHkbQ+M8Rn5nKjb0z+NvJF9Pokm/lrYtAPoo3x6YOAvh\nWjNnj3J+XkLAFsSoqvfrhKBZ5PGvz+d4tjysUy6OzfkmmWqelGd3OZ5R8CT2\nh5+3ZzT8IeH70hvKssumw3RALNIJe7oRVrHxQctAUL6k/5I6g9B02Aa8HDhm\nofldOOokNsjL0ZA+PwE55Jib9uHdA6qxh5NpULuMWrdtJAdvfNSNAuM8b7ZZ\nGbem4iQesywdlRBmunNzm+5OWDZ4FJEVnVGzeVr6hzK2Af5Aj241lcftd+3Z\nmWvPrZTMNyd+9eQBSNzkfRLT3a9pozOiqs5zHJK6ykySvx6go9BNZpS5HX1H\n5e/KQM26atiwwHrNJUNx1wnhKWd/gJ7aAv+0O9beuVdzRHtFHCkDp4/+0F8Q\ng0NJyYgQA09KYMzICz4O7EwkB8m8/bIwa9qYskxi06hYIb4W1Wi6ipE2n7wk\nCSULHUqtgFwv/VY0kQt6izD2mR1PZNo0l8XvcMvxgR0ZZLYn8Z3DqRKEbPHi\n3TcAUqFiZHLP/psXPGaANdyA06CVZ7CZZxgaLAL+VdkKfw8Gqqf2x0df/0B+\nyQL9\r\n=1hzP\r\n-----END PGP SIGNATURE-----\r\n"},"jest":{"verbose":true,"testEnvironment":"node","collectCoverageFrom":["build/**/*.js","!build/test/**/*.js"],"testPathIgnorePatterns":["/node_modules/","<rootDir>/test"]},"watch":{"build":{"quiet":false,"patterns":["source"],"extensions":["caf","coffee"]}},"scripts":{"nn":"nn build/* ","test":"npm run nn\njest","build":"coffee -m --output build --compile source &\nCOFFEE_PID=$!\ncaf -m -c source -o build &\nCAF_PID=$!\nwait $COFFEE_PID || exit 1\nwait $CAF_PID || exit 1\nnpm run nn","clean":"rm -rf build/*","watch":"npm-watch","build-clean":"# BUILD CLEAN START\n#   - building into: build-temp\n#\nrm -rf ./__build-old__\ncoffee -m --output build-temp --compile source &\nCOFFEE_PID=$!\ncaf -m -c source -o build-temp &\nCAF_PID=$!\nwait $COFFEE_PID || exit 1\nwait $CAF_PID || exit 1\nnpm run nn\n\nnn build-temp/*\n\n# BUILD CLEAN FINIALIZING\n#  - replace old build in:   build\n#  - with new build from:    build-temp\n#\nmv build __build-old__\nmv build-temp build\nrm -rf ./__build-old__"},"_npmUser":{"name":"shanebdavis","email":"shanebdavis@gmail.com"},"repository":{"url":"git+https://github.com/art-suite/art-suite-foundations.git","type":"git"},"_npmVersion":"7.6.0","description":"- `isBrowser` true/false - `isWebWorker` true/false - `startWorkerFromJsString(workerSourceJs)` - `startWorkerFromFunction(workerFunction)` - `echoWebWorker` sample workerSourceJs","directories":{},"_nodeVersion":"14.17.0","dependencies":{"art-standard-lib":"^1.71.2"},"_hasShrinkwrap":false,"devDependencies":{},"_npmOperationalInternal":{"tmp":"tmp/web-worker_1.0.0_1627535814548_0.7474675922873799","host":"s3://npm-registry-packages"}},"1.0.1":{"author":{"name":"Shane Brinkman-Davis Delamore"},"bugs":{"url":"https://github.com/art-suite/art-suite-foundations/issues"},"dependencies":{"art-standard-lib":"^1.74.4"},"devDependencies":{},"homepage":"https://github.com/art-suite/art-suite-foundations","jest":{"collectCoverageFrom":["build/**/*.js","!build/test/**/*.js"],"coveragePathIgnorePatterns":["/index.js$","/namespace.js$"],"testEnvironment":"node","testPathIgnorePatterns":["/node_modules/","<rootDir>/test"],"verbose":true},"license":"ISC","name":"@art-suite/web-worker","repository":{"type":"git","url":"git+https://github.com/art-suite/art-suite-foundations.git"},"scripts":{"build":"rsync -av --include='*.js' --include='*.css' --exclude='*' ./source/ ./build/\ncoffee -m --output build --compile source &\nCOFFEE_PID=$!\ncaf -m -c source -o build --require coffee-script/register&\nCAF_PID=$!\nwait $COFFEE_PID || exit 1\nwait $CAF_PID || exit 1\nnpm run nn","build-clean":"# BUILD CLEAN START\n#   - building into: build-temp\n#\nrm -rf ./__build-old__\nrsync -av --include='*.js' --include='*.css' --exclude='*' ./source/ ./build/\ncoffee -m --output build-temp --compile source &\nCOFFEE_PID=$!\ncaf -m -c source -o build-temp --require coffee-script/register&\nCAF_PID=$!\nwait $COFFEE_PID || exit 1\nwait $CAF_PID || exit 1\nnpm run nn\n\nnn build-temp/*\n\n# BUILD CLEAN FINIALIZING\n#  - replace old build in:   build\n#  - with new build from:    build-temp\n#\nmv build __build-old__\nmv build-temp build\nrm -rf ./__build-old__","build-watch":"nodemon -e js,ts,jsx,tsx,caf,coffee,json -x npm run build","clean":"rm -rf build/*","nn":"nn build/* ","test":"npm run build\njest","test-watch":"jest --watch"},"version":"1.0.1","watch":{"build":{"extensions":["caf","coffee"],"patterns":["source"],"quiet":false}},"gitHead":"3140bf828cabdf379d7c25fc877c26c1608c2409","_id":"@art-suite/web-worker@1.0.1","description":"- `isBrowser` true/false - `isWebWorker` true/false - `startWorkerFromJsString(workerSourceJs)` - `startWorkerFromFunction(workerFunction)` - `echoWebWorker` sample workerSourceJs","_nodeVersion":"24.10.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-IiCHmFBzzAy/e+Tqq9DkMTr5gkRJ4jAmZCkSgM4qtkDvsHOHHAl9IjamdAHBxp/Bm1DOiRUZGGy1CofGbF3VWg==","shasum":"eecaa08634482a36c62bb9a03bef7e3baa73df9b","tarball":"https://registry.npmjs.org/@art-suite/web-worker/-/web-worker-1.0.1.tgz","fileCount":26,"unpackedSize":37445,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDEyUbU+r4BIfFmJFbX8OdNk9mF59rk33scR44hdXh6eAIhAIxI4B2+3F/bLpUasT/t6Lkd4f4mZ6WWii/7LqmMzg6W"}]},"_npmUser":{"name":"shanebdavis","email":"shanebdavis@gmail.com"},"directories":{},"maintainers":[{"name":"shanebdavis","email":"shanebdavis@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/web-worker_1.0.1_1762507600976_0.45507015851138344"},"_hasShrinkwrap":false}},"time":{"created":"2021-07-29T05:16:54.510Z","modified":"2025-11-07T09:26:41.367Z","1.0.0":"2021-07-29T05:16:54.706Z","1.0.1":"2025-11-07T09:26:41.175Z"},"bugs":{"url":"https://github.com/art-suite/art-suite-foundations/issues"},"author":{"name":"Shane Brinkman-Davis Delamore"},"license":"ISC","homepage":"https://github.com/art-suite/art-suite-foundations","repository":{"type":"git","url":"git+https://github.com/art-suite/art-suite-foundations.git"},"description":"- `isBrowser` true/false - `isWebWorker` true/false - `startWorkerFromJsString(workerSourceJs)` - `startWorkerFromFunction(workerFunction)` - `echoWebWorker` sample workerSourceJs","maintainers":[{"name":"shanebdavis","email":"shanebdavis@gmail.com"}],"readme":"# WebWorker\n\n- `isBrowser` true/false\n- `isWebWorker` true/false\n- `startWorkerFromJsString(workerSourceJs)`\n- `startWorkerFromFunction(workerFunction)`\n- `echoWebWorker` sample workerSourceJs\n\n# WorkerRpc\nWorkerRPC has two modes: singleton and instanced.\n\n# Singleton\n  Including WorkerRPC automatically creates the singleton instance.\n  In a worker, the singleton automatically binds to the worker's self.onmessage and starts listening.\n  In workers or the browser, any handler registered with the singleton will be available to respond\n  to any message received by the singleton OR ANY OTHER INSTANCE of WorkerRPC in that thread.\n  You can think of the singleton as the global registry for handlers.\n\n- In practice:\n  - In browser:\n\n        # to register all your handlers, call this one or more times:\n        WorkerRpc.register ...\n\n        # Call for each each worker you want to listen for RPC calls from,\n        # and bind any remote procedures you want to be able to invoke on\n        # that specific worker-thread.\n        aBoundWorker = new WorkerRpc worker,\n          bind: ...\n          bindWithPromises: ...\n\n        # to make remote-procedure-calls to the worker:\n        # NOTE: if registered with bindWithPromises, will return a promise for the RPC's result.\n        aBoundWorker.MyWorkerNamespace.myWorkerFunction ...\n\n  - In worker:\n\n        # to register all your handlers, call this one or more times:\n        WorkerRpc.register ...\n\n        # bind any remote procedures you want to be able to invoke on the browser-thread\n        WorkerRpc.bind ...\n        WorkerRpc.bindWithPromises ...\n\nNOTES:\n  registered functions are invoked with @/this set to the namespace. That way you can invoke\n  callback functions you previously bound back to the specific worker that invoked the\n  function with: @MyWorkerNamespace.myWorkerFunction()\n\n### Real world example\n\n  Suppose you want to access the localStorage object on the browser thread from your worker.\n  The 6 lines of code below create the 'self.asyncLocalStorage' object which works just like\n  'localStorage' except it returns Art.Foundation.Promises for the function results.\n\n  browser: (before starting the worker)\n\n    {WorkerRpc} = Art.Foundation\n    WorkerRpc.register localStorage: localStorage\n    new WorkerRpc workerSourcePath\n\n  worker:\n\n    {workerRpc} = Art.Foundation.WorkerRpc\n    workerRpc.bindWithPromises localStorage: [\"getItem\", \"setItem\", \"removeItem\", \"clear\"]\n    self.asyncLocalStorage = workerRpc.localStorage\n\n  > SBD: Isn't that nice! So streamlined!\n\n### General Examples\n\nUsage with no return value expected:\n\n- browser thread:\n\n      new WorkerRpc (new Worker workerUrl),\n        register:\n          MyMainNamespace:\n            doWork: (a) -> ...\n\n- worker thread:\n\n      {MyMainNamespace} = new WorkerRpc self,\n        bind:\n          MyMainNamespace: [\"doWork\"]\n\n      MyMainNamespace.doWork myStructuredData\n\nUsage with promises:\n\n- browser thread:\n\n      new WorkerRpc (new Worker workerUrl),\n        register:\n          MyMainNamespace:\n            concatStrings: (a, b) ->\n              a + b\n              # equivelent to: Promise.resolve a + b\n              # if the result is not a Promse, Promise.resolve(result) is automatically applied\n\n- worker thread:\n\n      {MyMainNamespace} = new WorkerRpc self,\n        bindWithPromises:\n          MyMainNamespace: [\"concatStrings\"]\n\n      MyMainNamespace.concatStrings \"hi \", \"Shane\"\n      .then (result) ->\n        # result == \"hi Shane\"\n\nUsage with arbitrary response messages:\n\n  Sometimes you want a handle to the workerRpc instance for the thread that just send\n  you the message inside your registered response functions. You can access that\n  via the global: WorkerRpc.lastMessageReceivedFrom.\n\n- browser thread:\n\n      new WorkerRpc (new Worker workerUrl),\n        register:\n          MyMainNamespace:\n            doWorkAndRespond: (key) ->\n              count == 0\n              invokeThreeTimes =>\n                count++\n                WorkerRpc.lastMessageReceivedFrom.MyWorkerNamespace.respond key, count\n\n- worker thread:\n\n      {MyMainNamespace} = new WorkerRpc self,\n        register:\n          MyWorkerNamespace:\n            respond: (key, count) -> console.log \"MyWorkerNamespace#respond: #{key} #{count}\"\n        bind:\n          MyMainNamespace: [\"doWorkAndRespond\"]\n\n      MyMainNamespace.doWorkAndRespond \"myKey\"\n\nUsage - add to global registery:\n\n    WorkerRpc.register\n      MyGlobalClass:\n        doSomethingNoMatterWhoCalls: ->\n          ...\n","readmeFilename":"README.md"}