![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
function-thread
Advanced tools
npm install function-thread --save
func
: Function to run in a separate threadoptions
: Options when creating a function (Object):options.timeout
: Timeout (milliseconds) (Default: 0)options.usePool
: Do I need to use a pool of workers (Bool) (Default: false)options.pool
: Pool options (Object):options.pool.max
: maximum number of resources to create at any given time. (Default: CPUs count * 2)options.pool.min
: minimum number of resources to keep in pool at any given time. If this is set >= max, the pool will silently set the min to equal max
. (Default: CPUs count)options.pool.maxWaitingClients
: maximum number of queued requests allowed, additional acquire
calls will be callback with an err
in a future cycle of the event loop.options.pool.testOnBorrow
: boolean
: should the pool validate resources before giving them to clients. Requires that either factory.validate
or factory.validateAsync
to be specified (Default: true)options.pool.acquireTimeoutMillis
: max milliseconds an acquire
call will wait for a resource before timing out. (Default: no limit), if supplied should non-zero positive integer.options.pool.fifo
: if true the oldest resources will be first to be allocated. If false the most recently released resources will be the first to be allocated. This in effect turns the pool's behaviour from a queue into a stack. boolean
, (Default: false)options.pool.priorityRange
: int between 1 and x - if set, borrowers can specify their relative priority in the queue if no resources are available.
see example. (Default: 1)options.pool.autostart
: boolean, should the pool start creating resources etc once the constructor is called, (Default: true)options.pool.evictionRunIntervalMillis
: How often to run eviction checks. (Default: 60000)options.pool.numTestsPerRun
: Number of resources to check each eviction run. Default: (Default: CPUs count).options.pool.softIdleTimeoutMillis
: amount of time an object may sit idle in the pool before it is eligible for eviction by the idle object evictor (if any), with the extra condition that at least "min idle" object instances remain in the pool. (Default: 600000)options.pool.idleTimeoutMillis
: the minimum amount of time that an object may sit idle in the pool before it is eligible for eviction due to idle time. Supercedes softIdleTimeoutMillis
(Default: 3600000)options.pool.Promise
: Promise lib, a Promises/A+ implementation that the pool should use. Default: options.pool.Promise = require('bluebird');
.'use strict';
const functionThread = require('function-thread');
// Creating a function
const someFunction = functionThread(function (input, resolve, reject) {
// input - Some data for calculations
// Some heavy calculations, which usually block the thread
resolve('Result...');
});
// Run the function in a separate thread
someFunction('Some data for calculations 1', {
timeout: 500 // Custom timeout
}).then(function (result) {
console.log(result);
}).catch(function (err) {
console.error(err);
});
// Run the function in a separate thread
someFunction('Some data for calculations 2', {
timeout: 1000 // Custom timeout
}).then(function (result) {
console.log(result);
}).catch(function (err) {
console.error(err);
});
// Run the function in a separate thread
someFunction('Some data for calculations 3', {
timeout: 1500 // Custom timeout
}).then(function (result) {
console.log(result);
}).catch(function (err) {
console.error(err);
});
FAQs
Run the function in a separate thread
The npm package function-thread receives a total of 41 weekly downloads. As such, function-thread popularity was classified as not popular.
We found that function-thread demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.