Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

handy-redis

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

handy-redis - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

dist/overrides.d.ts

18

dist/index.js

@@ -5,2 +5,3 @@ "use strict";

const flatten_1 = require("./flatten");
const overrides_1 = require("./overrides");
exports.createHandyClient = (...clientArgs) => {

@@ -13,11 +14,14 @@ const nodeRedis = (typeof clientArgs[0] === "object" && typeof clientArgs[0].zscan === "function")

const func = nodeRedis[key];
handyClient[key] = (...args) => new Promise((resolve, reject) => {
const flattened = flatten_1.flattenDeep(args);
func.apply(nodeRedis, flattened.concat([(err, data) => err ? reject(err) : resolve(data)]));
});
if (overrides_1.useUnderlyingImpl.has(key)) {
handyClient[key] = func.bind(nodeRedis);
}
else {
handyClient[key] = (...args) => new Promise((resolve, reject) => {
const flattened = flatten_1.flattenDeep(args);
func.apply(nodeRedis, flattened.concat([(err, data) => err ? reject(err) : resolve(data)]));
});
}
});
Object.assign(handyClient, overrides_1.additionalFunctions);
return handyClient;
// return _createHandyClient(args[0]);
// }
// return _createHandyClient(createClient.apply(null, args));
};
{
"name": "handy-redis",
"version": "1.1.2",
"version": "1.2.0",
"description": "A wrapper around node_redis with Promise and TypeScript support.",

@@ -13,3 +13,3 @@ "main": "dist/index.js",

"compile": "tsc -p .",
"prebuild": "ts-node scripts/generate-types && ts-node scripts/generate-tests",
"prebuild": "ts-node -D scripts/generate-types && ts-node scripts/generate-tests",
"build": "tsc -p .",

@@ -16,0 +16,0 @@ "lint": "tslint **/*.ts",

@@ -50,2 +50,26 @@ # handy-redis

### Examples
See the [snapshot tests](https://github.com/mmkal/handy-redis/blob/master/test/generated/commands/snapshots) for tons of usage examples (look at the `.md` files).
### Multi
Most members of node_redis's `multi` type don't need to be promisified, because they execute synchronously. Only `exec` is async. To use a promisified version of that, use `execMulti`:
```JavaScript
import { createHandyClient } from 'handy-redis';
(async function() {
const client = createHandyClient();
const multi = client.multi().set("z:foo", "987").keys("z:*").get("z:foo");
const result = await client.execMulti(multi);
console.log(result); // ["OK", ["z:foo"], "987"]
})();
```
`execMulti` is generic, so in TypeScript you can use something like `const strings = await client.execMulti<string>(multi)` if you know all results will be strings. Otherwise the type will default to `{}`.
## Development

@@ -52,0 +76,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc