Output hash value of JavaScript AST.
MIT License
Output hash value of JavaScript AST. This tool help to compare source codes ignoring space and comment.
This tool is inspired by following article.
.ts
and .tsx
)Ignore comments example:
/* comment A */ var a = 1;// a
===
/* comment B */ var a = 1; // b
Ignore spaces example:
var fn = function(){}
===
var fn = function (){
};
Install with npm:
npm install js-ast-hash
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 json
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 example1
CSV 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.
See Releases page.
Install devDependencies and Run npm test
:
npm i -d && npm test
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
MIT azu