forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
backbone.localstorage.d.ts
51 lines (35 loc) · 1.33 KB
/
backbone.localstorage.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Type definitions for backbone.localStorage 1.0.0
// Project: https://github.com/jeromegn/Backbone.localStorage
// Definitions by: Louis Grignon <https://github.com/lgrignon/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../backbone/backbone.d.ts" />
declare namespace Backbone {
interface Serializer {
serialize(item: any): any;
deserialize(data: any): any;
}
class LocalStorage {
name: string;
serializer: Serializer;
records: string[];
constructor(name: string, serializer?: Serializer);
save(): void;
// Add a model, giving it a (hopefully)-unique GUID, if it doesn't already
// have an id of it's own.
create(model: any): any;
// Update a model by replacing its copy in `this.data`.
update(model: any): any;
// Retrieve a model from `this.data` by id.
find(model: any): any;
// Return the array of all models currently in storage.
findAll(): any;
// Delete a model from `this.data`, returning it.
destroy<T>(model: T): T;
localStorage(): any;
// Clear localStorage for specific collection.
_clear(): void;
_storageSize(): number;
_itemName(id: any): string;
}
}
import Store = Backbone.LocalStorage;