🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

string-hash

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-hash - npm Package Compare versions

Comparing version

to
1.1.3

13

index.js

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

module.exports = function(str) {
"use strict";
function hash(str) {
var hash = 5381,
i = str.length
i = str.length;
while(i)
hash = (hash * 33) ^ str.charCodeAt(--i)
while(i) {
hash = (hash * 33) ^ str.charCodeAt(--i);
}

@@ -13,1 +16,3 @@ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed

}
module.exports = hash;
{
"name": "string-hash",
"version": "1.1.2",
"version": "1.1.3",
"description": "fast string hashing function",

@@ -22,4 +22,7 @@ "license": "CC0-1.0",

"devDependencies": {
"mocha": "1.3.x"
"mocha": "*"
},
"scripts": {
"test": "mocha"
}
}

@@ -0,12 +1,13 @@

"use strict";
var assert = require("assert"),
hash = require("./")
hash = require("./");
describe("hash", function() {
it("should hash \"Mary had a little lamb.\" to 1766333550", function() {
assert.equal(hash("Mary had a little lamb."), 1766333550)
})
assert.equal(hash("Mary had a little lamb."), 1766333550);
});
it("should hash \"Hello, world!\" to 343662184", function() {
assert.equal(hash("Hello, world!"), 343662184)
})
})
assert.equal(hash("Hello, world!"), 343662184);
});
});