Skip to content

Instantly share code, notes, and snippets.

@burdiuz
Last active March 28, 2017 10:04
Show Gist options
  • Save burdiuz/7664491eed84695250e46be20670be84 to your computer and use it in GitHub Desktop.
Save burdiuz/7664491eed84695250e46be20670be84 to your computer and use it in GitHub Desktop.
SymbolImpl simple fallback for environments that don't have Symbol type
{
"name": "SymbolImpl",
"description": "SymbolImpl simple fallback for environments that don't have Symbol type",
"version": "0.0.2",
"main": "SymbolImpl.js",
"dependencies": {
}
}
'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