Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
long-long-job
Advanced tools
10 PRINT "HELLO"
20 GOTO 10
This module ables you to create a chain of tasks (computations or actions) with ability to resume run state on restart. Each task receives state of previous task (or initial state if it is first in chain) and must return action what to do next composed with new state.
First of all we need to define where job's state will be stored during transitions. Then we must initialize module with it.
For example, we will store state in Map
object. This is simplest storage method and it won't preserve state during restarts.
const { longLongJob } = require('long-long-job');
const mapBasedStorage = () => {
const stateStore = new Map();
return {
async hasState(id) {
return stateStore.has(id);
},
async setState(id, state) {
stateStore.set(id, state);
},
async getState(id) {
return stateStore.get(id);
},
async clean(id) {
stateStore.delete(id);
},
};
};
module.exports = longLongJob(mapBasedStorage());
const LongLongJob = require('./LongLongJob');
const { repeat, next } = require('long-long-job');
const incrementJob = new LongLongJob('increment-job', [
async ({ value, threshold }) => {
incrementJob.emit('tick', value);
return value < threshold
? repeat({ value: value + 1, threshold })
: next({ value, threshold });
},
]);
module.exports = incrementJob;
const incrementJob = require('./incrementJob');
incrementJob.on('start', () => console.log('Job started'));
incrementJob.on('resume', () => console.log('Job resumed'));
incrementJob.on('tick', value => console.log('Current value is %d', value));
incrementJob.on('done', () => console.log('Job finished'));
incrementJob
.start({ value: 0, threshold: 1000 })
.then(({ value }) => console.log('Task is done with value %d', value));
FAQs
Library for execution of long jobs with resume support.
The npm package long-long-job receives a total of 3 weekly downloads. As such, long-long-job popularity was classified as not popular.
We found that long-long-job 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.