Skip to content

Commit

Permalink
Remove object hash (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
Exelord authored Feb 5, 2018
1 parent 8db20e7 commit caf36b8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 40 deletions.
14 changes: 12 additions & 2 deletions addon/utils/hash.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import objectHash from 'object-hash';
import md5 from 'md5';

export default function hash(object = {}) {
return objectHash(object);
return md5(serialize(object));
}

function serialize(obj) {
if (Array.isArray(obj)) {
return JSON.stringify(obj.map(i => serialize(i)))
} else if (typeof obj === 'object' && obj !== null) {
return Object.keys(obj).sort().map(k => `${k}:${serialize(obj[k])}`).join('|')
}

return obj
}
12 changes: 0 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,12 @@ module.exports = {

app.import('vendor/ember-initials/md5.js');
app.import('vendor/shims/md5.js', { type: 'vendor' });

app.import('vendor/ember-initials/object_hash.js');
app.import('vendor/shims/object-hash.js', { type: 'vendor' });
},

md5Path() {
return path.join(this.app.project.nodeModulesPath, 'blueimp-md5', 'js');
},

objectHashPath() {
return path.join(this.app.project.nodeModulesPath, 'object-hash', 'dist');
},

treeForVendor(tree) {
let trees = [tree];

Expand All @@ -33,11 +26,6 @@ module.exports = {
files: ['md5.js']
}));

trees.push(new Funnel(this.objectHashPath(), {
destDir: 'ember-initials',
files: ['object_hash.js']
}));

return mergeTrees(trees);
}
}
7 changes: 1 addition & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,10 @@
"blueimp-md5": "2.10.0",
"broccoli-funnel": "2.0.1",
"broccoli-merge-trees": "2.0.0",
"ember-cli-babel": "6.11.0",
"object-hash": "1.2.0"
"ember-cli-babel": "6.11.0"
},
"fastbootDependencies": [
"blueimp-md5",
"object-hash"
"blueimp-md5"
],
"ember-addon": {
"configPath": "tests/dummy/config",
Expand Down
16 changes: 0 additions & 16 deletions vendor/shims/object-hash.js

This file was deleted.

0 comments on commit caf36b8

Please sign in to comment.