Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: michaelcontento/redux-storage-decorator-immutablejs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: react-stack/redux-storage-decorator-immutablejs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 14 commits
  • 5 files changed
  • 4 contributors

Commits on Nov 9, 2016

  1. Update README.md

    guns2410 authored Nov 9, 2016
    Copy the full SHA
    21ca40d View commit details
  2. Update README.md

    guns2410 authored Nov 9, 2016
    Copy the full SHA
    133c8a7 View commit details
  3. Update README.md

    guns2410 authored Nov 9, 2016
    Copy the full SHA
    a2f21cd View commit details
  4. Update package.json

    guns2410 authored Nov 9, 2016
    Copy the full SHA
    d937d2d View commit details

Commits on Nov 16, 2016

  1. Updated license

    guns2410 authored Nov 16, 2016
    Copy the full SHA
    8d7b026 View commit details
  2. Update LICENSE.txt

    guns2410 authored Nov 16, 2016
    Copy the full SHA
    e8c9572 View commit details

Commits on Nov 24, 2016

  1. Update README.md

    guns2410 authored Nov 24, 2016
    Copy the full SHA
    227e9af View commit details

Commits on Dec 12, 2016

  1. Update README.md

    michaelcontento authored Dec 12, 2016

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    570fcf0 View commit details
  2. Update package.json

    michaelcontento authored Dec 12, 2016

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    289e12c View commit details
  3. Release 1.0.3

    michaelcontento committed Dec 12, 2016

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    190c89a View commit details
  4. Release 1.0.4

    michaelcontento committed Dec 12, 2016

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    88df4cf View commit details

Commits on May 11, 2017

  1. Copy the full SHA
    ded1dd4 View commit details
  2. Merge pull request #1 from jmfrancois/jmfrancois/nested-key

    fix: make nested key working
    guns2410 authored May 11, 2017
    Copy the full SHA
    3981638 View commit details

Commits on May 15, 2017

  1. Copy the full SHA
    5a3b32d View commit details
Showing with 71 additions and 24 deletions.
  1. +2 −1 LICENSE.txt
  2. +14 −17 README.md
  3. +8 −4 package.json
  4. +35 −0 src/__tests__/index-test.js
  5. +12 −2 src/index.js
3 changes: 2 additions & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2015 Michael Contento
Copyright (c) 2016- Gunjan Soni <gunjan.soni2002@gmail.com>
Copyright (c) 2015-2016 Michael Contento <mail@michaelcontento.de>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
# [redux-storage-decorator-immutablejs][]
# redux-storage-decorator-immutablejs

