GithubHelp home page GithubHelp logo

murmurhash-js's Introduction

MurmurHash.js

An optimized JavaScript implementation of the MurmurHash algorithms.

These algorithms take a JavaScript string (and a seed), and quickly create a non-cryptographic 32-bit hash from it. And by quick I mean sub-millisecond performance.

More information about these algorithms can be found at:

License (MIT)

Copyright (c) 2011 Gary Court

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

murmurhash-js's People

Contributors

garycourt avatar timdumol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

murmurhash-js's Issues

Put on npm?

I'm a big fan of this implementation of murmurhash, and would love to use it as an NPM module. What do you think about publishing it to npm?

Is the seed mandatory?

The doc says:

seed Positive integer only

but it seems to work without a seed.

murmurhash3_32_gc('test'); // output 3127628307
murmurhash3_32_gc('test', undefined); // output 3127628307

is this supported?

I am surprised even libs which based on your work do this: https://www.npmjs.com/package/murmurhash

Uncaught (in promise) TypeError: r is not a function

Uncaught (in promise) TypeError: r is not a function

seems like there might be a bug here in the compiled code... looks to be in the "var maxmind_function " function?

var a, c = function() {
var e, t;
try {
t = (e = document.createElement("canvas")).getContext("2d")
} catch (e) {}
return t ? (t.fillStyle = "red",
t.fillRect(30, 10, 200, 100),
t.strokeStyle = "#1a3bc1",
t.lineWidth = 6,
t.lineCap = "round",
t.arc(50, 50, 20, 0, Math.PI, !1),
t.stroke(),
t.fillStyle = "#42e1a2",
t.font = "15.4px 'Arial'",
t.textBaseline = "alphabetic",
t.fillText("PR flacks quiz gym: TV DJ box when? ☠", 15, 60),
t.shadowOffsetX = 1,
t.shadowOffsetY = 2,
t.shadowColor = "white",
t.fillStyle = "rgba(0, 0, 200, 0.5)",
t.font = "60px 'Not a real font'",
t.fillText("No骗", 40, 80),
r(e.toDataURL())) : null
}

Murmurhash doesn't equal known murmurhashes.

Environment

System: Windows 10, 64 bit.
Nodejs Version: 10.23.2

Steps to Reproduce

// add at the end of murmurhash2_gc.js
module.exports.murmurhash2_32_gc = murmurhash2_32_gc;

// add at the end of murmurhash3_gc.js
module.exports.murmurhash3_32_gc = murmurhash3_32_gc;

// then run the following code
var mmh2 = require('./murmurhash2_gc.js')

mmh2.murmurhash2_32_gc('foo')
// prints 2414502773

var mmh3 = require('./murmurhash3_gc.js')

mmh3.murmurhash3_32_gc('foo');
// prints 4138058784

Expected

One of those outputs needs to be equal to -156908512 which is the known murmurhash for foo

npm

I posted this library to npm so that it would be easier to install and use within node.js and projects that use CommonJS for modules. Here is the link:

https://npmjs.org/package/murmurhash-js

If you have an account I can transfer ownership of the package to you, or I can take care of maintenance myself if you like.

Need to upgrade to ES6 standards

Hi @garycourt @TimDumol

As i was screening the code, found that the JS standards used in the code is not updated , so i wish to raise a PR for JS up-gradation but as of now i don't have the necessary rights to raise a pull request.

Thanks in advance

Regards,
Piyush Biswal

Unicode & Python implementation

I'm wondering how to get the same hash for a unicode string in my browser using this function vs. using the same function in Python https://pypi.org/project/murmurhash/ (where it operates either on unicode or bytes).

> murmurhash3_32_gc('a', 1)
< 1485495528
> murmurhash3_32_gc('Җ', 1)
< 4216681732

Python:

>>> murmurhash.hash('a', 1)
1485495528
>>> murmurhash.hash_bytes('a'.encode('utf8'), 1)
1485495528
>>> murmurhash.hash_bytes('a'.encode('utf16'), 1)
-1631321036
>>> murmurhash.hash('Җ', 1)
-1621654532
>>> murmurhash.hash_bytes('Җ'.encode('utf8'), 1)
-1621654532
>>> murmurhash.hash_bytes('Җ'.encode('utf16'), 1)
1377606248

I'm wondering which implementation is correct, or if there's anything I need to do to either to get the output to match up?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.