-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding support for react components in Immutable pretty-format plugins
- Loading branch information
1 parent
2cd9b50
commit e981653
Showing
8 changed files
with
176 additions
and
18 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
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,30 @@ | ||
'use strict'; | ||
|
||
const reactPlugin = require('./ReactElement'); | ||
const prettyFormat = require('../'); | ||
|
||
const IMMUTABLE_NAMESPACE = 'Immutable.'; | ||
|
||
const traverseImmutable = ( | ||
val: Object, | ||
print: Function, | ||
indent: Function, | ||
opts: Object, | ||
colors: Object | ||
) : string => { | ||
let result = IMMUTABLE_NAMESPACE; | ||
|
||
result += val.map((item: any) => { | ||
if (reactPlugin.test(item)) { | ||
return reactPlugin.print(item, print, indent, opts, colors); | ||
} else if (item instanceof Object) { | ||
return prettyFormat(item); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cpenarrieta
Author
Contributor
|
||
} else { | ||
return item; | ||
} | ||
}); | ||
|
||
return result; | ||
}; | ||
|
||
module.exports = traverseImmutable; |
You should use
print
instead ofprettyFormat
andreactPlugin.print
here. Plugins should be automatically resolved then?