GoogleChromeLabs / react-adaptive-hooks

Deliver experiences best suited to a user's device and network constraints
Apache License 2.0
5.1k stars 113 forks source link

Human readable usage #38

Closed wingleung closed 4 years ago

wingleung commented 4 years ago

For jsHeapSizeLimit, totalJSHeapSize, usedJSHeapSize it could be nice to have a human readable property like deviceMemory is somewhat of a human readable property (in gigabytes). We could add a human readable property alongside machine value.

{
    supported: true,
    deviceMemory: 8,
    jsHeapSizeLimit: 4345298944
    jsHeapSizeLimit-human: "4.05 G",
    totalJSHeapSize: 47665242, 
    totalJSHeapSize-human:"45.46 MB",
    usedJSHeapSize: 38501994, 
    usedJSHeapSize-human: "36.72 MB",
}
strayiker commented 4 years ago

This can be done with comments

{
    supported: true,
    deviceMemory: 8,
    jsHeapSizeLimit: 4345298944, // 4.05 G
    totalJSHeapSize: 47665242, // 45.46 MB
    usedJSHeapSize: 38501994, // 36.72 MB
}