API Docs for: 2.0.0
Show:

DiskStorage Class

Defined in: src/DiskStorage.js:1

Item Index

Properties

Attributes

Methods

clear

() DiskStorage chainable

Unset all values

Returns:

clone

(
  • [name]
  • [engine]
)
DiskStorage

Return a new DiskStorage object with the same keys and values

Parameters:

  • [name] String optional

    new namespace; defaults to "default"

  • [engine] String optional

    "localStorage" or "sessionStorage"; defaults to the current instance's engine

Returns:

destroy

() DiskStorage chainable

Clear the data and remove the DiskStorage data from localStorage/sessionStorage Note that the object will flush to disk if any new values are added

Returns:

exportData

() DiskStorage

Return a copy of the data store

Returns:

flush

() DiskStorage chainable

Flush to disk (localStorage or sessionStorage). Is triggered automatically on the next event loop when data changes

Returns:

forEach

(
  • callback
  • [thisArg]
)
DiskStorage chainable

Iterate through the collection

Parameters:

  • callback Function

    The iterator function. Will receive three parameters: value, key, this DiskStorage instance

  • [thisArg] Object optional

    The scope in which to execute the callback; defaults to this DiskStorage instance

Returns:

get

(
  • key
)
Any

Get a previously stored value

Parameters:

  • key String

    The name of the value

Returns:

Any:

isSupported

() Boolean static

Return true if localStorage, sessionStorage and JSON are available

Returns:

Boolean:

True if browser will support DiskStorage

load

(
  • data
)
DiskStorage chainable

Replace the internal data with the one given

Parameters:

  • data Object

    data to load

Returns:

remove

(
  • key
)
DiskStorage chainable

Unset a stored value

Parameters:

  • key String

    The name to unset

Returns:

set

(
  • key
  • value
)
DiskStorage chainable

Store data for later retreival

Parameters:

  • key String

    The name of the value

  • value Any

    The data to store

Returns:

Properties

data

Object

The data

engine

String

"localStorage" or "sessionStorage"

isDirty

Boolean

True if flush should write to disk

name

String

The namespace of the store

Attributes

version

String static

The DiskStorage version