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

List

Methods for manipulating a List on the server

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

get(i: *): Promise<string, Error>

get the value of element i (via LINDEX)

public

get the entire list (via LRANGE)

public

insert an element immediately after the first element equal to pivot (via LINSERT)

public

insert an element immediately before the first element equal to pivot (via LINSERT)

public

length of list (via LLEN)

public

remove the tail from the list and return it (via RPOP)

public

popTo(destination: string): Promise<Array, Error>

remove the tail from the list and append (unshift) it as the head of another list (via RPOPLPUSH)

public

push(values: ...string): Promise<number, Error>

append values to the tail of the list (via RPUSH)

public

remove(v: string, count: nunber): Promise<number, Errpr>

remove elements with value v (via LREM)

public

set element i to value v (via LSET)

public

setAll(values: ...string): Promise<number, Error>

set list to supplied values (via DEL and RPUSH)

public

remove element 0 from the list and return it, and re-index the list (via LPOP)

public

return all or part of the list, list is unchanged (via LRANGE)

public

trim(from: number, to: number): Promise<Array, Error>

trim list to only the indicated range of indexes and reindex (via LTRIM)

public

unshift(values: ...string): Promise<number, Error>

append to beginning of list, in reverse order, and re-index the list (via LPUSH)

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 get(i: *): Promise<string, Error> source

get the value of element i (via LINDEX)

Params:

NameTypeAttributeDescription
i *

index to fetch

Return:

Promise<string, Error>

response is value of element i

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

get the entire list (via LRANGE)

Return:

Promise<Array, Error>

response is array containing entire list

public insertAfter(pivot: string, v: string): Promise<number, Error> source

insert an element immediately after the first element equal to pivot (via LINSERT)

Params:

NameTypeAttributeDescription
pivot string

value to find

v string

value to insert

Return:

Promise<number, Error>

response is new list length

public insertBefore(pivot: string, v: string): Promise<number, Error> source

insert an element immediately before the first element equal to pivot (via LINSERT)

Params:

NameTypeAttributeDescription
pivot string

value to find

v string

value to insert

Return:

Promise<number, Error>

response is new list length

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

length of list (via LLEN)

Return:

Promise<number, Error>

response is the length of the list

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

remove the tail from the list and return it (via RPOP)

Return:

Promise<string, Error>

response is the tail value from the list

public popTo(destination: string): Promise<Array, Error> source

remove the tail from the list and append (unshift) it as the head of another list (via RPOPLPUSH)

Params:

NameTypeAttributeDescription
destination string

key to List receiving the element

Return:

Promise<Array, Error>

status response

public push(values: ...string): Promise<number, Error> source

append values to the tail of the list (via RPUSH)

Params:

NameTypeAttributeDescription
values ...string

to append to the tail of the list

Return:

Promise<number, Error>

response is new length of the list

public remove(v: string, count: nunber): Promise<number, Errpr> source

remove elements with value v (via LREM)

Params:

NameTypeAttributeDescription
v string

the value to remove

count nunber
  • optional
  • default: 0

0 for all occurrences, otherwise limit the number of removals

Return:

Promise<number, Errpr>

response is the number removed

public set(i: number, v: string): Promise<Array, Error> source

set element i to value v (via LSET)

Params:

NameTypeAttributeDescription
i number

index of element to set

v string

value

Return:

Promise<Array, Error>

status response

public setAll(values: ...string): Promise<number, Error> source

set list to supplied values (via DEL and RPUSH)

Params:

NameTypeAttributeDescription
values ...string

Values to set

Return:

Promise<number, Error>

response is new length of list

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

remove element 0 from the list and return it, and re-index the list (via LPOP)

Return:

Promise<string, Error>

response is the removed element 0

public slice(from: number, to: number): Promise<Array, Error> source

return all or part of the list, list is unchanged (via LRANGE)

Params:

NameTypeAttributeDescription
from number
  • optional
  • default: 0

index to begin slice

to number
  • optional
  • default: -1

index to end slice

Return:

Promise<Array, Error>

response is the requested array of data

public trim(from: number, to: number): Promise<Array, Error> source

trim list to only the indicated range of indexes and reindex (via LTRIM)

Params:

NameTypeAttributeDescription
from number

the first index of elements to keep

to number

the last index of elements to keep, inclusive

Return:

Promise<Array, Error>

status response

public unshift(values: ...string): Promise<number, Error> source

append to beginning of list, in reverse order, and re-index the list (via LPUSH)

Params:

NameTypeAttributeDescription
values ...string

values to be appeded onto the head of the list

Return:

Promise<number, Error>

response is the new length of the list