1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00
This commit is contained in:
Leibale
2023-04-23 07:56:15 -04:00
parent 35d32e5b64
commit 9faa3e77c4
326 changed files with 14620 additions and 10931 deletions

View File

@@ -1,22 +1,22 @@
import { createHash } from 'crypto';
import { RedisCommand } from './commands';
import { Command } from './RESP/types';
export interface RedisScriptConfig extends RedisCommand {
SCRIPT: string;
NUMBER_OF_KEYS?: number;
export type RedisScriptConfig = Command & {
SCRIPT: string | Buffer;
NUMBER_OF_KEYS?: number;
}
export interface SHA1 {
SHA1: string;
SHA1: string;
}
export function defineScript<S extends RedisScriptConfig>(script: S): S & SHA1 {
return {
...script,
SHA1: scriptSha1(script.SCRIPT)
};
return {
...script,
SHA1: scriptSha1(script.SCRIPT)
};
}
export function scriptSha1(script: string): string {
return createHash('sha1').update(script).digest('hex');
export function scriptSha1(script: RedisScriptConfig['SCRIPT']): string {
return createHash('sha1').update(script).digest('hex');
}