Home Reference Source Test Repository
import {Rset} from 'webdismay/src/index.js'
public class | source

Rset

Methods for maniplulating Set data on the webdis/redis stack. Not named Set to avoid collision with Javascript Sets

Constructor Summary

Public Constructor
public

Instantly create a list handler associated with a specific list, via its key, sends no requests to the server until a method is called.

Member Summary

Public Members
public

k: *

Method Summary

Public Methods
public

add(vals: ...string): Promise<number, Error>

add new values to the set

public

delete all members by deleting key (via DEL)

public

store at this key the set difference of sets at keys given by x and y (via SDIFFSTORE)

public

fromIntersection(skeys: ...skeys): Promise<number, Error>

store at this key the set intersection of the listed sets (via SINTERSTORE)

public

fromUnion(skeys: ...skeys): Promise<number, Error>

store at this key the set union of the listed sets (via SUNIONSTORE)

public

synonym for .members()

public

has(x: *): Promise<number, Error>

test set membership (via SISMEMBER)

public

find the members in the set intersection of the current set and the other listed sets (via SINTER)

public

clone of .has, tests set membership (via SISMEMBER)

public

synonym for .members()

public

number of members (via SCARD)

public

list members of set (via SMEMBERS)

public

moveTo(otherSet: string, member: string): Promise<number, Error>

(always) delete a member from the current set and (potentially) add it to another set (via SMOVE)

public

remove and return a random member of the set

public

remove values from the set (via SREM)

public

sampleSubset(count: number, response: Promise<Array, Error>): *

generate a random sample that is a subset, so that the sample has no repetition of memberss

public

generate a random sample from the set, of any length, potentially repeating members

public

set(vals: ...string): Promise<number, Error>

initialize the set to the passed values (via DEL and SADD)

public

union(skeys: ...string): Promise<Array, Error>

find the members in the set union of the current set and the other listed sets (via SUNION)

public

synonym for .members()

public

find the members in the current set not in any of the other sets (by key) (via SDIFF)

Public Constructors

public constructor(k: string) source

Instantly create a list handler associated with a specific list, via its key, sends no requests to the server until a method is called.

Params:

NameTypeAttributeDescription
k string

Key where a List is stored, or to be stored, on the server

Public Members

public k: * source

Public Methods

public add(vals: ...string): Promise<number, Error> source

add new values to the set

Params:

NameTypeAttributeDescription
vals ...string

New values to add to set

Return:

Promise<number, Error>

response is the number of additional members

public clear(): Promise<number, Error> source

delete all members by deleting key (via DEL)

Return:

Promise<number, Error>

response is 1 on deletion or 0 if the set does not exist

public fromDiff(x: string, y: string): Promise<number, Error> source

store at this key the set difference of sets at keys given by x and y (via SDIFFSTORE)

Params:

NameTypeAttributeDescription
x string

key for set X

y string

key for set Y

Return:

Promise<number, Error>

response is the number of members stored in this key's set

public fromIntersection(skeys: ...skeys): Promise<number, Error> source

store at this key the set intersection of the listed sets (via SINTERSTORE)

Params:

NameTypeAttributeDescription
skeys ...skeys

Keys of sets for intersection

Return:

Promise<number, Error>

response is the number of members stored in this key's set

public fromUnion(skeys: ...skeys): Promise<number, Error> source

store at this key the set union of the listed sets (via SUNIONSTORE)

Params:

NameTypeAttributeDescription
skeys ...skeys

Keys of sets for union

Return:

Promise<number, Error>

response is the number of members stored in this key's set

public getAll(): Promise<Array, Error> source

synonym for .members()

Return:

Promise<Array, Error>

response is array list of members of the set

public has(x: *): Promise<number, Error> source

test set membership (via SISMEMBER)

Params:

NameTypeAttributeDescription
x *

value to find in the set

Return:

Promise<number, Error>

response is 1 for member and 0 for not member

public intersection(skeys: ...string): Promise<Array, Error> source

find the members in the set intersection of the current set and the other listed sets (via SINTER)

Params:

NameTypeAttributeDescription
skeys ...string

Keys of other sets for intersection

Return:

Promise<Array, Error>

response is an array giving the values in the calculated set intersection

public isMember(x: *): Promise<number, Error> source

clone of .has, tests set membership (via SISMEMBER)

Params:

NameTypeAttributeDescription
x *

value to find in the set

Return:

Promise<number, Error>

response is 1 for member and 0 for not member

public keys(): Promise<Array, Error> source

synonym for .members()

Return:

Promise<Array, Error>

response is array list of members of the set

public len(): Promise<number, Error> source

number of members (via SCARD)

Return:

Promise<number, Error>

response is the number of members in the set

public members(): Promise<Array, Error> source

list members of set (via SMEMBERS)

Return:

Promise<Array, Error>

response is array list of members of the set

public moveTo(otherSet: string, member: string): Promise<number, Error> source

(always) delete a member from the current set and (potentially) add it to another set (via SMOVE)

Params:

NameTypeAttributeDescription
otherSet string

key to destination set

member string

value to move

Return:

Promise<number, Error>

response is 1 if moved from source set to destination set, 0 if not a member of source set

public pop(): Promise<string, Error> source

remove and return a random member of the set

Return:

Promise<string, Error>

response is the removed member

public remove(vals: ...string): Promise<number, Error> source

remove values from the set (via SREM)

Params:

NameTypeAttributeDescription
vals ...string

Values to remove

Return:

Promise<number, Error>

response is the number removed

public sampleSubset(count: number, response: Promise<Array, Error>): * source

generate a random sample that is a subset, so that the sample has no repetition of memberss

Params:

NameTypeAttributeDescription
count number

desired subset length

response Promise<Array, Error>

is the requested random subset

Return:

*

public sampleWithReplacement(count: number): Promise<Array, Error> source

generate a random sample from the set, of any length, potentially repeating members

Params:

NameTypeAttributeDescription
count number

desired sample length

Return:

Promise<Array, Error>

response is the requested random sample

public set(vals: ...string): Promise<number, Error> source

initialize the set to the passed values (via DEL and SADD)

Params:

NameTypeAttributeDescription
vals ...string

Values used to initialize the set

Return:

Promise<number, Error>

response is the number of unique set members

public union(skeys: ...string): Promise<Array, Error> source

find the members in the set union of the current set and the other listed sets (via SUNION)

Params:

NameTypeAttributeDescription
skeys ...string

Keys of other sets for union

Return:

Promise<Array, Error>

response is an array giving the (unique) values in the calculated set union

public vals(): Promise<Array, Error> source

synonym for .members()

Return:

Promise<Array, Error>

response is array list of members of the set

public withoutSets(skeys: ...string): Promise<Array, Error> source

find the members in the current set not in any of the other sets (by key) (via SDIFF)

Params:

NameTypeAttributeDescription
skeys ...string

Keys of other sets

Return:

Promise<Array, Error>

response is an array giving the values in calculated set difference