Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
A queue persist on filesytem to save memory
$ npm install disk-queue
# or
$ pnpm add disk-queue
import { DiskQueue } from "disk-queue";
const queue = new DiskQueue({
filePath,
});
queue.push({ data: 1 });
console.log(queue.remainCount); // 1
queue.push(...[{ data: 2 }, { data: 3 }]);
console.log(queue.remainCount); // 3
console.log(queue.shift()); // {data: 1}
console.log(queue.remainCount); // 2
//...
if (queue.remainCount === 0) {
console.log(queue.shift()); // undefined
}
class of disk queue recive a options object
Type:
interface Options {
filePath: string; // filePath to persist queue
serializer?: Serializer; // default is JSON.stringify
deserializer?: DeSerializer; // default is JSON.parse
}
add items to queue work like Array#shift
dequeue a item work like Array#shift
discard jobs and reset everything
close internal file descriptor, push after close will throw fd error
The number of remaining item in queue
event triggered when queue remainCount hit zero
queue.on('drain', () => {
assert(queue.remainCount === 0)
})
event triggered when queue.reset is called
FAQs
A queue persist on filesytem to save memory
The npm package disk-queue receives a total of 959 weekly downloads. As such, disk-queue popularity was classified as not popular.
We found that disk-queue 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.