npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@abetomo/vsq

v4.1.1

Published

Very simple queue. And a very simple SQS like queue.

Downloads

100

Readme

Very-simple-queue

npm version Test

Very simple queue. And a very simple SQS like queue.

install

% npm install @abetomo/vsq

Command example

Use it like a queue

% vsq push -d /tmp/example.db -v 'value1'
% vsq push -d /tmp/example.db -v 'value2'
% vsq shift -d /tmp/example.db
value1
% vsq shift -d /tmp/example.db
value2

Use it like a stack

% vsq push -d /tmp/example-stack.db -v '{"key": "value1"}'
% vsq push -d /tmp/example-stack.db -v '{"key": "value2"}'
% vsq pop -d /tmp/example-stack.db
{"key": "value2"}
% vsq pop -d /tmp/example-stack.db
{"key": "value1"}

Use it like a SQS

% vsq send -d /tmp/example-sqs.db -v 'value1'
150390342-39bb8a1f-dd3c-488f-9ac8-f0b8383d9ae5
% vsq send -d /tmp/example-sqs.db -v 'value2'
150390342-1c95158b-381d-4735-b888-01e49f22bc3c
% vsq receive -d /tmp/example-sqs.db
{
  "id": "150390342-1c95158b-381d-4735-b888-01e49f22bc3c",
  "body": "value2"
}
% vsq delete -d /tmp/example-sqs.db -i "150390342-1c95158b-381d-4735-b888-01e49f22bc3c"
true
% vsq receive -d /tmp/example-sqs.db
{
  "id": "150390342-39bb8a1f-dd3c-488f-9ac8-f0b8383d9ae5",
  "body": "value1"
}

Usage example of Node.js API

Simple queue and stack

File

const VerySimpleQueue = require('@abetomo/vsq')
const vsq = new VerySimpleQueue()
const dbFile = '/tmp/test.db'

vsq.load(dbFile)

console.log('[unshift] data size: %s', vsq.unshift('value1'))
console.log('[unshift] data size: %s', vsq.unshift('value2'))
console.log('[push] data size: %s', vsq.push('value3'))
console.log('[push] data size: %s', vsq.push('value4'))

console.log('[shift]: %s', vsq.shift())
console.log('[shift]: %s', vsq.shift())
console.log('[pop]: %s', vsq.pop())
console.log('[pop]: %s', vsq.pop())

/*
 * Result:
 *
 * [unshift] data size: 1
 * [unshift] data size: 2
 * [push] data size: 3
 * [push] data size: 4
 * [shift]: value2
 * [shift]: value1
 * [pop]: value4
 * [pop]: value3
 */

Memory

const VerySimpleQueue = require('@abetomo/vsq')
const vsq = new VerySimpleQueue()

vsq.load(':memory:') // Specify ':memory:'

console.log('[unshift] data size: %s', vsq.unshift('value1'))
console.log('[unshift] data size: %s', vsq.unshift('value2'))
console.log('[push] data size: %s', vsq.push('value3'))
console.log('[push] data size: %s', vsq.push('value4'))

console.log('[shift]: %s', vsq.shift())
console.log('[shift]: %s', vsq.shift())
console.log('[pop]: %s', vsq.pop())
console.log('[pop]: %s', vsq.pop())

/*
 * Result:
 *
 * [unshift] data size: 1
 * [unshift] data size: 2
 * [push] data size: 3
 * [push] data size: 4
 * [shift]: value2
 * [shift]: value1
 * [pop]: value4
 * [pop]: value3
 */

SQS like

const VerySimpleQueueLikeSQS = require('@abetomo/vsq').SQS
const vsq = new VerySimpleQueueLikeSQS()
const dbFile = '/tmp/test.sqs.db'

vsq.load(dbFile)

console.log('[send] data ID: %s', vsq.send('value1'))
console.log('[send] data Id: %s', vsq.send('value2'))

const data = vsq.receive()
console.log('[receive]: %s', JSON.stringify(data))
console.log('[delete]: %s', vsq.delete(data.id))

console.log('[receive]: %s', JSON.stringify(vsq.receive()))

/*
 * Result:
 *
 * [send] data ID: 150390381-43b055bb-cccb-446a-a460-07d4a35697bc
 * [send] data Id: 150390381-52795da6-0528-46c0-a0bd-8c535b292dc8
 * [receive]: {"id":"150390381-43b055bb-cccb-446a-a460-07d4a35697bc","body":"value1"}
 * [delete]: true
 * [receive]: {"id":"150390381-52795da6-0528-46c0-a0bd-8c535b292dc8","body":"value2"}
 */