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

@multiformats/murmur3

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@multiformats/murmur3 - npm Package Compare versions

Comparing version 0.0.10 to 1.0.0

0

37

cjs/index.js
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var hasher = require('multiformats/hashes/hasher');
var multiformats = require('multiformats');
var mur = require('murmurhash3js-revisited');

@@ -9,25 +13,22 @@

const fromNumberTo32BitBuf = number => {
function fromNumberTo32BitBuf(number) {
const bytes = new Array(4);
for (let i = 0; i < 4; i++) {
bytes[i] = number & 0xff;
bytes[i] = number & 255;
number = number >> 8;
}
return new Uint8Array(bytes);
};
const create = multiformats => {
const {bytes} = multiformats;
const {fromHex} = bytes;
const hashes = [{
name: 'murmur3-128',
code: 0x22,
encode: data => fromHex(mur__default['default'].x64.hash128(data))
}, {
name: 'murmur3-32',
code: 0x23,
encode: data => fromNumberTo32BitBuf(mur__default['default'].x86.hash32(data))
}];
return hashes;
};
}
const murmur332 = hasher.from({
name: 'murmur3-32',
code: 35,
encode: input => fromNumberTo32BitBuf(mur__default['default'].x86.hash32(input))
});
const murmur3128 = hasher.from({
name: 'murmur3-128',
code: 34,
encode: input => multiformats.bytes.fromHex(mur__default['default'].x64.hash128(input))
});
module.exports = create;
exports.murmur3128 = murmur3128;
exports.murmur332 = murmur332;

@@ -0,24 +1,21 @@

import { from } from 'multiformats/hashes/hasher';
import { bytes } from 'multiformats';
import mur from 'murmurhash3js-revisited';
const fromNumberTo32BitBuf = number => {
function fromNumberTo32BitBuf(number) {
const bytes = new Array(4);
for (let i = 0; i < 4; i++) {
bytes[i] = number & 0xff;
bytes[i] = number & 255;
number = number >> 8;
}
return new Uint8Array(bytes);
};
const create = multiformats => {
const {bytes} = multiformats;
const {fromHex} = bytes;
const hashes = [{
name: 'murmur3-128',
code: 0x22,
encode: data => fromHex(mur.x64.hash128(data))
}, {
name: 'murmur3-32',
code: 0x23,
encode: data => fromNumberTo32BitBuf(mur.x86.hash32(data))
}];
return hashes;
};
export default create;
}
export const murmur332 = from({
name: 'murmur3-32',
code: 35,
encode: input => fromNumberTo32BitBuf(mur.x86.hash32(input))
});
export const murmur3128 = from({
name: 'murmur3-128',
code: 34,
encode: input => bytes.fromHex(mur.x64.hash128(input))
});

@@ -1,1 +0,4 @@

{ "type" : "module" }
{
"type": "module",
"browser": {}
}
{
"name": "@multiformats/murmur3",
"version": "0.0.10",
"description": "",
"exports": {
"require": "./cjs/index.js",
"import": "./esm/index.js",
"browser": "./esm/index.js"
},
"version": "1.0.0",
"description": "Multiformats Murmur3 implementations",
"main": "./cjs/index.js",
"scripts": {
"build": "npm_config_yes=true npx ipjs@latest build --tests",
"publish": "npm_config_yes=true npx ipjs@latest publish",
"build": "npm run build:js && npm run build:types",
"build:js": "ipjs build --tests --main && npm run build:copy",
"build:copy": "cp -a tsconfig.json *.js dist/",
"build:types": "npm run build:copy && cd dist && tsc --build",
"publish": "ipjs publish",
"lint": "standard",
"test:cjs": "npm run build && mocha dist/cjs/node-test/test-*.js",
"test:node": "hundreds mocha test/test-*.js",
"test:browser": "polendina --cleanup dist/cjs/browser-test/test-*.js",
"test": "npm run lint && npm run test:node && npm run test:cjs && npm run test:browser",
"coverage": "c8 --reporter=html mocha test/test-*.js && npx st -d coverage -p 8080"
"test:cjs": "npm run build && mocha dist/cjs/node-test/test-*.js && npm run test:cjs:browser",
"test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/test-*.js",
"test:cjs:browser": "polendina --cleanup dist/cjs/browser-test/test-*.js",
"test": "npm run lint && npm run test:node && npm run test:cjs",
"test:node-v12": "mocha test/test-*.js && npm run test:cjs",
"coverage": "c8 --reporter=html mocha test/test-*.js && npm_config_yes=true npx st -d coverage -p 8080"
},
"keywords": [],
"keywords": [
"IPFS",
"IPLD",
"multiformats",
"hash",
"multihash",
"blake2"
],
"author": "Mikeal Rogers <mikeal.rogers@gmail.com> (https://www.mikealrogers.com/)",
"license": "(Apache-2.0 AND MIT)",
"dependencies": {
"murmurhash3js-revisited": "^3.0.0"
"murmurhash3js-revisited": "^3.0.0",
"multiformats": "^9.4.1"
},
"devDependencies": {
"c8": "^7.3.0",
"globby": "^11.0.1",
"hundreds": "0.0.8",
"mocha": "^8.1.1",
"multiformats": "^3.0.3",
"@ipld/dag-cbor": "^6.0.5",
"c8": "^7.7.3",
"chai": "^4.3.4",
"ipjs": "^5.0.2",
"mocha": "^9.0.2",
"polendina": "^1.1.0",
"standard": "^14.3.4"
"standard": "^16.0.3",
"typescript": "^4.3.5"
},
"exports": {
"browser": "./esm/index.js",
"require": "./cjs/index.js",
"import": "./esm/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/multiformats/js-murmur3.git"
},
"typesVersions": {
"*": {
"*": [
"types/*"
],
"types/*": [
"types/*"
]
}
},
"release": {
"branches": [
"master"
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{
"breaking": true,
"release": "major"
},
{
"revert": true,
"release": "patch"
},
{
"type": "feat",
"release": "minor"
},
{
"type": "fix",
"release": "patch"
},
{
"type": "chore",
"release": "patch"
},
{
"type": "docs",
"release": "patch"
},
{
"type": "test",
"release": "patch"
},
{
"scope": "no-release",
"release": false
}
]
}
],
[
"@semantic-release/release-notes-generator",
{
"preset": "conventionalcommits",
"presetConfig": {
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "chore",
"section": "Trivial Changes"
},
{
"type": "docs",
"section": "Trivial Changes"
},
{
"type": "test",
"section": "Tests"
}
]
}
}
],
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"pkgRoot": "dist"
}
],
"@semantic-release/github",
"@semantic-release/git"
]
},
"browser": "./cjs/index.js"
}
}

@@ -1,16 +0,47 @@

# js-murmur3
# @multiformats/murmur3
Multiformats hash functions for MurmurHash3
Murmur3-32 (x86 32-bit) and Murmur3-128 (x64 128-bit) multihash hashers for [multiformats](https://github.com/multiformats/js-multiformats).
`MultihashHashers`s are exported from this library, they produce `MultihashDigest`s. Details about these can be found in the [multiformats multihash interface definitions](https://github.com/multiformats/js-multiformats/blob/master/src/hashes/interface.ts).
```js
import { create } from 'multiformats'
import murmur2 from '@multiformats/murmur3'
import * as Block from 'multiformats/block'
import * as codec from '@ipld/dag-cbor'
import { murmur3128 as hasher } from '@multiformats/murmur3'
const multiformats = create()
const { multihash } = multiformats
multihash.add(murmur3)
const data = new Uint8Array([...someData])
const hash = await multihash.hash(data, 'murmur3-128')
async function run () {
const value = { hello: 'world' }
const block = await Block.encode({ value, hasher, codec })
console.log(block.cid)
// -> CID(bafyseebn7ksk6khsn4an2lzmae6wm4qk)
}
run().catch(console.error)
```
This package contains hashing functions for `murmur3-128` and `murmur3-32`.
## Usage
The `@multiformats/murmur3` package exports `murmur332` and `murmur3128` `MultihashHasher`s. The Multicodecs [table](https://github.com/multiformats/multicodec/blob/master/table.csv) defines these multihashes.
The `murmur3-32`, multicodec code `0x23`, may be imported as:
```js
import { murmur332 } from '@multiformats/murmur3'
```
The `murmur3-128`, multicodec code `0x22`, may be imported as:
```js
import { murmur3128 } from '@multiformats/murmur3'
```
## License
Licensed under either of
* Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / http://www.apache.org/licenses/LICENSE-2.0)
* MIT ([LICENSE-MIT](LICENSE-MIT) / http://opensource.org/licenses/MIT)
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
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