Options
All
  • Public
  • Public/Protected
  • All
Menu

Summary

Utility object used to implement the Indexable Behavior of Storage implementations.

Description

It's primarily intended for internal Library use, however it's implemented in a way to allow for use by Library users. If possible, at least submit a ticket when you create custom Storage implementations so that maintainers can learn more about developer use cases, and make the library better by extending the Library's feature set.

Usage

const proxy: Storage = new Proxy(
 myCustomStorageImplementation,
 this.proxyHandler,
);
version

1.0.0

since

1.0.0

see

MDN Proxy Object

see

MDN Storage Interface

Hierarchy-Diagram

UML class diagram of StorageProxyHandler

Legend

icon for a class in the UML class diagram class
icon for a public method in the UML class diagram public method

Hierarchy

  • StorageProxyHandler

Implements

  • ProxyHandler<Storage>

Index

Constructors

constructor

Methods

deleteProperty

  • deleteProperty(storage: Storage, key: string | number | symbol): boolean
  • Removes the item stored in storage under the provided key. It enables for the delete operator's use on custom Storage implementations when passed in a Proxy.

    version

    1.0.0

    since

    1.0.0

    Parameters

    • storage: Storage
    • key: string | number | symbol

    Returns boolean

get

  • get(target: Storage, propertyKey: string | number | symbol): unknown
  • Returns the item stored in storage under the provided key. It enables for the property accessors on custom Storage implementations when passed in a Proxy.

    version

    1.0.0

    since

    1.0.0

    Parameters

    • target: Storage
    • propertyKey: string | number | symbol

    Returns unknown

getOwnPropertyDescriptor

  • getOwnPropertyDescriptor(storage: Storage, key: string | number | symbol): undefined | PropertyDescriptor
  • Returns a synthetic property descriptor for the value stored in storage under the provided key. It enables for property descriptor accessors on custom Storage implementations when passed in a Proxy. when passed in a Proxy.

    version

    1.0.0

    since

    1.0.0

    Parameters

    • storage: Storage
    • key: string | number | symbol

    Returns undefined | PropertyDescriptor

has

  • has(storage: Storage, key: string | number | symbol): boolean
  • Tells whether there's a value stored in storage under the provided key. It enables for presence checks on custom Storage implementations when passed in a Proxy, for example: "myKey" in myStorage ? "yay" : "nay"

    version

    1.0.0

    since

    1.0.0

    Parameters

    • storage: Storage
    • key: string | number | symbol

    Returns boolean

ownKeys

  • ownKeys(storage: Storage): (string | number | symbol)[]
  • Returns the keys present in storage. It enables for PropertyKey retrievals on custom Storage implementations when passed in a Proxy, for example: for (key in myStorage) ...

    version

    1.0.0

    since

    1.0.0

    Parameters

    • storage: Storage

    Returns (string | number | symbol)[]

set

  • set(target: Storage, key: string | number | symbol, value: unknown): boolean
  • Sets the provided value in storage under the provided key. It enables for the property setters on custom Storage implementations when passed in a Proxy.

    version

    1.0.0

    since

    1.0.0

    Parameters

    • target: Storage
    • key: string | number | symbol
    • value: unknown

    Returns boolean

Generated using TypeDoc