1.1.1 • Published 7 years ago
js-ast-hash v1.1.1
js-ast-hash 
Output hash value of JavaScript AST. This tool help to compare source codes ignoring space and comment.
This tool is inspired by following article.
Features
- Output JavaScript AST hash(md5) value
- Ignore space, break line, and comment of the source code
Ignore comments example:
/* comment A */ var a = 1;// a===
/* comment B */ var a = 1; // bIgnore spaces example:
var fn = function(){}===
var fn = function (){
};Install
Install with npm:
npm install js-ast-hashUsage
Usage
$ js-ast-hash file.js ["src/**/*.js"]
Options
--format -f output format: json, csv (default: csv)
Examples
$ js-ast-hash file.js
$ js-ast-hash "src/**/*.js" -f jsonExample
example1.js:
// this is example 1
var a = 1;example2.js:
// this is example 2
var b = 1;example3.js:
// this is example 3
var a = 1 // code is same with example1CSV results:
$ js-ast-hash test/fixtures/example.js
"filePath","hash"
"test/fixtures/example1.js","3a5c739d9c4b6284c5790de8b557bd3d"
"test/fixtures/example2.js","da948b06f3c073a32dc6de72e00dbe8f"
"test/fixtures/example3.js","3a5c739d9c4b6284c5790de8b557bd3d"JSON results:
$ js-ast-hash test/fixtures/ -f json
[{"filePath":"test/fixtures/example1.js","hash":"3a5c739d9c4b6284c5790de8b557bd3d"},{"filePath":"test/fixtures/example2.js","hash":"da948b06f3c073a32dc6de72e00dbe8f"},{"filePath":"test/fixtures/example3.js","hash":"3a5c739d9c4b6284c5790de8b557bd3d"},]example1.js and example3.js should be same hash value.
Changelog
See Releases page.
Running tests
Install devDependencies and Run npm test:
npm i -d && npm testContributing
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request :D
Author
License
MIT © azu