{"name":"ohash","version":"1.1.4","description":"Super fast hashing library based on murmurhash3 written in Vanilla JS","repository":{"type":"git","url":"git+https://github.com/unjs/ohash.git"},"license":"MIT","sideEffects":false,"type":"module","exports":{".":{"import":"./dist/index.mjs","types":"./dist/index.d.ts","require":"./dist/index.cjs"}},"main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","devDependencies":{"@types/node":"^22.5.5","@vitest/coverage-v8":"^2.1.1","benchmark":"^2.1.4","changelogen":"^0.5.5","eslint":"^9.10.0","eslint-config-unjs":"^0.3.2","prettier":"^3.3.3","typescript":"^5.6.2","unbuild":"^2.0.0","vitest":"^2.1.1"},"scripts":{"build":"unbuild","dev":"vitest dev","lint":"eslint . && prettier -c src test","lint:fix":"eslint --fix . && prettier -w src test","release":"pnpm test && changelogen --release --push && pnpm publish","benchmark":"node benchmark/object-hash.mjs","test":"pnpm lint && vitest run && pnpm typecheck","typecheck":"tsc --noEmit"},"_id":"ohash@1.1.4","bugs":{"url":"https://github.com/unjs/ohash/issues"},"homepage":"https://github.com/unjs/ohash#readme","_integrity":"sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==","_resolved":"/private/var/folders/hf/lrc_fvsd0qv7rd6q57mkqp180000gn/T/81df5161de53f845fb101a70d4402733/ohash-1.1.4.tgz","_from":"file:ohash-1.1.4.tgz","_nodeVersion":"20.17.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-FlDryZAahJmEF3VR3w1KogSEdWX3WhA5GPakFx4J81kEAiHyLMpdLLElS8n8dfNadMgAne/MywcvmogzscVt4g==","shasum":"ae8d83014ab81157d2c285abf7792e2995fadd72","tarball":"http://registry-npm.ywwl.com/ohash/download/ohash-1.1.4.tgz","fileCount":8,"unpackedSize":64769,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAOZVfal2HpSfw1TTATJisJ4Z/sD2PJTXeheCgtl/BPuAiBgwcZ/WDxEqBZ+tBReP4HClmSMuS74B/vdJ880XqzdVw=="}],"size":16948,"noattachment":false,"key":"/ohash/-/ohash-1.1.4.tgz"},"_npmUser":{"name":"pi0","email":"pyapar@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ohash_1.1.4_1726427905160_0.17548638251426407"},"_hasShrinkwrap":false,"readme":"# ohash\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Github Actions][github-actions-src]][github-actions-href]\n[![Codecov][codecov-src]][codecov-href]\n[![bundle size][bundle-src]][bundle-href]\n\n> Super fast hashing library written in Vanilla JS\n\n## Usage\n\nInstall package:\n\n```sh\n# npm\nnpm install ohash\n\n# yarn\nyarn add ohash\n\n# pnpm\npnpm install ohash\n```\n\nImport:\n\n```js\n// ESM\nimport { hash, objectHash, murmurHash, sha256 } from \"ohash\";\n\n// CommonJS\nconst { hash, objectHash, murmurHash, sha256 } = require(\"ohash\");\n```\n\n### `hash(object, options?)`\n\nConverts object value into a string hash using `objectHash` and then applies `sha256` with Base64 encoding (trimmed by length of 10).\n\nUsage:\n\n```js\nimport { hash } from \"ohash\";\n\n// \"dZbtA7f0lK\"\nconsole.log(hash({ foo: \"bar\" }));\n```\n\n### `objectHash(object, options?)`\n\nConverts a nest object value into a stable and safe string for hashing.\n\nUsage:\n\n```js\nimport { objectHash } from \"ohash\";\n\n// \"object:1:string:3:foo:string:3:bar,\"\nconsole.log(objectHash({ foo: \"bar\" }));\n```\n\n### `isEqual(obj1, obj2, options?)`\n\nCompare two objects using reference equality and stable object hashing.\n\nUsage:\n\n```js\nimport { isEqual } from \"ohash\";\n\n// true\nconsole.log(isEqual({ a: 1, b: 2 }, { b: 2, a: 1 }));\n```\n\n### `diff(obj1, obj2, options?)`\n\nCompare two objects with nested hashing. Returns an array of changes.\n\nReturned value is an array of diff entries with `$key`, `$hash`, `$value` and `$props`. When logging, a string version of changelog is displayed.\n\nUsage:\n\n```js\nimport { diff } from \"ohash\";\n\nconst createObject = () => ({\n  foo: \"bar\",\n  nested: {\n    y: 123,\n    bar: {\n      baz: \"123\",\n    },\n  },\n});\n\nconst obj1 = createObject();\nconst obj2 = createObject();\n\nobj2.nested.x = 123;\ndelete obj2.nested.y;\nobj2.nested.bar.baz = 123;\n\nconst diff = diff(obj1, obj2);\n\n// [-] Removed nested.y\n// [~] Changed nested.bar.baz from \"123\" to 123\n// [+] Added   nested.x\nconsole.log(diff(obj1, obj2));\n```\n\n### `murmurHash(str)`\n\nConverts input string (of any length) into a 32-bit positive integer using [MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash).\n\nUsage:\n\n```js\nimport { murmurHash } from \"ohash\";\n\n// \"427197390\"\nconsole.log(murmurHash(\"Hello World\"));\n```\n\n### `sha256`\n\nCreate a secure [SHA 256](https://en.wikipedia.org/wiki/SHA-2) digest from input string.\n\n```js\nimport { sha256 } from \"ohash\";\n\n// \"a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e\"\nconsole.log(sha256(\"Hello World\"));\n```\n\n### `sha256base64`\n\nCreate a secure [SHA 256](https://en.wikipedia.org/wiki/SHA-2) digest in Base64 encoding from input string.\n\n```js\nimport { sha256base64 } from \"ohash\";\n\n// \"pZGm1Av0IEBKARczz7exkNYsZb8LzaMrV7J32a2fFG4\"\nconsole.log(sha256base64(\"Hello World\"));\n```\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)\n- Install dependencies using `pnpm install`\n- Run interactive tests using `pnpm dev`\n\n## License\n\nMade with 💛\n\nPublished under [MIT License](./LICENSE).\n\nBased on [puleos/object-hash](https://github.com/puleos/object-hash) by [Scott Puleo](https://github.com/puleos/), and implementations from [perezd/node-murmurhash](https://github.com/perezd/node-murmurhash) and\n[garycourt/murmurhash-js](https://github.com/garycourt/murmurhash-js) by [Gary Court](mailto:gary.court@gmail.com) and [Austin Appleby](mailto:aappleby@gmail.com) and [brix/crypto-js](https://github.com/brix/crypto-js).\n\n<!-- Badges -->\n\n[npm-version-src]: https://img.shields.io/npm/v/ohash?style=flat-square\n[npm-version-href]: https://npmjs.com/package/ohash\n[npm-downloads-src]: https://img.shields.io/npm/dm/ohash?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/ohash\n[github-actions-src]: https://img.shields.io/github/actions/workflow/status/unjs/ohash/ci.yml?branch=main&style=flat-square\n[github-actions-href]: https://github.com/unjs/ohash/actions?query=workflow%3Aci\n[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/ohash/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/unjs/ohash\n[bundle-src]: https://flat.badgen.net/bundlephobia/minzip/ohash\n[bundle-href]: https://bundlephobia.com/package/ohash\n","publish_time":1726427905362,"maintainers":[{"name":"pi0","email":"pyapar@gmail.com"}],"_cnpm_publish_time":1726427905362,"dist-tags":{"1x":"1.1.6","latest":"2.0.12"}}