This repository has been archived by the owner on Dec 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conditionally import immutable and use either isImmutable or isIterable
- Loading branch information
1 parent
e0fe9c9
commit dee80a7
Showing
5 changed files
with
36 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// @flow | ||
/* eslint-disable import/no-mutable-exports, no-empty */ | ||
const throwError = (...args) => { | ||
throw new Error( | ||
`immutable.js was not imported. Make sure you have it installed. Was called with ${args}.` | ||
); | ||
}; | ||
|
||
let immutable; | ||
let Map = throwError; | ||
let List = throwError; | ||
let fromJS = throwError; | ||
let isImmutable = throwError; | ||
|
||
try { | ||
immutable = require('immutable'); | ||
Map = immutable.Map; | ||
List = immutable.List; | ||
fromJS = immutable.fromJS; | ||
// To account for immutable versions 3.8.x -> 4.x.x | ||
isImmutable = immutable.isImmutable ? immutable.isImmutable : immutable.Iterable.isIterable; | ||
} catch (e) {} | ||
|
||
export { | ||
Map, | ||
List, | ||
fromJS, | ||
isImmutable | ||
}; | ||
|
||
export default immutable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters