My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
API  
The API for realStorage 2.0
Featured, Type-Documentation
Updated Sep 7, 2010 by bcannon

Verified browser compatibility:

  • Chrome 4 - 6
  • Firefox 3.5 - 3.6
  • Internet Explorer 8
  • Safari 4 - 5

Library requirements are denote in sienna. Any additions or changes between versions are denoted in green.


Functions available directly from the window.realStorage object delegate to localStorage when available, else to a Gears database if provided.

W3C Web Storage API

W3C Specification. Code up to date as of Editor's Draft 8 August 2009.

length

ulong

Requires Object.__defineGetter__().

The number of entries in the store.

key()

(n:ulong) → String

Returns the key for the nth entry in the store. The index/key association is stable so long as no keys are added or removed. If an index is equal to or greater than Storage.length, null is returned.

getItem()

(key:String) → String|null

Return the value for the given key. The key is coerced to a string before being used to query the store. If the key is not set in the store, null is returned.

setItem()

(key:String, value:String) → null

Associate the key with the specified value. Both the key and value are coerced to strings before being stored.

removeItem()

(key:String) → null

Remove the key (and its value). The key is coerced to a string before attempting removal. Trying to remove a key that is not in the store is a no-op.

clear()

() → null

Empty out the store. Emptying an already empty store is a no-op.


Non-Standard API

local

Storage

Requires localStorage to be available.

localStorage wrapped by realStorage. If this is available then calling functions off of realStorage directly will delegate to this object.

New in 2.0.

session

Storage

Requires sessionStorage to be available.

sessionStorage wrapped by realStorage.

New in 2.0.

gears

Storage

Requires Gears to be available.

Wrapping of realStorage for Gears. Creates a realStorage-db with a realStorage table. if local is not defined then function accessed directly off of realStorage delegate to this object.

New in 2.0.

getLength()

() → uint

Return the number of entries in the store. Provided for instances where an accessor cannot be created for the length property.

New in 2.0.

contains()

(key:String) → Boolean

Return a boolean representing whether the key exists in the store.

New in 1.1.

keysArray()

() → Array

Return an array containing all keys.

New in 1.1.

setObject()

(key:String, value:Object, [*args]) → Object

Requires JSON.stringify()

Associate with the key with the JSON-compatible object key. All arguments beyond key and value have the same order and meaning as those optional arguments for JSON.stringify().

Renamed from setJSONObject() in 2.0.
New in 1.2.

getObject()

(key:String, [*args]) → Object

Requires JSON.parse()

Return theJSON-compatible object as stored under the specified key. All arguments beyond key have the same ordering and meaning as those passed to JSON.parse().

Renamed from getJSONObject() in 2.0.
New in 1.2.

Deprecated/Removed

storageArea

Storage

Storage instance wrapped by realStorage.

Removed in 2.0.


Sign in to add a comment
Powered by Google Project Hosting