{"_id":"0xdiff","_rev":"1-176a5a324af5dfe73c914109d15b25cf","name":"0xdiff","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"0xdiff","version":"1.0.0","description":"Converts bin file to diffable text and starts `code --diff`","main":"index.mjs","type":"module","bin":{"0xdiff":"index.mjs"},"engines":{"node":">=18.17.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/1two3code/0xdiff.git"},"keywords":[],"author":"","license":"MIT","bugs":{"url":"https://github.com/1two3code/0xdiff/issues"},"homepage":"https://github.com/1two3code/0xdiff#readme","gitHead":"fc10c108ed433df652a1083f4c3364d197ce1882","_id":"0xdiff@1.0.0","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-dHWkPv6WFoqSU+N1RZZIMGnJJYfheswKcrvBD/NYANQnOngMqmGBI2SrO3FckH8mZnpy98UuHtFTaYoShYO62w==","shasum":"2255a5e9792d6117b82308d1e9813fcfa1053f46","tarball":"https://registry.npmjs.org/0xdiff/-/0xdiff-1.0.0.tgz","fileCount":4,"unpackedSize":8411,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIG3gYV5Qv15e2z1ZlFslsB8fSlOVafxktfI5msRSAmDfAiEAy/wGCgYW2aGN8AMpbqIhWBLPwVbwtulxxl0Ou6KSiJU="}]},"_npmUser":{"name":"1two3code","email":"hasse.lofgren@outlook.com"},"directories":{},"maintainers":[{"name":"1two3code","email":"hasse.lofgren@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/0xdiff_1.0.0_1694187432258_0.4273430824094546"},"_hasShrinkwrap":false},"1.0.1":{"name":"0xdiff","version":"1.0.1","description":"Converts bin file to diffable text and starts `code --diff`","main":"index.mjs","type":"module","bin":{"0xdiff":"index.mjs"},"engines":{"node":">=18.17.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/1two3code/0xdiff.git"},"keywords":[],"author":{"name":"Hans Löfgren"},"license":"MIT","bugs":{"url":"https://github.com/1two3code/0xdiff/issues"},"homepage":"https://github.com/1two3code/0xdiff#readme","gitHead":"328971e64cfb9e7a95abaa655da6f5f6fb4ed9e7","_id":"0xdiff@1.0.1","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-zbMQO5sUrkvaJKFsku8FFFwyxvFkGaoNDQ7USIP/3uDzgn8qoa81y958yPBAE7wz/ba+pdQsR//oNznirpUW5A==","shasum":"82a3b8f452a1e90872a9f184857f352a260482f4","tarball":"https://registry.npmjs.org/0xdiff/-/0xdiff-1.0.1.tgz","fileCount":9,"unpackedSize":541912,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDjovlEf88kyjE5YulD9rayuC1NvWFJrol6RCol/UxM8QIhAPiOfZxXO2XlUxPU+6bmq7IZ8t03uRSOeW4YOG0AAPL8"}]},"_npmUser":{"name":"1two3code","email":"hasse.lofgren@outlook.com"},"directories":{},"maintainers":[{"name":"1two3code","email":"hasse.lofgren@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/0xdiff_1.0.1_1694201929542_0.09672037175755421"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-08T15:37:12.106Z","1.0.0":"2023-09-08T15:37:12.453Z","modified":"2023-09-08T19:38:49.945Z","1.0.1":"2023-09-08T19:38:49.777Z"},"maintainers":[{"name":"1two3code","email":"hasse.lofgren@outlook.com"}],"description":"Converts bin file to diffable text and starts `code --diff`","homepage":"https://github.com/1two3code/0xdiff#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/1two3code/0xdiff.git"},"bugs":{"url":"https://github.com/1two3code/0xdiff/issues"},"license":"MIT","readme":"# 0xdiff [(npmjs 🔗)](https://www.npmjs.com/package/0xdiff)\n\nZero dependency CLI tool to diff binary files. \n\n## Requirements\n- shell (WSL2 on Windows)\n- node >= 18.17.1\n- vscode\n\n## Install\n`npm i -g 0xdiff`\n\n## Usage\n```\n0xdiff 1.0.1\nConverts bin file to diffable text and starts `code --diff`\n\nUsage: 0xdiff [options] <file> <file>\n\nOptions\n  -b --bytes-per-row <bytes>                        [1, 2, 4, (8), 16, 32, 64].\n  -s --max-size <size>                              MB max file size for compare(1).\n  -k --keep                                         Do not discard temp files on exit.\n  -d --debug <Double|Float|(Big)(U)Int(16|32|64)>   Displays value for each hex row.\n  -e --endianness <l | little | b | big>            Only used with -d (little)\n  -h --help                                         Display this help text.\n```\n\n\n## Git Diff\nThe cli tool does not feature git diffs natively at this point.  \nYou can utilize the `git cat-file` command to achieve this for now.\n```bash\ngit cat-file -p <SHA>:<FILE> > <FILE>.tmp \\\n&& 0xdiff <FILE>.tmp <FILE> \\\n&& rm <FILE>.tmp\n```\n\nAppend it as a shell function in your .bashrc:\n```bash\ngitxdiff() {\n  sha=\"${@: -2:1}\"\n  file=\"${@: -1}\"\n  opts=\"${@:1:$#-2}\" \n  git cat-file -p $sha:$file > $file.tmp \\\n  && 0xdiff $opts $file.tmp $file \\\n  && rm $file.tmp\n}\n```\n\n### Demo\nGit diff between checked in file and local changes:\n#### `gitxdiff HEAD README.md`\n![](docs/gitxdiff.png)\n\n## Options\n\n### --bytes-per-row\nUse this option to change how to diff your binary data.\n\n#### `--bytes-per-row 4`\n![](docs/bytes-per-row_4.png)\n\n#### `--bytes-per-row 16`\n![](docs/bytes-per-row_16.png)\n\n### --max-size\n**OBS❗**  \nThis application was developed with _small_ binary files in mind, which is why\nthe hacky solution of using the text diff tool works.  \nConverting binary files to utf-8 text files like this effectively makes them **300%**\nlarger in size.\nDoing `diff` on large files consumes a lot of processing and memory resources,\nspecially if there are  also many changes which is often the case with binary files.\n\nThe `--max-size` is an override to the 1MB precautionary max size.\n\nYou can increase the amount of time that vscode will compute the diff with the\nfollowing vscode setting:\n```jsonc\n{\n  // Timeout in milliseconds after which diff computation is cancelled. Use 0 for no timeout.\n  \"diffEditor.maxComputationTime\": 5000\n}\n```\n\n### --debug\nIf you want to debug the value of each row.  \nNote that the `bit` of the chosen debug format can not be greater than the bits\nrepresented on each row, as set with the `--bytes-per-row` option, see table.\n\n| format    |   -b |\n| --------- | ---: |\n| BigInt64  |    8 |\n| BigUInt64 |    8 |\n| Double    |    8 |\n| Float     |    4 |\n| Int16     |    2 |\n| Int32     |    4 |\n| UInt16    |    2 |\n| UInt32    |    4 |\n\n#### --debug Float\n![](docs/debug_Float.png)\n\n#### --debug Int16\n![](docs/debug_Int16.png)\n\n### --endianness\nThis option is only used with the `--debug` option.  \nIf you are working with binary files you probably know what to do with this option.\n\n### --keep\nStop `0xdiff` from removing the temporary files when exiting.  \nPlease note that this option will leave dangling files in your OS temp directory.\n","readmeFilename":"README.md","author":{"name":"Hans Löfgren"}}