Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mattzeunert/immutable-object-formatter-extension
Make ImmutableJS objects more readable when viewed in Chrome DevTools
https://github.com/mattzeunert/immutable-object-formatter-extension
chrome-devtools immutablejs
Last synced: about 2 months ago
JSON representation
Make ImmutableJS objects more readable when viewed in Chrome DevTools
- Host: GitHub
- URL: https://github.com/mattzeunert/immutable-object-formatter-extension
- Owner: mattzeunert
- Created: 2016-03-25T23:24:08.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2022-11-16T02:56:01.000Z (about 2 years ago)
- Last Synced: 2024-04-14T12:10:26.146Z (10 months ago)
- Topics: chrome-devtools, immutablejs
- Language: JavaScript
- Homepage: https://chrome.google.com/webstore/detail/hgldghadipiblonfkkicmgcbbijnpeog
- Size: 752 KB
- Stars: 134
- Watchers: 6
- Forks: 14
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-fe-resources - immutable-object-formatter-extension
README
# Immutable.js Object Formatter (Chrome Extension)
Transforms Immutable JS objects to a more readable format when they are logged to the console.
[Install the Chrome Extension](https://chrome.google.com/webstore/detail/immutablejs-object-format/hgldghadipiblonfkkicmgcbbijnpeog)
Based on [immutable-devtools](https://github.com/andrewdavey/immutable-devtools).
The Chrome extension will only work if you **enable Custom Formatters** in the DevTools settings.
### Step 1: Open DevTools settings
![](https://user-images.githubusercontent.com/1303660/36625688-48c2160e-195f-11e8-9a5f-ba9ea8553b06.png)
### Step 2: Enable custom formatters
![](https://cloud.githubusercontent.com/assets/1303660/18231278/a271ede6-72ad-11e6-8623-367f3e8eb686.png)
## How it works
The code in "/immutable-devtools" is essentially just a copy of `immutable-devtools`.
The two main differences are:
1. We can't use `instanceof Immutable.Record` to detect if an object is a record, since we don't have access to the Immutable module that's loaded on the page. (We only have access to the one loaded in the extension.)
We can still identify Records correctly, but the way we do it means there's a chance that an internal change in how Immutable.JS works could break that.
2. The code can be loaded and unloaded several times on the same page, so we can't rely on variables inside the modules to detect if the formatters have already been injected into the page. Instead I'm setting a `window.__ImmutableJSDevToolsFormattersInstalled` property.Then all that's left to do is to load the code in "devtools.js".
## Running the code locally
1. `npm install`
2. `npm run dev`
3. Load the "/extension" directory as an unpacked Chrome extension
4. Open "/test-page/index.html" to check everything looks as expectedMake sure to reload the extension after any changes.