Last active
January 7, 2016 03:36
-
-
Save artisonian/9609675 to your computer and use it in GitHub Desktop.
Hash it, then compress it!
This file contains hidden or 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'; | |
| var hashpress = require('./hashpress'); | |
| var obj = { | |
| username: 'foo', | |
| likes: ['cats', 'candy'], | |
| quote: "I don't always program JavaScript...but when I do, I use Node.js" | |
| }; | |
| var longString = (new Array(1024*1024)).join('lorem ipsum dolor...'); | |
| console.log('object:\t%s', hashpress(obj)); | |
| console.log('string:\t%s', hashpress(longString)); |
This file contains hidden or 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'; | |
| // Just use [hash-sum](https://github.com/bevacqua/hash-sum) | |
| module.exports = require('hash-sum'); |
This file contains hidden or 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'; | |
| var assert = require('assert'); | |
| var hashpress = require('./hashpress'); | |
| var obj = { | |
| username: 'foo', | |
| likes: ['cats', 'candy'], | |
| quote: "I don't always program JavaScript...but when I do, I use Node.js" | |
| }; | |
| var short = hashpress(obj); | |
| var shortCopy = hashpress(obj); | |
| var longString = (new Array(1024*1024)).join('lorem ipsum dolor...'); | |
| var shortOther = hashpress(longString); | |
| assert.equal(short, shortCopy); | |
| assert.notEqual(short, shortOther); |
This file contains hidden or 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": "hashpress.js", | |
| "description": "Hash a value, then compress it", | |
| "version": "0.1.0", | |
| "dependencies": { | |
| "hash-sum": "^1.0.2" | |
| }, | |
| "scripts": { | |
| "test": "node hashpress.test.js" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment