Socket
Socket
Sign inDemoInstall

nice-threads

Package Overview
Dependencies
5
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0

esm/_dnt.polyfills.js

5

esm/lib/NiceThreadPool.js

@@ -83,2 +83,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {

}
queue(calls) {
for (const args of calls)
this.call(...args);
return this;
}
all(calls) {

@@ -85,0 +90,0 @@ if (Array.isArray(calls))

8

esm/lib/url.js

@@ -9,6 +9,12 @@ // deno-lint-ignore-file no-var no-explicit-any

}
function normalizeNodeModule(script) {
const importStarMatch = /await Promise\.resolve\(\)\.then\(\(\) => __importStar\(require\((.+)\)\)\)/gu;
const requireMatch = /require\((.+)\)/gu;
const trueImport = 'await import($1)';
return script.replaceAll(importStarMatch, trueImport).replaceAll(requireMatch, trueImport);
}
export function makeUrl(script) {
const mimetype = 'text/javascript';
if (typeof process === 'object' && typeof process?.versions?.node === 'string') {
return `data:${mimetype};base64,${internalBtoa(script)}`;
return `data:${mimetype};base64,${internalBtoa(normalizeNodeModule(script))}`;
}

@@ -15,0 +21,0 @@ else {

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

import "./_dnt.polyfills.js";
export * from './lib/NiceThread.js';
export * from './lib/NiceThreadPool.js';

4

package.json

@@ -6,3 +6,3 @@ {

"name": "nice-threads",
"version": "0.2.0",
"version": "0.3.0",
"description": "A promise wrapper for JavaScript Workers, batteries",

@@ -42,2 +42,2 @@ "keywords": [

}
}
}

@@ -9,2 +9,4 @@ # Nice Threads

All executors and workers are of type `module`; use `await import` to dynamically import other modules at runtime.
Then, you can start individual threads and manage them yourself:

@@ -11,0 +13,0 @@

@@ -109,2 +109,7 @@ "use strict";

}
queue(calls) {
for (const args of calls)
this.call(...args);
return this;
}
all(calls) {

@@ -111,0 +116,0 @@ if (Array.isArray(calls))

@@ -35,6 +35,12 @@ "use strict";

}
function normalizeNodeModule(script) {
const importStarMatch = /await Promise\.resolve\(\)\.then\(\(\) => __importStar\(require\((.+)\)\)\)/gu;
const requireMatch = /require\((.+)\)/gu;
const trueImport = 'await import($1)';
return script.replaceAll(importStarMatch, trueImport).replaceAll(requireMatch, trueImport);
}
function makeUrl(script) {
const mimetype = 'text/javascript';
if (typeof process === 'object' && typeof process?.versions?.node === 'string') {
return `data:${mimetype};base64,${internalBtoa(script)}`;
return `data:${mimetype};base64,${internalBtoa(normalizeNodeModule(script))}`;
}

@@ -41,0 +47,0 @@ else {

@@ -17,3 +17,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
require("./_dnt.polyfills.js");
__exportStar(require("./lib/NiceThread.js"), exports);
__exportStar(require("./lib/NiceThreadPool.js"), exports);

@@ -7,2 +7,3 @@ export declare class NiceThreadPool<T extends NiceAsync> extends Array<Promise<Awaited<ReturnType<T>>>> {

call(...args: Parameters<T>): Promise<any>;
queue(calls: Parameters<T>[]): this;
all(): Promise<Awaited<ReturnType<T>>[]>;

@@ -9,0 +10,0 @@ all(calls: Parameters<T>[]): Promise<Awaited<ReturnType<T>>[]>;

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

import "./_dnt.polyfills.js";
export * from './lib/NiceThread.js';
export * from './lib/NiceThreadPool.js';
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc