├── .babelrc ├── .editorconfig ├── .gitignore ├── .jshintrc ├── .travis.yml ├── LICENSE.txt ├── Makefile ├── README.md ├── package.json └── src ├── __tests__ └── index-test.js └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ "modern-node/0.12" ] 3 | } 4 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build artefacts 2 | /build/ 3 | 4 | # npm 5 | /node_modules/ 6 | /npm-debug.log 7 | /redux-storage-*.tgz 8 | 9 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "esnext": true 3 | } 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "5.5" 4 | - "5.4" 5 | - "5.3" 6 | - "5.2" 7 | - "5.1" 8 | - "5.0" 9 | - "4.2" 10 | - "4.1" 11 | - "0.12" 12 | - "0.10" 13 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Michael Contento 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /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-reactnativeasyncstorage][] 2 | 3 | [![build](https://travis-ci.org/michaelcontento/redux-storage-engine-reactnativeasyncstorage.svg?branch=master)](https://travis-ci.org/michaelcontento/redux-storage-engine-reactnativeasyncstorage) 4 | [![dependencies](https://david-dm.org/michaelcontento/redux-storage-engine-reactnativeasyncstorage.svg)](https://david-dm.org/michaelcontento/redux-storage-engine-reactnativeasyncstorage) 5 | [![devDependencies](https://david-dm.org/michaelcontento/redux-storage-engine-reactnativeasyncstorage/dev-status.svg)](https://david-dm.org/michaelcontento/redux-storage-engine-reactnativeasyncstorage#info=devDependencies) 6 | 7 | [![license](https://img.shields.io/npm/l/redux-storage-engine-reactnativeasyncstorage.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-engine-reactnativeasyncstorage) 8 | [![npm version](https://img.shields.io/npm/v/redux-storage-engine-reactnativeasyncstorage.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-engine-reactnativeasyncstorage) 9 | [![npm downloads](https://img.shields.io/npm/dm/redux-storage-engine-reactnativeasyncstorage.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-engine-reactnativeasyncstorage) 10 | 11 | `AsyncStorage` based engine for [redux-storage][]. 12 | 13 | # Moved to the react-stack organisation 14 | 15 | My focus has left the node / react ecosystem and this module has got a new home 16 | over at [react-stack](https://github.com/react-stack/redux-storage-engine-reactnativeasyncstorage)! 17 | 18 | ## Installation 19 | 20 | npm install --save redux-storage-engine-reactnativeasyncstorage 21 | 22 | ## Usage 23 | 24 | This will use `AsyncStorage` out of [react-native][]. 25 | 26 | ```js 27 | import createEngine from 'redux-storage-engine-reactnativeasyncstorage'; 28 | const engine = createEngine('my-save-key'); 29 | ``` 30 | 31 | ## License 32 | 33 | The MIT License (MIT) 34 | 35 | Copyright (c) 2015 Michael Contento 36 | 37 | Permission is hereby granted, free of charge, to any person obtaining a copy of 38 | this software and associated documentation files (the "Software"), to deal in 39 | the Software without restriction, including without limitation the rights to 40 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 41 | the Software, and to permit persons to whom the Software is furnished to do so, 42 | subject to the following conditions: 43 | 44 | The above copyright notice and this permission notice shall be included in all 45 | copies or substantial portions of the Software. 46 | 47 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 48 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 49 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 50 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 51 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 52 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 53 | 54 | [redux-storage]: https://github.com/michaelcontento/redux-storage 55 | [redux-storage-engine-reactnativeasyncstorage]: https://github.com/michaelcontento/redux-storage-engine-reactnativeasyncstorage 56 | [react-native]: https://facebook.github.io/react-native/ 57 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "redux-storage-engine-reactnativeasyncstorage", 3 | "version": "1.0.2", 4 | "description": "react-native/AsyncStorage based engine for redux-storage", 5 | "main": "build/index.js", 6 | "scripts": { 7 | "test": "make lint test build" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/michaelcontento/redux-storage-engine-reactnativeasyncstorage.git" 12 | }, 13 | "homepage": "https://github.com/michaelcontento/redux-storage-engine-reactnativeasyncstorage", 14 | "keywords": [ 15 | "redux", 16 | "redux-storage", 17 | "redux-storage-engine", 18 | "react-native" 19 | ], 20 | "author": "Michael Contento ", 21 | "files": [ 22 | "build/", 23 | "src", 24 | "!**/__tests__/**" 25 | ], 26 | "eslintConfig": { 27 | "extends": "michaelcontento" 28 | }, 29 | "license": "MIT", 30 | "devDependencies": { 31 | "babel-cli": "^6.4.0", 32 | "babel-core": "^6.4.0", 33 | "babel-polyfill": "^6.3.14", 34 | "babel-preset-modern-node": "^2.1.0", 35 | "eslint": "^1.10.3", 36 | "eslint-config-michaelcontento": "^1.1.1", 37 | "eslint-plugin-mocha-only": "0.0.3", 38 | "mocca": "^1.0.3", 39 | "release-it": "^2.3.1" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/__tests__/index-test.js: -------------------------------------------------------------------------------- 1 | describe('engine', () => { 2 | }); 3 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import { AsyncStorage } from 'react-native'; 2 | 3 | export default (key) => ({ 4 | load() { 5 | return AsyncStorage.getItem(key) 6 | .then((jsonState) => JSON.parse(jsonState) || {}); 7 | }, 8 | 9 | save(state) { 10 | const jsonState = JSON.stringify(state); 11 | return AsyncStorage.setItem(key, jsonState); 12 | } 13 | }); 14 | --------------------------------------------------------------------------------