Skip to content

Commit 1a2ee5c

Browse files
authored
Merge pull request #107 from SpringRoll/chore/docs-update
Chore/docs update
2 parents a5c3a8e + 1bec36f commit 1a2ee5c

7 files changed

Lines changed: 104 additions & 7989 deletions

File tree

README.md

Lines changed: 72 additions & 43 deletions
Large diffs are not rendered by default.

dist/SpringRoll-Container-umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/SpringRoll-Container-umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 1 addition & 7917 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/SavedData.js

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export class SavedData {
2727
* Save a variable.
2828
* @method write
2929
* @static
30-
* @param {String} name The name of the value to save
31-
* @param {*} value The value to save. This will be run through JSON.stringify().
32-
* @param {Boolean} [tempOnly=false] If the value should be saved only in the current browser session.
30+
* @param {string} name The name of the value to save
31+
* @param {string} value The value to save. This will be run through JSON.stringify().
32+
* @param {boolean} [tempOnly=false] If the value should be saved only in the current browser session.
3333
*/
3434
static write(name, value, tempOnly = false) {
3535

@@ -68,7 +68,7 @@ export class SavedData {
6868
/**
6969
* Open a connection with the IDB Database and optionally add or delete
7070
* Indexes and stores
71-
*
71+
*
7272
* @param {string} dbName The name of your IndexedDB database
7373
* @param {string} dbVersion The version number of the database. Additions and deletions will be ignored if lower than current version number
7474
* @param {JSON} additions Any additions to the structure of the database
@@ -111,7 +111,7 @@ export class SavedData {
111111
});
112112
}
113113
}
114-
114+
115115
if (deletions != null) {
116116
if (deletions.indexes != null) {
117117
// delete indexes first to avoid deleting an index to a store that has already to been deleted
@@ -133,9 +133,9 @@ export class SavedData {
133133

134134
/**
135135
* Delete a database and all records, stores, and indexes associated
136-
* @param {*} dbName Name of the database to delete
137-
* @param {*} options Optionally pass in options
138-
* @param {*} callback The callback to be run on success or error. One value will be passed into this function
136+
* @param {string} dbName Name of the database to delete
137+
* @param {object} options Optionally pass in options
138+
* @param {function} callback The callback to be run on success or error. One value will be passed into this function
139139
*/
140140
IDBDeleteDB(dbName, options = null, callback = {}) {
141141
const request = options != null ? indexedDB.deleteDatabase(dbName, options): indexedDB.deleteDatabase(dbName);
@@ -153,28 +153,28 @@ export class SavedData {
153153
/**
154154
* Add a record to a given store
155155
* @param {string} storeName The name of the store from which the record will be updated
156-
* @param {string} key the key of the record to be updated
157-
* @param {*} value The value for the record with the given key to be updated
156+
* @param {string} key the key of the record to be updated
157+
* @param {string} value The value for the record with the given key to be updated
158158
* @param {function} callback The method to call on success or failure. A single value will be passed in
159159
*/
160160
IDBAdd(storeName, value, key, callback) {
161161
if ( !this.db && this.dbName != '') {
162162
this.IDBOpen(this.dbName);
163163
}
164-
164+
165165
const tx = this.db.transaction(storeName, 'readwrite');
166166
tx.onerror = () => callback({result: tx.error != null ? tx.error.toString() : 'Aborted: No error given, was the record already added?', success: false});
167167
tx.onabort = () => callback({result: tx.error != null ? tx.error.toString() : 'Aborted: No error given, was the record already added?', success: false});
168-
168+
169169
tx.oncomplete = () => callback({result: 'Success: Record Added', success: true});
170170
const store = tx.objectStore(storeName);
171171
store.add(value, key);
172172
}
173173

174174
/**
175175
* Update a record in a given store
176-
* @param {string} storeName
177-
* @param {string} key the key of the record to be updated
176+
* @param {string} storeName The name of the store from which the record will be updated
177+
* @param {string} key the key of the record to be updated
178178
* @param {string | object} value The altered object to be updated from the given store
179179
* @param {function} callback The method to call on success or failure. A single value will be passed in
180180
*/
@@ -185,7 +185,7 @@ export class SavedData {
185185

186186
const tx = this.db.transaction(storeName, 'readwrite');
187187
const store = tx.objectStore(storeName);
188-
188+
189189
const updateRequest = store.put(value, key);
190190

191191
updateRequest.onsuccess = () => {
@@ -197,8 +197,8 @@ export class SavedData {
197197

198198
/**
199199
* Delete a given record within a given store
200-
* @param {*} storeName
201-
* @param {*} key
200+
* @param {string} storeName The name of the store from which the record will be removed
201+
* @param {string} key the key of the record to be removed
202202
* @param {function} callback The method to call on success or failure. A single value will be passed in
203203
*/
204204
IDBRemove(storeName, key, callback) {
@@ -217,8 +217,8 @@ export class SavedData {
217217

218218
/**
219219
* Return a record from a given store with a given key
220-
* @param {string} storeName
221-
* @param {string} key The key for the record in the given store
220+
* @param {string} storeName the name of the store to read from
221+
* @param {string} key The key for the record in the given store
222222
* @param {function} callback The method to call on success or failure. A single value will be passed in
223223
*/
224224
IDBRead(storeName, key, callback) {
@@ -228,7 +228,7 @@ export class SavedData {
228228
const store = tx.objectStore(storeName);
229229

230230
tx.onerror = () => callback({result: this.db.error.toString(), success: false});
231-
231+
232232
const readRequest = store.get(key);
233233

234234
readRequest.onsuccess = () => {
@@ -239,9 +239,11 @@ export class SavedData {
239239

240240
/**
241241
* Get all keys with given index
242+
* @param {string} storeName the name of the store to be read from
243+
* @param {string} indexName the name of the index to be read from
242244
* @param {string} query Optionally give a keyRange of records to return
243245
* @param {string} count Optionally give a max limit on records to be returned
244-
* @param {function} callback The method to call on success or failure. A single value will be passed in
246+
* @param {function} callback The method to call on success or failure. A single value will be passed in as a parameter
245247
*/
246248
IDBGetIndexKeys (storeName, indexName, query = null, count = null, callback = {}) {
247249
// Open transaction with a store
@@ -280,7 +282,7 @@ export class SavedData {
280282
const tx = this.db.transaction(storeName, 'readonly');
281283
// Get the store object from the transaction
282284
const store = tx.objectStore(storeName);
283-
285+
284286
const readRequest = count != null ? store.getAll(null, count) : store.getAll();
285287

286288
// const readRequest = store.getAll();
@@ -294,7 +296,7 @@ export class SavedData {
294296
}
295297

296298
/**
297-
* Get the version number of a given database. This will create a database if it doesn't exist.
299+
* Get the version number of a given database. This will create a database if it doesn't exist.
298300
* Do not call this after opening a connection with the database
299301
* @param {string} dbName The name of the database for which the version will be returned
300302
* @param {function} callback The method to call on success or failure. A single value will be passed in
@@ -323,7 +325,7 @@ export class SavedData {
323325
if ( this.db ) {
324326
this.db.close();
325327
callback({result: 'Success: Closed Database Connection', success: true});
326-
}
328+
}
327329
}
328-
330+
329331
}

0 commit comments

Comments
 (0)