Last active
March 28, 2017 10:04
-
-
Save burdiuz/7664491eed84695250e46be20670be84 to your computer and use it in GitHub Desktop.
SymbolImpl simple fallback for environments that don't have Symbol type
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
{ | |
"name": "SymbolImpl", | |
"description": "SymbolImpl simple fallback for environments that don't have Symbol type", | |
"version": "0.0.2", | |
"main": "SymbolImpl.js", | |
"dependencies": { | |
} | |
} |
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
'use strict'; | |
let SymbolImpl; | |
if (typeof(Symbol) === 'undefined') { | |
SymbolImpl = (value) => { | |
const salt = Math.random(); | |
const symbol = () => `@@${value}:${salt}`; | |
symbol.toString = symbol; | |
symbol.valueOf = symbol; | |
return symbol; | |
}; | |
} else { | |
SymbolImpl = Symbol; | |
} | |
export default SymbolImpl; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment