Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Storage<T>

Type parameters

  • T

Hierarchy

Index

Constructors

constructor

  • new Storage<T>(path: string, opts?: {}): Storage<T>
  • Type parameters

    • T

    Parameters

    • path: string
    • Optional opts: {}

    Returns Storage<T>

Methods

_get

  • _get(): T
  • Returns T

add

  • This only works for items with a number Increase this Item by the given number.

    Parameters

    • num: number

      The number to add

    Returns Storage<T>

divide

  • This only works for items with a number Divide this Item by the given number.

    Parameters

    • num: number

      The number to divide by

    Returns Storage<T>

field

  • field<U>(index: T[keyof T], opts?: ItemOpts<T[U]>): Field<T[U]>
  • Get a property/item from this Item.

    alias

    item

    Type parameters

    • U: string | number | symbol

    Parameters

    • index: T[keyof T]

      The property to get

    • Optional opts: ItemOpts<T[U]>

      The options for getting this item, specifically the default value if this item has no value.

    Returns Field<T[U]>

filter

  • filter<U>(cond: (val: U) => any): Storage<T>
  • This only works for items with their value as an array Remove all items that match the condition from this Item<U[]>

    Type parameters

    • U

    Parameters

    • cond: (val: U) => any

      The condition to find the item with.

        • (val: U): any
        • Parameters

          • val: U

          Returns any

    Returns Storage<T>

find

  • find<U>(cond: (val: U) => any): Nothing | U
  • This only works for items with their value as an array Find the item that matches the condition from this Item<U[]>

    Type parameters

    • U

    Parameters

    • cond: (val: U) => any

      The condition to find the item with.

        • (val: U): any
        • Parameters

          • val: U

          Returns any

    Returns Nothing | U

get

  • get<T>(): T
  • Get the current value of this Item.

    Type parameters

    • T

    Returns T

getItem

  • getItem<U>(index: keyof T): T[U]
  • Get the value of the given field of this Item.

    Type parameters

    • U: string | number | symbol

    Parameters

    • index: keyof T

      The field to get

    Returns T[U]

has

  • has<U>(cond: (val: U) => any): boolean
  • This only works for items with their value as an array Check if this Item<U[]> has an item that matches the condition

    Type parameters

    • U

    Parameters

    • cond: (val: U) => any

      The condition to find the item with.

        • (val: U): any
        • Parameters

          • val: U

          Returns any

    Returns boolean

item

  • item<U>(index: U, opts?: ItemOpts<T[U]>): Field<T[U]>
  • Get a property/item from this Item.

    Type parameters

    • U: string | number | symbol

    Parameters

    • index: U

      The property to get

    • Optional opts: ItemOpts<T[U]>

      The options for getting this item, specifically the default value if this item has no value.

    Returns Field<T[U]>

list

  • list<T>(): T[keyof T][] | keyof T[]
  • List all of the items in this Item. If the value is an an array, returns the value, otherwise, it returns the keys of the value.

    Type parameters

    • T

    Returns T[keyof T][] | keyof T[]

multiply

  • multiply(num: number): Storage<T>
  • This only works for items with a number Multiply this Item by the given number.

    Parameters

    • num: number

      The number to multiply by

    Returns Storage<T>

pop

  • pop(val: keyof T): T
  • This only works for items with properties like objects or arrays Pop the given index or property from this Item.

    Parameters

    • val: keyof T

      The item to pop

    Returns T

pow

  • This only works for items with a number Raise this Item to the power of the given number

    Parameters

    • num: number

      The number to raise to the power of

    Returns Storage<T>

push

  • This only works for items with their value as an array Add the given item to this Item<U[]>

    Type parameters

    • U

    Parameters

    • val: U

      The item to push

    Returns Storage<T>

remove

  • This only works for items with their value as an array Remove the given item from this Item<U[]>

    Type parameters

    • U

    Parameters

    • val: U

      The item to remove

    Returns Storage<T>

save

  • save(path: string, callback?: () => any): Promise<any>
  • Parameters

    • path: string
    • Optional callback: () => any
        • (): any
        • Returns any

    Returns Promise<any>

set

  • Parameters

    • val: T

    Returns Storage<T>

setDefault

  • setDefault<T>(val: T): Storage<T>
  • If there is no value for this Item already, and the val isn't null or undefined or anything either, set the value to the val.

    Type parameters

    • T

    Parameters

    • val: T

    Returns Storage<T>

setItem

  • setItem<U>(index: keyof T, val: T[U]): Field<T[U]>
  • Set a field of this Item to a value.

    Type parameters

    • U: string | number | symbol

    Parameters

    • index: keyof T

      The field to be set

    • val: T[U]

      The value for the field to be set as

    Returns Field<T[U]>

subtract

  • subtract(num: number): Storage<T>
  • This only works for items with a number Subtract this Item by the given number.

    Parameters

    • num: number

      The number to subtract

    Returns Storage<T>

Static createConfig

  • createConfig<T>(path: string, data: any, opts?: {}): Storage<T>
  • Type parameters

    • T

    Parameters

    • path: string
    • data: any
    • Optional opts: {}

    Returns Storage<T>

Generated using TypeDoc