[![build](https://travis-ci.org/michaelcontento/redux-storage-decorator-immutablejs.svg?branch=master)](https://travis-ci.org/michaelcontento/redux-storage-decorator-immutablejs)
[![dependencies](https://david-dm.org/michaelcontento/redux-storage-decorator-immutablejs.svg)](https://david-dm.org/michaelcontento/redux-storage-decorator-immutablejs)
[![devDependencies](https://david-dm.org/michaelcontento/redux-storage-decorator-immutablejs/dev-status.svg)](https://david-dm.org/michaelcontento/redux-storage-decorator-immutablejs#info=devDependencies)
[![build](https://travis-ci.org/react-stack/redux-storage-decorator-immutablejs.svg?branch=master)](https://travis-ci.org/react-stack/redux-storage-decorator-immutablejs)
[![dependencies](https://david-dm.org/react-stack/redux-storage-decorator-immutablejs.svg)](https://david-dm.org/react-stack/redux-storage-decorator-immutablejs)
[![devDependencies](https://david-dm.org/react-stack/redux-storage-decorator-immutablejs/dev-status.svg)](https://david-dm.org/react-stack/redux-storage-decorator-immutablejs#info=devDependencies)

[![license](https://img.shields.io/npm/l/redux-storage-decorator-immutablejs.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-immutablejs)
[![npm version](https://img.shields.io/npm/v/redux-storage-decorator-immutablejs.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-immutablejs)
[![npm downloads](https://img.shields.io/npm/dm/redux-storage-decorator-immutablejs.svg?style=flat-square)](https://www.npmjs.com/package/redux-storage-decorator-immutablejs)
[![Code Climate](https://codeclimate.com/github/michaelcontento/redux-storage-decorator-immutablejs/badges/gpa.svg)](https://codeclimate.com/github/michaelcontento/redux-storage-decorator-immutablejs)

[ImmutableJS][] decorator for [redux-storage][]. Use this to convert the loaded
state tree (or parts of it) into a [ImmutableJS][] structure.

# Deprecated - No longer maintained

My focus has left the node / react ecosystem and this module is no
longer maintained. Maybe [redux-persist](https://github.com/rt2zz/redux-persist)
is a good replacement for you? Or if you want to step in and become
the new owner - just ping me :smile:

Thank you for your patience and using this module in the first place!

## Installation

npm install --save redux-storage-decorator-immutablejs
@@ -39,11 +29,18 @@ engine = immutablejs(engine, [
]);
```

# A fork of [redux-storage-decorator-immutablejs](https://github.com/michaelcontento/redux-storage-decorator-immutablejs)

The original author of the package [redux-storage-decorator-immutablejs](https://github.com/michaelcontento/redux-storage-decorator-immutablejs) has decided to deprecate the project and no longer maintained. The package will now be maintained here.

Thank you [michaelcontento](https://github.com/michaelcontento) for a great library!

## License

The MIT License (MIT)

Copyright (c) 2015 Michael Contento
Copyright (c) 2016- Gunjan Soni <gunjan.soni2002@gmail.com>
Copyright (c) 2015-2016 Michael Contento <mail@michaelcontento.de>

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
@@ -62,6 +59,6 @@ engine = immutablejs(engine, [
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

[redux-storage]: https://github.com/michaelcontento/redux-storage
[redux-storage-decorator-immutablejs]: https://github.com/michaelcontento/redux-storage-decorator-immutablejs
[redux-storage]: https://github.com/react-stack/redux-storage
[redux-storage-decorator-immutablejs]: https://github.com/react-stack/redux-storage-decorator-immutablejs
[ImmutableJS]: https://github.com/facebook/immutable-js
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
{
"name": "redux-storage-decorator-immutablejs",
"version": "1.0.2",
"version": "1.0.4",
"description": "Decorator for redux-storage to convert your state tree to ImmutableJS",
"main": "build/index.js",
"scripts": {
"test": "make lint test build"
},
"repository": {
"type": "git",
"url": "https://github.com/michaelcontento/redux-storage-decorator-immutablejs.git"
"url": "https://github.com/react-stack/redux-storage-decorator-immutablejs.git"
},
"homepage": "https://github.com/michaelcontento/redux-storage-decorator-immutablejs",
"bugs": "https://github.com/react-stack/redux-storage-decorator-immutablejs/issues",
"homepage": "https://github.com/react-stack/redux-storage-decorator-immutablejs",
"keywords": [
"redux",
"redux-storage",
"redux-storage-decorator",
"immutable"
],
"author": "Michael Contento <michaelcontento@gmail.com>",
"author": [
"Michael Contento <mail@michaelcontento.de>",
"Guns <gunjan.soni2002@gmail.com>"
],
"files": [
"build/",
"src",
35 changes: 35 additions & 0 deletions src/__tests__/index-test.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
import decorator from '../';
import assert from 'assert';

const STATE = {
key: { foo: 'bar' },
nested: { key: { foo: 'baz' } },
};

const ENGINE = {
save: () => {},
load: () => new Promise(function l(resolve) {
return resolve(STATE);
}),
};

describe('decorator', () => {
it('should be a function which return save, load', () => {
const ret = decorator(ENGINE);
assert.equal(typeof ret.load, 'function');
assert.equal(typeof ret.save, 'function');
});
it('should support key and nested key', (done) => {
const ret = decorator(ENGINE, ['key', ['nested', 'key']]);
ret.load().then((state) => {
assert.equal(typeof state.key.get, 'function');
assert.equal(typeof state.nested.key.get, 'function');
done();
}, (error) => done(error));
});
it('should support nested key not in already in state', (done) => {
const ret = decorator(ENGINE, [['nested', 'not-in-key', 'foo', 'bar']]);
ret.load().then((state) => {
assert.equal(state.nested['not-in-key'], undefined);
done();
}, (error) => done(error));
});
});
14 changes: 12 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -6,8 +6,18 @@ export default (engine, whitelist = []) => {

load() {
return engine.load().then((result) => {
whitelist.forEach((key) => {
result[key] = fromJS(result[key]);
whitelist.forEach((keys) => {
if (typeof keys === 'string') {
keys = [keys]; // eslint-disable-line no-param-reassign
}
let tmp = result;
keys.forEach((key, index) => {
if (tmp && index === keys.length - 1) {
tmp[key] = fromJS(tmp[key]);
} else if (tmp) {
tmp = tmp[key];
}
});
});
return result;
});