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

redis-dev

v2.4.0

Published

Redis development helper

Downloads

7

Readme

install

npm i redis-dev

start

const port = 6379
const host = '127.0.0.1'
const requirepass = 'foo'
const redis = new RedisDev(port, host, requirepass)

APIs

common

_set

/**
 * Set key and value.
 * 
 * @param {string} pattern - 'string' or 'hash'
 * @param {string} key
 * @param {(string|Object)} fieldOrEntriesOrValue
 * @param {string} [value=undefined]
 * @returns {Promise}
 */
await redis._set('string', 'foo', 'foo') 

await redis._set('hash', 'foo', 'bar', 'bar') // foo: { bar: 'bar' }
await redis._set('hash', 'foo', { // foo: { bar: 'bar', baz: 'baz' }
  bar: 'bar',
  baz: 'baz'
})

_get

/**
 * Get value by key.
 * 
 * @param {string} pattern - 'string' or 'hash'
 * @param {string} key
 * @param {(string|number)} startOrField
 * @param {number} [end=-1]
 * @returns {Promise}
 */
await redis._get('string', 'foo') // output: 'foo'
await redis._get('string', 'foo', 0) // output: 'foo'
await redis._get('string', 'foo', 1) // output: 'oo'
await redis._get('string', 'foo', 0, 1) // output: 'fo'

await redis._get('hash', 'foo') // output: { foo: 'foo', bar: 'bar' }
await redis._get('hash', 'foo', 'foo') // output: 'foo'
await redis._get('hash', 'foo', ['foo', 'bar']) // output: ['foo', 'bar']

_del

/**
 * Remove data by key.
 * 
 * @param {string} pattern - 'string' or 'hash'
 * @param {string} key
 * @param {string} field
 * @returns {Promise}
 */
await redis._del('string', 'foo')

await redis._del('hash', 'foo', 'foo')

flushall

/**
 * Clear all data.
 * 
 * @returns {Promise}
 */
await redis.flushall()

ttl

/**
 * Get the remaining survival time of a data with an expiration time.
 * 
 * @param {string} key - key
 * @returns {Promise}
 */
await redis.ttl(key)

type

/**
 * Get the type of data.
 * 
 * @param {string} key - key
 * @returns {Promise}
 */
await redis.type(key)

keys

/**
 * Get data by pattern.
 * 
 * @param {string} [pattern=*] - pattern
 * @returns {Promise}
 */
await redis.keys('*')

expire

/**
 * Set expiration time.
 * 
 * @param {string} key - key
 * @param {number} expiration - duration time
 * @returns {Promise}
 */
await redis.expire('foo', 60)

subscribe

/**
 * Subscribe channel.
 * 
 * @param {string} channel - channel
 * @param {Function} cb - callback
 * @returns {Promise}
 */
await redis.subscribe('foo', message => console.log(message))

publish

/**
 * Puslish message.
 * 
 * @param {string} channel - channel
 * @param {string} message - message
 * @returns {Promise}
 */
await redis.publisj('foo', 'Published message')

for string

set

/**
 * Set key and value.
 * 
 * @param {string} key - key
 * @param {string} value - value
 * @returns {Promise}
 */
await redis.set('foo', 'foo')

get

/**
 * Get value by key.
 * 
 * @param {string} key - key
 * @returns {Promise}
 */
await redis.get('foo')

getrange

/**
 * Get range value by key.
 * 
 * @param {string} key - key
 * @param {number} start - start index
 * @param {number} [end=-1] - end index
 * @returns {Promise}
 */
await redis.getrange('foo')

del

/**
 * Remove data by key.
 * 
 * @param {string} key - key
 * @returns {Promise}
 */
await redis.del('foo')

for hash

hset

/**
 * Set key and field and value.
 * 
 * @param {string} key - key
 * @param {string} field - field
 * @param {string} value - value
 * @returns {Promise}
 */
await redis.hset('foo', 'foo', 'foo')

hget

/**
 * Get value by field.
 * 
 * @param {string} key - key
 * @param {string} field - field
 * @returns {Promise}
 */
await redis.hget('foo', 'foo')

hmget

/**
 * Get multiple values by fields.
 * 
 * @param {string} key - key
 * @param {...string} fields - fields
 * @returns {Promise}
 */
await redis.hmget('foo', 'foo', 'bar', 'baz')

hgetall

/**
 * Get all fields and values by key.
 * 
 * @param {string} key - key
 * @returns {Promise}
 */
await redis.hgetall('foo')

hdel

/**
 * Remove data by key.
 * 
 * @param {string} key - key
 * @param {string} field - field
 * @returns {Promise}
 */
await redis.hdel('foo', 'foo')