Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
job-schedule
Advanced tools
Schedule job for run one time.
This is similar to PriorityQueue
Creates a queue object with the specified concurrency. Tasks added to the queue are processed in parallel (up to the concurrency limit). If all workers are in progress, the task is queued until one becomes available. Once a worker completes a task, that task's callback is called.
However, it can specific running-condition for the task. This is very useful to schedule the time based jobs for run one time only.
$ npm i -S job-schedule
// parameters and return value if similar to `priorityQueue`
let q = new Queue(worker, concurrency)
// Start task when this function returns `true`
// Call `cb` to resume the queue `q`
q.when = function (node, cb) {
if (someConditions(node)) {
return true
}
doSomething(() => cb())
}
// remove jobs with condition
// true: removing job
q.remove(node => {
if (matched(node)) {
return true
}
return false
})
const Queue = require('job-schedule')
var timerId = null
var q = new Queue((task, cb) => {
console.log('priority:hello', task.name)
cb()
}, 1)
// node: { priority, data }
q.when = function (node, cb) {
// start task if it's priority less than 2
if (node.priority -- < 2) {
clearTimeout(timerId)
console.log('start:', node.data.name)
return true
}
// resume queue after 1s
timerId = setTimeout(cb, 1000)
}
// call when all tasks finished
q.drain = function () {
console.log('all items have been processed')
}
// add some items to the queue
q.push({name: 'foo'}, 10, function (err) {
console.log('finished processing foo', err)
})
q.push({name: 'bar'}, 2, function (err) {
console.log('finished processing bar', err)
})
// add some items to the queue (batch-wise)
q.push([{name: 'baz'}, {name: 'bay'}, {name: 'bax'}], 6, function (err) {
console.log('finished processing item', err)
})
FAQs
Schedule Jobs for run one time
The npm package job-schedule receives a total of 0 weekly downloads. As such, job-schedule popularity was classified as not popular.
We found that job-schedule 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.