Registry / messaging / orq
library0.3.0jsnpmunverified

orq (Observable Request Queue) v0.3.0 is an HTTP request queue optimized for Web Workers, providing TTL caching, RESTful cache invalidation, cancelable requests, and duplicate request elimination. It uses RxJS Observables and is platform-independent, allowing custom request implementations for Node.js or browser environments. Designed for modern JavaScript applications where caching and request deduplication are critical, particularly in worker-based architectures. Licensed under the MIT License.

npm install orq
INSTALL
IMPORT
SIG · ORQ
O
orq
messagingjavascriptv0.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mkMemCache
import { mkMemCache } from 'orq'
const mkMemCache = require('orq')
orq is ESM-only; CommonJS require will not work.
mkCachePolicy
import { mkCachePolicy } from 'orq'
import { mkCachePolicy } from 'orq/mkCachePolicy'
mkCachePolicy is a named export from the main entry point, not a subpath.
mkReceiver
import { mkReceiver } from 'orq'
import mkReceiver from 'orq'
mkReceiver is a named export, not a default export.
mkInterface
import mkInterface from 'orq/interface'
import { mkInterface } from 'orq'
mkInterface is the default export of the subpath 'orq/interface', not from the main module.

Sets up a Web Worker with TTL cache and RESTful cache policy, then creates an interface in main thread to make requests.

// worker.js import { mkMemCache, mkCachePolicy, mkReceiver } from 'orq'; import request from '@orq/superagent'; // not yet published const fiveMinutes = 300000; const applyCachePolicy = mkCachePolicy({ ttl: fiveMinutes }); const cache = applyCachePolicy(mkMemCache()); mkReceiver(self, request, cache); // main.js (in browser) import mkInterface from 'orq/interface'; const orqWorker = new Worker('worker.js'); const orq = mkInterface(orqWorker); // make a request orq.addRequest('https://api.example.com/data').subscribe({ next: (data) => console.log(data), error: (err) => console.error(err) }); // cancelable request const sub = orq.addRequest('https://api.example.com/data', { cancelable: true }).subscribe(); setTimeout(() => sub.unsubscribe(), 1000);
Debug
Known issues
gotchaDefault behavior: GET requests are not cancelable unless explicitly passed { cancelable: true }.
fix
Pass { cancelable: true } in options to addRequest for GET requests to be cancelable.
affects: >=0.0.0
breakingorq is ESM-only and does not provide a CommonJS build. Using require('orq') will fail.
fix
Use ES module import syntax or configure your bundler to handle ESM.
affects: >=0.0.0
deprecatedThe package has an incomplete @orq/superagent dependency listed as TODO; may cause confusion.
fix
Implement your own request wrapper using the platform-independent pattern described in the README.
affects: 0.3.0
gotchamkReceiver expects self (WorkerGlobalScope) as first argument; using window or global will break in workers.
fix
Ensure mkReceiver is called inside a Web Worker with self as context.
affects: >=0.0.0
breakingNo TypeScript types provided; library is written in plain JavaScript.
fix
Install @types/orq if community provides, or write your own type declarations.
affects: 0.3.0
Errors
Common errors & fixes
TypeError: mkMemCache is not a function
Using CommonJS require instead of ESM import (or named import mismatch).
fix
Use import { mkMemCache } from 'orq' with ES modules.
Error: mkReceiver is not a function
Trying to import mkReceiver as default instead of named export.
fix
Use import { mkReceiver } from 'orq'.
Uncaught TypeError: Failed to execute 'importScripts' on 'WorkerGlobalScope'
Using importScripts to load orq inside a worker; orq expects module scripts.
fix
Use <script type="module"> or set { type: 'module' } in Worker constructor.
ReferenceError: self is not defined
mkReceiver called in a non-worker context (e.g., main thread) or in Node.js without proper scope.
fix
Only call mkReceiver from within a Web Worker or provide a mock self object.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
packageorq
orq — npm install orq · libregistry