From e93ec33cf24cc33cac095e0e1528730eed01d93b Mon Sep 17 00:00:00 2001 From: "ZIVL (Ziv Levy)" Date: Tue, 13 Oct 2015 11:44:31 +0300 Subject: [PATCH] use Symbol to create unique keys In case where multiple classes are using the same String keys, there is no way to distinct between one an other. With JavaScript Symbol mechanism it is possible and it is still easy to debug --- index.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 7f657b9..27e8e6b 100644 --- a/index.js +++ b/index.js @@ -43,7 +43,7 @@ var keyMirror = function(obj) { } for (key in obj) { if (obj.hasOwnProperty(key)) { - ret[key] = key; + ret[key] = Symbol(key); } } return ret; diff --git a/package.json b/package.json index 636f39e..dc538b8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "keymirror", - "version": "0.1.1", + "version": "0.1.2", "description": "A simple utility for creating an object with values equal to its keys. Identical to react/lib/keyMirror", "main": "index.js", "author": "Samuel Reed (http://strml.net/)",