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-scanrx

v1.0.1

Published

Rx interface for the Redis *SCAN commands, for use with node_redis

Downloads

6

Readme

redis-scanrx

Appends Rx interfaces to the Redis *SCAN commands.

example

var redis = require("redis");

// append scanrx methods for any clients
require("redis-scanrx")(redis);

var client = redis.createClient();
var common_prefix = "sample-app:";

client.scanrx()
	.map(function (x, idx, obs) {
		// remove common prefix for all keys
		return x.replace(common_prefix, "");
	})
	.take(10)
	.subscribe(
		function (x) { console.log("Next: " + x); },
		function (err) { console.error(err); },
		function () { console.log("Completed!") }
	);
// => Next: key:49
// => Next: key:2
// => Next: key:41
// => Next: key:43
// => Next: key:18
// => Next: key:12
// => Next: key:1
// => Next: key:10
// => Next: key:48
// => Next: key:9

If you want to get results as an array with async/await:


async function example() {
	var keys = await client.scanrx("sample-app:key:*").toArray().toPromise();
	console.log(keys);
}

example();

// => ["sample-app:key:49", "sample-app:key:2", "sample-app:key:41", "sample-app:key:43", ...] 

methods

client.scanrx([pattern])

Create a new Rx observable for Redis SCAN replies. Calls the scan command recursively, and each keys are supplied as stream elements.

  • pattern: (opt) the pattern to match keys against.

e.g.

client.scanrx("key:*")
	.subscribeOnNext(function (x) { console.log("Next: " + x); });

client.sscanrx(key, [pattern])

Create a new Rx observable for Redis SSCAN replies with a key. Calls the sscan command recursively on key key, and each members are supplied as stream elements.

  • key: the key of the set.
  • pattern: (opt) the pattern to match elements against.

client.hscanrx(key, [pattern])

Create a new Rx observable for Redis HSCAN replies. Calls the hscan command recursively on key key, and each field/value pair objects are supplied as stream elements, i.e.:

client.hscanrx("hash:1")
	.subscribeOnNext(function (x) { console.log(x); });
// => { field: "field_1", value: "value_1" }
// => { field: "field_2", value: "value_2" }
// => { field: "field_3", value: "value_3" }
// => { field: "field_4", value: "value_4" }
// ...
  • key: the key of the hash.
  • pattern: (opt) the pattern to match fields against.

client.zscanrx(key, [pattern])

Create a new Rx observable for Redis ZSCAN replies. Calls the zscan command recursively on key key, and each element/score pair objects are supplied as stream elements, i.e:

client.zscanrx("zset:1")
	.subscribeOnNext(function (x) { console.log(x); });
// => { element: "element_1", score: "1" }
// => { element: "element_2", score: "2" }
// => { element: "element_3", score: "3" }
// => { element: "element_4", score: "4" }
// ...
  • key: the key of the sorted set.
  • pattern: (opt) the pattern to match elements against.

LICENCE

MIT