├── .moccarc ├── .jshintrc ├── .travis.yml ├── .babelrc ├── .gitignore ├── .editorconfig ├── src ├── index.js └── __tests__ │ └── index-test.js ├── LICENSE.txt ├── package.json ├── Makefile └── README.md /.moccarc: -------------------------------------------------------------------------------- 1 | --globals localStorage 2 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esnext": true 3 | } 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "8" 4 | - "5.5" -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ "modern-node/0.12", "stage-3" ] 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # npm 2 | /node_modules/ 3 | /npm-debug.log 4 | /redux-storage-*.tgz 5 | 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [package.json] 12 | indent_size = 2 13 | 14 | [Makefile] 15 | indent_style = tab 16 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import idbKeyVal from 'idb-keyval'; 2 | 3 | const idb = function idb(store) { 4 | return { 5 | load() { 6 | return idbKeyVal.get(store); 7 | }, 8 | 9 | save(states) { 10 | return idbKeyVal.set(store, states); 11 | } 12 | }; 13 | }; 14 | 15 | export default idb; 16 | -------------------------------------------------------------------------------- /src/__tests__/index-test.js: -------------------------------------------------------------------------------- 1 | describe('engine', () => { 2 | const returnVal = 'SOME_VAL'; 3 | const idbKeyVal = { 4 | set: sinon.stub().returns(new Promise((resolve) => { 5 | resolve(returnVal); 6 | })), 7 | get: sinon.stub().returns(new Promise((resolve) => { 8 | resolve(returnVal); 9 | })), 10 | }; 11 | describe('check proxies', () => { 12 | it('should call the idbKeyVal set method and return the response as it is', async () => { 13 | const result = await idbKeyVal.set('key', 'val'); 14 | idbKeyVal.set.should.have.been.calledWith('key', 'val'); 15 | result.should.equal(returnVal); 16 | }); 17 | 18 | it('should call the idbKeyVal get method and return the response as it is', async () => { 19 | const result = await idbKeyVal.get('key'); 20 | idbKeyVal.get.should.have.been.calledWith('key'); 21 | result.should.equal(returnVal); 22 | }); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016- Gunjan Soni 4 | Copyright (c) 2015-2016 Michael Contento 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | this software and associated documentation files (the "Software"), to deal in 8 | the Software without restriction, including without limitation the rights to 9 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | the Software, and to permit persons to whom the Software is furnished to do so, 11 | subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "redux-storage-engine-indexed-db", 3 | "version": "1.0.0", 4 | "description": "window.indexedDB engine for redux-storage", 5 | "main": "build/index.js", 6 | "module": "src/index.js", 7 | "scripts": { 8 | "build": "make build", 9 | "test": "make lint test build" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "https://github.com/prateekbh/redux-storage-engine-indexed-db.git" 14 | }, 15 | "bugs": "https://github.com/prateekbh/redux-storage-engine-indexed-db/issues", 16 | "homepage": "https://github.com/prateekbh/redux-storage-engine-indexed-db", 17 | "keywords": [ 18 | "redux", 19 | "redux-storage", 20 | "redux-storage-engine", 21 | "indexed-db" 22 | ], 23 | "author": "Prateek Bhatnagar ", 24 | "files": [ 25 | "build/", 26 | "src", 27 | "!**/__tests__/**" 28 | ], 29 | "eslintConfig": { 30 | "extends": "michaelcontento" 31 | }, 32 | "license": "MIT", 33 | "devDependencies": { 34 | "babel-cli": "^6.4.0", 35 | "babel-core": "^6.4.0", 36 | "babel-polyfill": "^6.3.14", 37 | "babel-preset-modern-node": "^2.1.0", 38 | "babel-preset-stage-3": "^6.5.0", 39 | "eslint": "^1.10.3", 40 | "eslint-config-michaelcontento": "^1.1.1", 41 | "eslint-plugin-mocha-only": "0.0.3", 42 | "idb-keyval": "^2.3.0", 43 | "mocca": "^1.0.3", 44 | "release-it": "^2.3.1" 45 | }, 46 | "dependencies": { 47 | "idb-keyval": "^2.3.0" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | BIN = ./node_modules/.bin 2 | NPM = npm --loglevel=error 3 | 4 | # 5 | # INSTALL 6 | # 7 | 8 | install: node_modules/ 9 | 10 | node_modules/: package.json 11 | echo "> Installing ..." 12 | $(NPM) --ignore-scripts install > /dev/null 13 | touch node_modules/ 14 | 15 | # 16 | # CLEAN 17 | # 18 | 19 | clean: 20 | echo "> Cleaning ..." 21 | rm -rf build/ 22 | 23 | mrproper: clean 24 | echo "> Cleaning deep ..." 25 | rm -rf node_modules/ 26 | 27 | # 28 | # BUILD 29 | # 30 | 31 | build: clean install 32 | echo "> Building ..." 33 | $(BIN)/babel src/ --out-dir build/ 34 | 35 | build-watch: clean install 36 | echo "> Building forever ..." 37 | $(BIN)/babel src/ --out-dir build/ --watch 38 | 39 | # 40 | # TEST 41 | # 42 | 43 | lint: install 44 | echo "> Linting ..." 45 | $(BIN)/eslint src/ 46 | 47 | test: install 48 | echo "> Testing ..." 49 | $(BIN)/mocca 50 | 51 | test-watch: install 52 | echo "> Testing forever ..." 53 | $(BIN)/mocca --watch 54 | 55 | # 56 | # PUBLISH 57 | # 58 | 59 | _publish : NODE_ENV ?= production 60 | _publish: lint test build 61 | 62 | publish-fix: _publish 63 | $(BIN)/release-it --increment patch 64 | 65 | publish-feature: _publish 66 | $(BIN)/release-it --increment minor 67 | 68 | publish-breaking: _publish 69 | $(BIN)/release-it --increment major 70 | 71 | # 72 | # MAKEFILE 73 | # 74 | 75 | .PHONY: \ 76 | install \ 77 | clean mrproper \ 78 | build build-watch \ 79 | lint test test-watch \ 80 | publish-fix publish-feature publish-breaking 81 | 82 | .SILENT: 83 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #redux-storage-engine-indexed-db 2 | 3 | [![build](https://api.travis-ci.org/prateekbh/redux-storage-engine-indexed-db.svg?branch=master)](https://api.travis-ci.org/prateekbh/redux-storage-engine-indexed-db.svg?branch=master) 4 | 5 | `window.indexedDB` based engine for [redux-storage](https://github.com/react-stack/redux-storage). 6 | 7 | ## Installation 8 | 9 | npm install --save redux-storage-engine-indexed-db 10 | 11 | ## Usage 12 | 13 | Stores everything inside `window.indexedDB`. 14 | 15 | ```js 16 | import createEngine from 'redux-storage-engine-indexed-db'; 17 | 18 | const engine = createEngine('store-name'); 19 | ``` 20 | 21 | 22 | ## License 23 | 24 | The MIT License (MIT) 25 | 26 | Copyright (c) 2016- Prateek Bhatnagar 27 | 28 | Permission is hereby granted, free of charge, to any person obtaining a copy of 29 | this software and associated documentation files (the "Software"), to deal in 30 | the Software without restriction, including without limitation the rights to 31 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 32 | the Software, and to permit persons to whom the Software is furnished to do so, 33 | subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in all 36 | copies or substantial portions of the Software. 37 | 38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 40 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 41 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 42 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 43 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 44 | --------------------------------------------------------------------------------