Skip to content
This repository was archived by the owner on Feb 7, 2022. It is now read-only.

Commit 07d5c11

Browse files
committed
Merge pull request #17 from kabitakis/master
minor readme addition, changed getLeafKey to use hash instead of plain value
2 parents c961157 + e2ae7e7 commit 07d5c11

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ React.render(
2525
Make sure to include `json-inspector.css` in your stylesheet. Feel free to
2626
override or amend default styles, for instance, when using a dark background.
2727

28+
### Run the example
29+
30+
```bash
31+
cd /path/to/project
32+
npm install
33+
npm run watch
34+
```
35+
36+
Then, visit http://localhost/path/to/project/example
37+
2838
### Properties
2939

3040
#### props.data

lib/leaf.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
var React = require('react');
22
var D = React.DOM;
33

4+
var md5omatic = require('md5-o-matic');
5+
46
var uid = require('./uid');
57
var type = require('./type');
68

@@ -213,7 +215,8 @@ function items(count) {
213215
function getLeafKey(key, value) {
214216
if (isPrimitive(value)) {
215217
// TODO: Sanitize `value` better.
216-
return key + ':' + String(value).replace(/\s+/g, '_');
218+
var hash = md5omatic(String(value));
219+
return key + ':' + hash;
217220
} else {
218221
return key + '[' + type(value) + ']';
219222
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"license": "MIT",
1616
"dependencies": {
1717
"debounce": "1.0.0",
18+
"md5-o-matic": "^0.1.1",
1819
"object-assign": "2.0.0"
1920
},
2021
"devDependencies": {

0 commit comments

Comments
 (0)