fake-indexeddb
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -52,5 +52,12 @@ 'use strict'; | ||
this.storeRecord = function (newRecord) { | ||
var indexKey = extractKey(this.keyPath, newRecord.value); | ||
if (indexKey === undefined) { | ||
return; | ||
var indexKey; | ||
try { | ||
indexKey = extractKey(this.keyPath, newRecord.value); | ||
} catch (err) { | ||
if (err.name === 'DataError') { | ||
// Invalid key is not an actual error, just means we do not store an entry in this index | ||
return; | ||
} | ||
throw err; | ||
} | ||
@@ -57,0 +64,0 @@ |
{ | ||
"name": "fake-indexeddb", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "Fake IndexedDB: a pure JS in-memory implementation of the IndexedDB API", | ||
@@ -34,14 +34,14 @@ "homepage": "https://github.com/dumbmatter/fakeIndexedDB", | ||
"dependencies": { | ||
"array.prototype.find": "1.0.0", | ||
"array.prototype.findindex": "1.0.0", | ||
"realistic-structured-clone": "0.0.2", | ||
"setimmediate": "1.0.4" | ||
"array.prototype.find": "^1.0.0", | ||
"array.prototype.findindex": "^1.0.0", | ||
"realistic-structured-clone": "^0.0.3", | ||
"setimmediate": "^1.0.5" | ||
}, | ||
"devDependencies": { | ||
"browserify": "13.1.0", | ||
"eslint": "3.2.2", | ||
"mocha": "3.0.2", | ||
"node-qunit-phantomjs": "1.4.0", | ||
"qunitjs": "1.x" | ||
"browserify": "^14.0.0", | ||
"eslint": "^3.15.0", | ||
"mocha": "^3.2.0", | ||
"node-qunit-phantomjs": "^1.5.0", | ||
"qunitjs": "^1.23.1" | ||
} | ||
} |
@@ -11,7 +11,11 @@ # Fake IndexedDB [![Build Status](https://travis-ci.org/dumbmatter/fakeIndexedDB.svg?branch=master)](https://travis-ci.org/dumbmatter/fakeIndexedDB) | ||
$ npm install fake-indexeddb | ||
```sh | ||
npm install fake-indexeddb | ||
``` | ||
Otherwise, download [the bundled version](dist/fakeIndexedDB.js) and include it in your page like: | ||
<script type="text/javascript" src="fakeIndexedDB.js"></script> | ||
```html | ||
<script type="text/javascript" src="fakeIndexedDB.js"></script> | ||
``` | ||
@@ -26,34 +30,36 @@ If you're using AMD, you'll have to shim it. | ||
var fakeIndexedDB = require('fake-indexeddb'); | ||
var FDBKeyRange = require('fake-indexeddb/lib/FDBKeyRange'); | ||
```js | ||
var fakeIndexedDB = require('fake-indexeddb'); | ||
var FDBKeyRange = require('fake-indexeddb/lib/FDBKeyRange'); | ||
var request = fakeIndexedDB.open('test', 3); | ||
request.onupgradeneeded = function () { | ||
var db = request.result; | ||
var store = db.createObjectStore("books", {keyPath: "isbn"}); | ||
store.createIndex("by_title", "title", {unique: true}); | ||
var request = fakeIndexedDB.open('test', 3); | ||
request.onupgradeneeded = function () { | ||
var db = request.result; | ||
var store = db.createObjectStore("books", {keyPath: "isbn"}); | ||
store.createIndex("by_title", "title", {unique: true}); | ||
store.put({title: "Quarry Memories", author: "Fred", isbn: 123456}); | ||
store.put({title: "Water Buffaloes", author: "Fred", isbn: 234567}); | ||
store.put({title: "Bedrock Nights", author: "Barney", isbn: 345678}); | ||
} | ||
request.onsuccess = function (event) { | ||
var db = event.target.result; | ||
store.put({title: "Quarry Memories", author: "Fred", isbn: 123456}); | ||
store.put({title: "Water Buffaloes", author: "Fred", isbn: 234567}); | ||
store.put({title: "Bedrock Nights", author: "Barney", isbn: 345678}); | ||
} | ||
request.onsuccess = function (event) { | ||
var db = event.target.result; | ||
var tx = db.transaction("books"); | ||
var tx = db.transaction("books"); | ||
tx.objectStore("books").index("by_title").get("Quarry Memories").addEventListener('success', function (event) { | ||
console.log('From index:', event.target.result); | ||
}); | ||
tx.objectStore("books").openCursor(FDBKeyRange.lowerBound(200000)).onsuccess = function (event) { | ||
var cursor = event.target.result; | ||
if (cursor) { | ||
console.log('From cursor:', cursor.value); | ||
cursor.continue(); | ||
} | ||
}; | ||
tx.oncomplete = function () { | ||
console.log('All done!'); | ||
}; | ||
tx.objectStore("books").index("by_title").get("Quarry Memories").addEventListener('success', function (event) { | ||
console.log('From index:', event.target.result); | ||
}); | ||
tx.objectStore("books").openCursor(FDBKeyRange.lowerBound(200000)).onsuccess = function (event) { | ||
var cursor = event.target.result; | ||
if (cursor) { | ||
console.log('From cursor:', cursor.value); | ||
cursor.continue(); | ||
} | ||
}; | ||
tx.oncomplete = function () { | ||
console.log('All done!'); | ||
}; | ||
}; | ||
``` | ||
@@ -60,0 +66,0 @@ Variable names of all the objects are like the normal IndexedDB ones except with F replacing I, e.g. `FDBIndex` instead of `IDBIndex`. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
NPM Shrinkwrap
Supply chain riskPackage contains a shrinkwrap file. This may allow the package to bypass normal install procedures.
Found 1 instance in 1 package
85
0
251048
39
6015
+ Addedrealistic-structured-clone@0.0.3(transitive)
+ Addedsetimmediate@1.0.5(transitive)
- Removedrealistic-structured-clone@0.0.2(transitive)
- Removedsetimmediate@1.0.4(transitive)
Updatedarray.prototype.find@^1.0.0
Updatedsetimmediate@^1.0.5