Skip to content

Commit

Permalink
Don’t make promises immutable, but make their fulfillment value immut…
Browse files Browse the repository at this point in the history
…able.
  • Loading branch information
dentrado committed Jan 13, 2017
1 parent 7408f7c commit 492d53e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
7 changes: 7 additions & 0 deletions seamless-immutable.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,16 @@ function immutableInit(config) {
obj instanceof File;
}

function isPromise(obj) {
return typeof obj === 'object' &&
typeof obj.then === 'function';
}

function Immutable(obj, options, stackRemaining) {
if (isImmutable(obj) || isReactElement(obj) || isFileObject(obj)) {
return obj;
} else if (isPromise(obj)) {
return obj.then(Immutable);
} else if (Array.isArray(obj)) {
return makeImmutableArray(obj.slice());
} else if (obj instanceof Date) {
Expand Down
2 changes: 1 addition & 1 deletion seamless-immutable.development.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 492d53e

Please sign in to comment.