Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More →
Socket
Sign inDemoInstall
Socket

ohash

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ohash - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

22

dist/index.d.ts

@@ -1,10 +0,1 @@

/**
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
*
* @param {Uint8Array | string} key ASCII only
* @param {number} seed Positive integer only
* @return {number} 32-bit positive integer hash
*/
declare function murmurHash(key: Uint8Array | string, seed?: number): number;
interface HashOptions {

@@ -70,2 +61,13 @@ /**

export { HashOptions, hash, murmurHash, objectHash };
/**
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
*
* @param {Uint8Array | string} key ASCII only
* @param {number} seed Positive integer only
* @return {number} 32-bit positive integer hash
*/
declare function murmurHash(key: Uint8Array | string, seed?: number): number;
declare function sha256(message: string): any;
export { hash, murmurHash, objectHash, sha256 };
{
"name": "ohash",
"version": "0.1.0",
"version": "0.1.2",
"description": "Super fast hashing library based on murmurhash3 written in Vanilla JS",

@@ -21,5 +21,13 @@ "repository": "unjs/ohash",

],
"dependencies": {},
"scripts": {
"build": "unbuild",
"dev": "vitest dev",
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
"prepack": "unbuild",
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
"test": "pnpm lint && vitest run"
},
"devDependencies": {
"@nuxtjs/eslint-config-typescript": "latest",
"@types/node": "^18.0.4",
"c8": "latest",

@@ -32,11 +40,3 @@ "eslint": "latest",

},
"packageManager": "pnpm@6.32.2",
"scripts": {
"build": "unbuild",
"dev": "vitest dev",
"lint": "eslint --ext .ts,.js,.mjs,.cjs .",
"release": "pnpm test && standard-version && git push --follow-tags && pnpm publish",
"test": "pnpm lint && vitest run"
},
"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\n> Super fast hashing library based on murmurhash3 written in Vanilla JS\n\n## Usage\n\nInstall package:\n\n```sh\n# npm\nnpm install ohash\n\n# yarn\nyarn install ohash\n\n# pnpm\npnpm install ohash\n```\n\nImport:\n\n```js\n// ESM\nimport { hash, objectHash, murmurHash } from 'ohash'\n\n// CommonJS\nconst { hash, objectHash, murmurHash } = require('ohash')\n```\n\n### `hash(object, options?)`\n\nConverts object value into a string hash using `objectHash` and then applies `murmurHash`.\n\nUsage:\n\n```js\nimport { hash } from 'ohash'\n\n// \"2736179692\"\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### `murmurHash(str)`\n\nConverts input string (of any length) into a 32-bit positive integer using MurmurHash3.\n\nUsage:\n\n```js\nimport { murmurHash } from 'ohash'\n\n// \"2708020327\"\nconsole.log(murmurHash('Hello World'))\n```\n\n## What is MurmurHash\n\n[MurmurHash](https://en.wikipedia.org/wiki/MurmurHash) is a non-cryptographic hash function created by Austin Appleby.\n\nAccording to [murmurhash website](https://sites.google.com/site/murmurhash):\n\n✅ Extremely simple - compiles down to ~52 instructions on x86.\n\n✅ Excellent distribution - Passes chi-squared tests for practically all keysets & bucket sizes.\n\n✅ Excellent avalanche behavior - Maximum bias is under 0.5%.\n\n✅ Excellent collision resistance - Passes Bob Jenkin's frog.c torture-test. No collisions possible for 4-byte keys, no small (1- to 7-bit) differentials.\n\n✅ Excellent performance\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](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).\n\n<!-- Badges -->\n[npm-version-src]: https://img.shields.io/npm/v/ohash?style=flat-square\n[npm-version-href]: https://npmjs.com/package/ohash\n\n[npm-downloads-src]: https://img.shields.io/npm/dm/ohash?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/ohash\n\n[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/ohash/ci/main?style=flat-square\n[github-actions-href]: https://github.com/unjs/ohash/actions?query=workflow%3Aci\n\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"
}
"packageManager": "pnpm@7.5.2"
}

@@ -7,4 +7,5 @@ # ohash

[![Codecov][codecov-src]][codecov-href]
[![bundle size][bundle-src]][bundle-href]
> Super fast hashing library based on murmurhash3 written in Vanilla JS
> Super fast hashing library written in Vanilla JS

@@ -20,3 +21,3 @@ ## Usage

# yarn
yarn install ohash
yarn add ohash

@@ -31,6 +32,6 @@ # pnpm

// ESM
import { hash, objectHash, murmurHash } from 'ohash'
import { hash, objectHash, murmurHash, sha256 } from 'ohash'
// CommonJS
const { hash, objectHash, murmurHash } = require('ohash')
const { hash, objectHash, murmurHash, sha256 } = require('ohash')
```

@@ -40,3 +41,3 @@

Converts object value into a string hash using `objectHash` and then applies `murmurHash`.
Converts object value into a string hash using `objectHash` and then applies `sha256` (trimmed by length of 10).

@@ -48,3 +49,3 @@ Usage:

// "2736179692"
// "7596ed03b7"
console.log(hash({ foo: 'bar'}))

@@ -68,3 +69,3 @@ ```

Converts input string (of any length) into a 32-bit positive integer using MurmurHash3.
Converts input string (of any length) into a 32-bit positive integer using [MurmurHash3]((https://en.wikipedia.org/wiki/MurmurHash)).

@@ -80,18 +81,13 @@ Usage:

## What is MurmurHash
### `sha256`
[MurmurHash](https://en.wikipedia.org/wiki/MurmurHash) is a non-cryptographic hash function created by Austin Appleby.
Create a secure [SHA 256](https://en.wikipedia.org/wiki/SHA-2) digest from input string.
According to [murmurhash website](https://sites.google.com/site/murmurhash):
```js
import { sha256 } from 'ohash'
✅ Extremely simple - compiles down to ~52 instructions on x86.
// "a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e"
console.log(sha256('Hello World'))
```
✅ Excellent distribution - Passes chi-squared tests for practically all keysets & bucket sizes.
✅ Excellent avalanche behavior - Maximum bias is under 0.5%.
✅ Excellent collision resistance - Passes Bob Jenkin's frog.c torture-test. No collisions possible for 4-byte keys, no small (1- to 7-bit) differentials.
✅ Excellent performance
## 💻 Development

@@ -111,3 +107,3 @@

Based on [puleos/object-hash](https://github.com/puleos/object-hash) by [Scott Puleo](https://github.com/puleos/), and implementations from [perezd/node-murmurhash](perezd/node-murmurhash) and
[garycourt/murmurhash-js](https://github.com/garycourt/murmurhash-js) by [Gary Court](mailto:gary.court@gmail.com) and [Austin Appleby](mailto:aappleby@gmail.com).
[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).

@@ -126,1 +122,4 @@ <!-- Badges -->

[codecov-href]: https://codecov.io/gh/unjs/ohash
[bundle-src]: https://flat.badgen.net/bundlephobia/minzip/ohash
[bundle-href]: https://bundlephobia.com/package/ohash

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc