Licence
MIT
Version
1.0.3
Deps
8
Size
3 kB
Vulns
0
Weekly
0
@resolve-es/valueof
Returns x.valueOf() if x.valueOf exists, otherwise returns x.
Installation
npm install @resolve-es/valueof
Usage
const valueOf = require("@resolve-es/valueof")
const str = new String("Wow!")
console.log(typeof valueOf(str)) // "string"
// Handling primitives
console.log(valueOf(42)) // 42
// Complex objects without valueOf
console.log(valueOf({ name: "John Doe" })) // { name: 'John Doe' }