Skip to content

Commit

Permalink
Merge pull request #12 from freedomjs/storage
Browse files Browse the repository at this point in the history
typings for storage provider
  • Loading branch information
keroserene committed May 16, 2014
2 parents 2ce95a0 + f146477 commit dac18b0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
60 changes: 60 additions & 0 deletions interfaces/storage.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* freedom/interface/storage.js
*
* Typescript definitions for the Freedom Storage API.
*/

/// <reference path='promise.d.ts' />

// Interfaces for Freedom social API
declare module freedom.Social {

// Scope preferences when accessing stoarge.
// TODO: Enums should not be in this d.ts file (or any of the other interface
// files in freedom-typescript-api.) Find a better way to organize some
// regular .ts files to generate real js output, so Enums can work at runtime
// with additional hacks. At the moment, this particular enum isn't actually
// used by uProxy, so we'll wait until this becomes necessary.
enum SCOPE {
SESSION = 0,
DEVICE_LOCAL,
USER_LOCAL,
SHARED
}

} // declare module freedom.Storage

// The Freedom Storage class
declare module freedom {

class Storage {

/**
* Fetch array of all keys.
*/
keys() : string[];

/**
* Fetch a value for a key.
*/
get(key :string) : Promise<string>;

/**
* Sets a value to a key. Fulfills promise with the previous value, if it
* exists.
*/
set(key :string, value :string) : Promise<string>;

/**
* Remove a single key. Fulfills promise with previous value, if exists.
*/
remove(key :string) : Promise<string>;

/**
* Remove all data from storage.
*/
clear() : Promise<void>;

} // class Storage

} // declare module Freedom
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "freedom-typescript-api",
"description": "TypeScript Interface for Freedom",
"version": "0.1.7",
"version": "0.1.8",
"repository": {
"type": "git",
"url": "https://github.com/freedomjs/typescript-api"
Expand Down

0 comments on commit dac18b0

Please sign in to comment.