{"id":23822242,"url":"https://github.com/liqueurdetoile/blob-compare","last_synced_at":"2025-09-07T04:31:36.475Z","repository":{"id":43757083,"uuid":"207673542","full_name":"liqueurdetoile/blob-compare","owner":"liqueurdetoile","description":"Small library to quickly compare two blobs based on blob attributes and fallback to binary string conversion","archived":false,"fork":false,"pushed_at":"2023-03-14T21:19:42.000Z","size":5134,"stargazers_count":6,"open_issues_count":6,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T02:35:48.557Z","etag":null,"topics":["blob","blobs","comparison","comparison-tool","javascript","magic-numbers"],"latest_commit_sha":null,"homepage":"https://liqueurdetoile.github.io/blob-compare","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/liqueurdetoile.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-10T22:22:02.000Z","updated_at":"2024-08-26T07:57:24.000Z","dependencies_parsed_at":"2023-02-15T08:15:53.478Z","dependency_job_id":null,"html_url":"https://github.com/liqueurdetoile/blob-compare","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/liqueurdetoile/blob-compare","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liqueurdetoile%2Fblob-compare","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liqueurdetoile%2Fblob-compare/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liqueurdetoile%2Fblob-compare/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liqueurdetoile%2Fblob-compare/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/liqueurdetoile","download_url":"https://codeload.github.com/liqueurdetoile/blob-compare/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/liqueurdetoile%2Fblob-compare/sbom","scorecard":{"id":592024,"data":{"date":"2025-08-11","repo":{"name":"github.com/liqueurdetoile/blob-compare","commit":"bee1e23ec9bfc4429dd1ad74cdd4d73c79ca8241"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.3,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/11 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test-suite.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-suite.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/liqueurdetoile/blob-compare/test-suite.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test-suite.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/liqueurdetoile/blob-compare/test-suite.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-suite.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/liqueurdetoile/blob-compare/test-suite.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test-suite.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/liqueurdetoile/blob-compare/test-suite.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/test-suite.yml:25","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v1.1.0 not signed: https://api.github.com/repos/liqueurdetoile/blob-compare/releases/22649773","Warn: release artifact v1.0.1 not signed: https://api.github.com/repos/liqueurdetoile/blob-compare/releases/22647848","Warn: release artifact v1.0.0 not signed: https://api.github.com/repos/liqueurdetoile/blob-compare/releases/19928278","Warn: release artifact v1.1.0 does not have provenance: https://api.github.com/repos/liqueurdetoile/blob-compare/releases/22649773","Warn: release artifact v1.0.1 does not have provenance: https://api.github.com/repos/liqueurdetoile/blob-compare/releases/22647848","Warn: release artifact v1.0.0 does not have provenance: https://api.github.com/repos/liqueurdetoile/blob-compare/releases/19928278"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 20 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"40 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w","Warn: Project is vulnerable to: GHSA-q9mw-68c2-j6m5","Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc","Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-w7rc-rwvf-8q5r","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj","Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq","Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3","Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T22:11:35.193Z","repository_id":43757083,"created_at":"2025-08-20T22:11:35.193Z","updated_at":"2025-08-20T22:11:35.193Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273996588,"owners_count":25204472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blob","blobs","comparison","comparison-tool","javascript","magic-numbers"],"created_at":"2025-01-02T09:16:23.302Z","updated_at":"2025-09-07T04:31:35.976Z","avatar_url":"https://github.com/liqueurdetoile.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![NPM](https://nodei.co/npm/blob-compare.png)](https://nodei.co/npm/blob-compare/)\n\n[![GitHub license](https://img.shields.io/github/license/liqueurdetoile/blob-compare)](https://github.com/liqueurdetoile/blob-compare/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/liqueurdetoile/blob-compare.svg?branch=master)](https://travis-ci.org/liqueurdetoile/blob-compare)\n[![Coverage Status](https://coveralls.io/repos/github/liqueurdetoile/blob-compare/badge.svg?branch=master)](https://coveralls.io/github/liqueurdetoile/blob-compare?branch=master)\n[![Gzip size](http://img.badgesize.io/https://cdn.jsdelivr.net/npm/blob-compare@latest?compression=gzip\u0026style=flat-square)](https://cdn.jsdelivr.net/npm/blob-compare@latest)\n[![Known Vulnerabilities](https://snyk.io/test/github/liqueurdetoile/blob-compare/badge.svg)](https://snyk.io/test/github/liqueurdetoile/blob-compare)\n\n![npm](https://img.shields.io/npm/dm/blob-compare)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n[![Documentation](https://liqueurdetoile.github.io/blob-compare/badge.svg)](https://liqueurdetoile.github.io/blob-compare/)\n[![Greenkeeper badge](https://badges.greenkeeper.io/liqueurdetoile/blob-compare.svg)](https://greenkeeper.io/)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"https://liqueurdetoile.com\" target=\"\\_blank\"\u003e\u003cimg src=\"https://hosting.liqueurdetoile.com/logo_lqdt.png\" alt=\"Liqueur de Toile\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n# Blob comparison utility\n`blob-compare` is a small library designed to provide some useful methods to compare two blobs in browser with various methods :\n\n- Comparison on size of two blobs\n- Comparison on types of two blobs\n- Comparison on data types based on [magic numbers](https://en.wikipedia.org/wiki/List_of_file_signatures) of two blobs\n- Comparison byte to byte on full data or sliced subsets\n- A configurable combination of any of above to evaluate blobs or parts of blobs equality\n\nTool rely on native browsers buffer implementations and will likely work on any modern browser. It have been tested and benchmarked on Chrome, Firefox and Edge.\n\nTo provide better performance, `blob-compare` automatically relies on web workers if available when performing operations on blobs.\n\n## Installation\nYou can install it from `npm` or `yarn` :\n```bash\nnpm install blob-compare\n\nyarn add blob-compare\n```\nThen, simply require/import it to use it :\n\n```javascript\nconst blobCompare = require('blob-compare').default;\n// or\nimport blobCompare from 'blob-compare';\n```\nFor browser direct usage, `blob-compare` can be required as a script from any CDN mirroring NPM or Github, for instance :\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/blob-compare@latest\"\u003e\u003c/script\u003e\n\n\u003cscript src=\"https://unpkg.com/blob-compare@latest\"\u003e\u003c/script\u003e\n\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/liqueurdetoile/blob-compare@latest/dist/index.min.js\"\u003e\u003c/script\u003e\n```\n\nA global `blobCompare` will be automatically set after script was downloaded.\n\n## Quick reference\nSee [documentation](https://liqueurdetoile.github.io/blob-compare/) for a full reference.\n\n### Conversion tools ###\nAll conversions are run asynchronously.\n\nMethod  |  Description\n--|--\n`blobCompare::toArrayBuffer` |  Converts a blob to an ArrayBuffer. it can be optionnally chunked and assigned to a web worker. Conversion is run asynchronously.\n`blobCompare::toBinaryString`  |  Converts a blob to a BinaryString. it can be optionnally chunked and assigned to a web worker. Conversion is run asynchronously.\n\n### Comparison tools ###\nMethod  |  Description | Sync/Async\n--|--|:--:\n`blobCompare::sizeEqual` | Compares size of two blobs | sync\n`blobCompare::typeEqual`  | Compares types of two blobs. Types are not really reliable as they can be tricked when creating a blob |  sync\n`blobCompare::magicNumbersEqual`  | Compares [magic numbers](https://en.wikipedia.org/wiki/List_of_file_signatures) of two blobs. A quick comparison is done, therefore weird data types may not be compared with 100% accuracy. In that case, simply clone repo and override this function to fit your needs | async\n`blobCompare::bytesEqualWithArrayBuffer` | Converts blobs or chunk blobs to ArrayBuffers and performs a byte to byte comparison | async\n`blobCompare::bytesEqualWithBinaryString`  | Converts blobs or chunk blobs to BinaryString and performs a byte to byte comparison | async\n`blobCompare::isEqual`  | The swiss army knife to bundle multiple comparison methods above in one single call | async\n\n## Usage examples\n```javascript\n// assuming img1 and img2 are two blobs vars\n\n/**\n * Fully compare two blobs with default methods configuration\n*/\nblobCompare.isEqual(img1, img2).then(res...)\n\n/**\n * Comparing only file types\n */\nblobCompare.isEqual(img1, img2, {methods: ['magic']}).then(res...)\n// or\nblobCompare.magicNumbersEqual(img1, img2).then(res =\u003e ...)\n\n/**\n *  Compare file types AND the last 100 bytes of blobs\n *  Never find a use case ^^\n*/\nblobCompare.isEqual(img1, img2, {\n  methods: ['bytes'],\n  sizes: [-100]\n}).then(res =\u003e ...)\n\n/**\n * Compare file types OR the last 100 bytes of blobs\n*/\nblobCompare.isEqual(img1, img2, {\n  methods: ['bytes'],\n  sizes: [-100],\n  partial: true\n}).then(res =\u003e ...)\n```\nTo speed up things, `isEqual` with its default configuration checks first if sizes are equal, then types, then magic numbers and finally performs a byte to byte comparison to ensure blobs equality.\n\nAll methods working on bytes comparison are asynchronous, use web workers by default if available and works very well with `async/await` syntax.\n\n## About performance\nTrying to compare blobs can be tricky though the only real pitfall is most likely to run out of memory on the VM. There's not much to do with it except working only on smaller data chunks and use device storage like IndexedDb to buffer the unprocessed chunks.\n\n### Web workers\nAnother caveat is likely to consume device CPU to perform operations on blobs. Web workers can be very helpful in this case. `blob-compare` is enabling web workers by default for two major reasons :\n1. A worker is constructed each time a blob needs to be converted to raw binary data or array buffer. On a multi-threaded system, it allows efficient concurrency\n2. Huge blobs operations won't freeze the main thread\n\nThe cons is that processing will be slower due to the copy operation. A workaround could be to use directly `ArrayBuffers` and the `blobCompare.compareBuffers` method that take advantage of the [transferable interface](https://developer.mozilla.org/en-US/docs/Web/API/Transferable) of an ArrayBuffer.\n\nDisabling web workers can also help prevent memory issues in some cases.\n\n### Benchmarking\n**Repo is quite heavy due to fixtures.** I've tried to implement some automated bechnmarks around karma and benchmark.js but I'm quickly hitting some troubles with larger blobs, event with small blobs on Edge.\n\nI'm not sure that I'm doing right with my benchmarks _Oo_\n\nIf I find some time, I may try on jsPerf.\n\nAnyway, after cloning and installing this repository, you can play with fixtures and benchmarks (they are removed from npm version).\n\nJust bash `npm run bench:all` to run them into Chrome, Firefox and Edge. You can also make ChromeHeadless accessible and use `npm run bench`\n\nLatest results for Chrome, Firefox and Edge are stored in `results.json`\n\n## Documentation\nMethods are fully documented and docs are available on [github pages](https://liqueurdetoile.github.io/blob-compare/).\n\n## Issues and PRs\nAny bugs and issues can be filed on the [github repository](https://github.com/liqueurdetoile/blob-compare/issues).\n\n**You are free and very welcome to fork the project and submit any PR to fix or improve `blob-compare`.**\n\n## Changelog ##\n  - **1.1.0** : Add magic numbers in default comparison methods as type value can be falsy. `blobCompare.isEqual` now returns immediately when a falsy value is encountered or at first successful comparison if partial option is set to `true`\n  - **1.0.1** : Fix package content\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliqueurdetoile%2Fblob-compare","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fliqueurdetoile%2Fblob-compare","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fliqueurdetoile%2Fblob-compare/lists"}