Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fruitdown

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fruitdown - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.idea/jsLibraryMappings.xml

7

database-core.js

@@ -92,3 +92,6 @@ 'use strict';

txn.oncomplete = function () {
callback(null, keys);
// Safari has a bug where these keys aren't returned in sorted
// order, so we have to sort them explicitly
// https://bugs.webkit.org/show_bug.cgi?id=149205
callback(null, keys.sort());
};

@@ -203,2 +206,2 @@

module.exports = StorageCore;
module.exports = StorageCore;

@@ -15,3 +15,3 @@ {

],
"version": "1.0.0",
"version": "1.0.1",
"main": "index.js",

@@ -27,6 +27,11 @@ "dependencies": {

"beefy": "~1.1.0",
"browserify": "^4.1.2",
"browserify": "^11.1.0",
"fake-indexeddb": "^1.0.3",
"jshint": "^2.5.0",
"levelup": "^0.18.2",
"smokestack": "^3.3.1",
"tap-closer": "^1.0.0",
"tap-spec": "^4.1.0",
"tape": "^2.12.3",
"jshint": "^2.5.0"
"zuul": "^3.5.0"
},

@@ -41,4 +46,8 @@ "repository": {

"scripts": {
"test": "npm run jshint && beefy tests/test.js",
"jshint": "jshint -c .jshintrc *.js tests/*.js"
"dev": "npm run jshint && beefy tests/test.js",
"jshint": "jshint -c .jshintrc *.js tests/*.js",
"test": "npm run jshint && npm run test-browser",
"test-fakeindexeddb": "node tests/test.js",
"test-browser": "browserify tests/test.js | tap-closer | smokestack -b $BROWSER | tap-spec",
"test-saucelabs": "zuul --browser-name $BROWSER_NAME --browser-version $BROWSER_VERSION -- tests/test.js"
},

@@ -45,0 +54,0 @@ "license": "MIT",

@@ -1,3 +0,5 @@

# FruitDOWN
# FruitDOWN [![Build Status](https://travis-ci.org/nolanlawson/fruitdown.svg?branch=master)](https://travis-ci.org/nolanlawson/fruitdown)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/nolanwlawson.svg)](https://saucelabs.com/u/nolanwlawson)
A browser-based LevelDOWN adapter that works over all implementations of IndexedDB, including Apple's buggy version.

@@ -9,3 +11,3 @@

* Safari/iOS, but you don't want [an annoying popup](http://pouchdb.com/errors.html#not_enough_space) after you reach 5MB
* Safari/iOS, but you need to store more than 50MB, which [doesn't work in WebSQL](http://www.html5rocks.com/en/tutorials/offline/quota-research/) but [works in IndexedDB](https://github.com/nolanlawson/database-filler)
* iOS, but you need to store more than 50MB, which [works in IndexedDB](https://github.com/nolanlawson/database-filler) but [not in WebSQL](http://www.html5rocks.com/en/tutorials/offline/quota-research/)

@@ -22,15 +24,17 @@ This project is intended for use with the [Level ecosystem](https://github.com/level/), including as a [PouchDB](http://pouchdb.com) adapter (coming soon).

Cross-browser IndexedDB support is pretty awful these days. Every browser except for Chrome and Firefox has tons of bugs, but Apple's are [arguably the worst](http://www.raymondcamden.com/2014/09/25/IndexedDB-on-iOS-8-Broken-Bad). While there are well-known workarounds for [Microsoft's bugs](https://gist.github.com/nolanlawson/a841ee23436410f37168), most IndexedDB wrappers just gave up and didn't support Apple IndexedDB. [PouchDB](http://pouchdb.com), [LocalForage](http://mozilla.github.io/localForage/), [YDN-DB](http://dev.yathit.com/ydn-db/downloads.html), [Lovefield](https://github.com/google/lovefield), [Dexie](http://dexie.org/), and [Level.js](https://github.com/maxogden/level.js) all either fall back to WebSQL or recommend that you use the [IndexedDBShim](https://github.com/axemclion/IndexedDBShim).
IndexedDB support is pretty awful these days. Every browser except for Chrome and Firefox has tons of bugs, but Safari's are arguably [the](https://gist.github.com/nolanlawson/08eb857c6b17a30c1b26) [worst](http://www.raymondcamden.com/2014/09/25/IndexedDB-on-iOS-8-Broken-Bad). While there are well-known workarounds for [Microsoft's bugs](https://gist.github.com/nolanlawson/a841ee23436410f37168), most IndexedDB wrappers just gave up and didn't support Apple IndexedDB. [PouchDB](http://pouchdb.com), [LocalForage](http://mozilla.github.io/localForage/), [YDN-DB](http://dev.yathit.com/ydn-db/downloads.html), [Lovefield](https://github.com/google/lovefield), [Dexie](http://dexie.org/), and [Level.js](https://github.com/maxogden/level.js) all either fall back to WebSQL or recommend that you use the [IndexedDBShim](https://github.com/axemclion/IndexedDBShim).
This library is different. It does all the crazy backflips you have to do to support Apple IndexedDB.
This library is different. It does all the weird backflips you have to do to support Apple IndexedDB.
## Design
This project is a fork of [localstorage-down](https://github.com/No9/localstorage-down). It uses a tiny subset of the IndexedDB API – just those things that are supported in Firefox, Chrome, Safari, and IE. The #1 goal is compatibility with as many browsers as possible. The #2 goal is performance.
This project is a fork of [localstorage-down](https://github.com/No9/localstorage-down). It uses a tiny subset of the IndexedDB API – just those parts that are supported in Firefox, Chrome, Safari, and IE. The #1 goal is compatibility with as many browsers as possible. The #2 goal is performance.
All keys are kept in memory at all times, which is bad for memory usage but actually improves performance, because IDBCursors are slow. However, the database creates two indexes, because 1) the primary index does not support `openKeyCursor()` per the IndexedDB 1.0 spec, and we want to use it to avoid reading in large values during key iteration, but 2) secondary indexes [do not correctly throw ConstraintErrors in Safari](https://bugs.webkit.org/show_bug.cgi?id=149107). So unfortunately keys are indexed twice. ¯\\\_(ツ)\_/¯
Only one object store is ever opened, because Apple's implementation [does not allow you to open more than one at once](https://bugs.webkit.org/show_bug.cgi?id=136937). So presumably you would use something like [level-sublevel](https://github.com/dominictarr/level-sublevel/) to prefix keys. Also every operation is its own transaction, so you should not count on standard IndexedDB transaction guarantees, even when you use `batch()`. However, internally the lib does its own batching, and supports [snapshots](https://github.com/Level/leveldown#snapshots).
All keys are kept in memory, which is bad for memory usage but actually a win for performance, since IDBCursors are slow. However, the database creates two indexes, because 1) the primary index does not support `openKeyCursor()` per the IndexedDB 1.0 spec, and we want to use it to avoid reading in large values during key iteration, but 2) secondary indexes [do not correctly throw ConstraintErrors in Safari](https://bugs.webkit.org/show_bug.cgi?id=149107). So unfortunately there's a superfluous extra index. ¯\\\_(ツ)\_/¯
Another limitation is that both keys and values are converted to strings before being stored. So instead of efficiently using Blobs or even JSON objects, binary strings are stored instead. This is okay, though, because Chrome < 43 (and therefore pre-Lollipop Android) [does not store Blobs correctly](https://code.google.com/p/chromium/issues/detail?id=447836), and Safari [doesn't support Blob storage either](https://bugs.webkit.org/show_bug.cgi?id=143193).
To avoid [concurrency bugs in IE/Edge](https://gist.github.com/nolanlawson/a841ee23436410f37168), this project borrows PouchDB's system of maintaining a global cache of databases and only ever using one database per name. This should have zero impact on performance.
To avoid [concurrency bugs in IE/Edge](https://gist.github.com/nolanlawson/a841ee23436410f37168), this project borrows PouchDB's system of maintaining a global cache of databases and only ever using one database per name.

@@ -59,3 +63,3 @@ ## Browser support

```
npm run test
npm run dev
```

@@ -66,4 +70,19 @@

## Automated tests
Browser:
```
BROWSER=firefox npm test
BROWSER=chrome npm test
```
[FakeIndexedDB](https://github.com/dumbmatter/fakeIndexedDB) in Node:
```
npm run test-fakeindexeddb
```
## Thanks
Thanks to [Anton Whalley](https://github.com/no9), [Adam Shih](https://github.com/adamshih) and everybody else who contributed to localstorage-down. Also thanks to everybody who worked on PouchDB, where most of these IndexedDB bugs were discovered.
Thanks to [Anton Whalley](https://github.com/no9), [Adam Shih](https://github.com/adamshih) and everybody else who contributed to localstorage-down. Also thanks to everybody who worked on PouchDB, where most of these IndexedDB bugs were discovered.
'use strict';
if (typeof process !== 'undefined' && !process.browser) {
global.indexedDB = require('fake-indexeddb');
}
var tape = require('tape');

@@ -4,0 +8,0 @@ var lib = require('../');

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc