Comments (3)
How to detect Immutable objects?
Under the hood this is possible because of special properties on prototype called sentinels:
@@__IMMUTABLE_INDEXED__@@
@@__IMMUTABLE_ITERABLE__@@
@@__IMMUTABLE_KEYED__@@
@@__IMMUTABLE_LIST__@@
@@__IMMUTABLE_MAP__@@
@@__IMMUTABLE_ORDERED__@@
@@__IMMUTABLE_SEQ__@@
@@__IMMUTABLE_SET__@@
@@__IMMUTABLE_STACK__@@
from immutable-devtools.
From what I've found the only change that needs to be made is replacing instanceOf Immutable.Record
. Everything else already uses the sentinels under the hood, so you can include the Immutable library in the bookmarklet, rather than depending on the one on the page.
It's not pure, but using record._defaultValues !== undefined
to detect Records worked for me.
from immutable-devtools.
@mattzeunert Actually, Record can be detected in this way:
const isRecord = o => !!(
o['@@__IMMUTABLE_KEYED__@@'] &&
o['@@__IMMUTABLE_ITERABLE__@@'] &&
o._defaultValues);
from immutable-devtools.
Related Issues (20)
- 'install' is undefined, function name appears to have been removed by uglification HOT 3
- installDevTools is not a function HOT 3
- How to simulate 'if debug' without changing source code (using gulp&webpack) HOT 6
- Can this be an extension ? HOT 5
- installDevTools(immutable) returns undefined. HOT 1
- Failing on Chrome Canary builds HOT 12
- Implement support for Range
- Implement support for Repeat
- Implement support for Seq HOT 4
- Opera Support HOT 1
- Any plan to work in React Native? HOT 5
- Chrome >=48.0 required HOT 6
- Add note to enable custom formatters in docs
- Breaks with Immutable v4 HOT 2
- Not working with DevTools (server side) HOT 3
- Not working in chrome 69 HOT 1
- Typo in renderIterableBody?
- The string "null" is formatted as null
- Cannot show Record with an undefined property HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from immutable-devtools.