Git Product home page Git Product logo

indexeddb-polyfill's Introduction

Archived Repo

This is an archived project and is no longer supported or updated by Facebook. Please do not file issues or pull-requests against this repo. If you wish to continue to develop this code yourself, we recommend you fork it.

Proceed and be bold!

IndexedDB Polyfill

Contents

  1. Introduction
  2. Using the library
  3. Unit Tests
  4. Performance Tests
  5. Open issues
  6. License
  7. References

1. Introduction

Indexed Database API, or IndexedDB API, on its own is an API for browsers to support client-side storages. This API is implemented on Mozilla Firefox (since version 4), and Google Chrome (since version 11), and should be implemented in Internet Explorer in the next release version 10 [1]. However it is unknown whether it will be implemented by other browsers, as you can see from the link.

[Polyfilling] polyfill-wiki fills that gap by relying on the other capabilities of a browser. So "IndexedDB polyfill" is just a project that is intended to make other browsers "mimic" IndexedDB API. It uses Web SQL Database API, which is another client-side storage API, as a back-end.

The core design of IndexedDB API is databases with key-value tables, which are called ObjectStores. However unlike basic localStorage (sessionStorage), caching and other "key-value" alike storage APIs, it supports Indexing, Cursors, Key Generators, and Transactions. The IndexedDB API documentation[2] describes both synchronous and asynchronous API, but only the second one is implemented in Mozilla and Chrome. In general, the API is pretty flexible.

Documentation: http://www.w3.org/TR/IndexedDB

2. Using the library

All you have to do is to include indexeddb.polyfill.js file into your web page:

<script type="text/javascript" src="indexedDB.polyfill.js"></script>

If the target browser does not support IndexedDB, the polyfill automatically creates indexedDB global object and thus exposes its functionality. So you do not have to modify anything in your existing project with IndexedDB code. If the target browser has native implementation of IndexedDB, the polyfill will not interfere with it.

To force using polyfill append the following script before including the polyfill:

window.indexedDB = { polyfill : true };

###3. Unit Tests

To run unit tests open index.html in target browser. To verify unit tests against Firefox's native implementation of IndexedDB API, open the same page through web (http) server. Because, otherwise Firefox does not let to create IndexedDB databases under localhost origin.

The project also includes tests imported from [W3C-tests.org] 3 (see References section)

4. Performance Tests

All the database related routines, such as adding, deleting, clearing, creating indexes, cursors, can be tested for performance benchmarks using test/benchmark.html tool.

5. Open issues

Currently, the project has lack of JavaScript Date Object support when storing and reading it from ObjectStore. This is because values (not keys) are encoded and decoded using JSON serialization which does not parse date back to JavaScript Date Object.

6. License

The software is distributed under Apache License 2.0

7. Rerencess

  1. Test suits http://w3c-test.org/webapps/IndexedDB/;
  2. Mozilla IndexedDB implementation: http://hg.mozilla.org/mozilla-central/file/895e12563245/dom/indexedDB/;

indexeddb-polyfill's People

Contributors

jamesgpearce avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.