2025/2/8第一次更新

This commit is contained in:
爱吃咸鱼小猫咪
2025-02-08 18:50:38 +08:00
commit d7af560866
26519 changed files with 5046029 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/node_modules
+22
View File
@@ -0,0 +1,22 @@
string-hash
===========
A fast string hashing function for Node.JS. The particular algorithm is quite
similar to `djb2`, by Dan Bernstein and available
[here](http://www.cse.yorku.ca/~oz/hash.html). Differences include iterating
over the string *backwards* (as that is faster in JavaScript) and using the XOR
operator instead of the addition operator (as described at that page and
because it obviates the need for modular arithmetic in JavaScript).
The hashing function returns a number between 0 and 4294967295 (inclusive).
Thanks to [cscott](https://github.com/cscott) for reminding us how integers
work in JavaScript.
License
-------
To the extend possible by law, The Dark Sky Company, LLC has [waived all
copyright and related or neighboring rights][cc0] to this library.
[cc0]: http://creativecommons.org/publicdomain/zero/1.0/
+20
View File
@@ -0,0 +1,20 @@
{
"name": "string-hash",
"repo": "darkskyapp/string-hash",
"description": "fast string hashing function",
"version": "1.1.1",
"keywords": [
"string",
"hashing"
],
"dependencies": {},
"development": {
"mocha": "1.3.x"
},
"license": "CC0",
"main": "index.js",
"scripts": [
"index.js"
],
"remotes": []
}
+17
View File
@@ -0,0 +1,17 @@
"use strict";
function hash(str) {
var hash = 5381,
i = str.length;
while(i) {
hash = (hash * 33) ^ str.charCodeAt(--i);
}
/* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
* integers. Since we want the results to be always positive, convert the
* signed int to an unsigned by doing an unsigned bitshift. */
return hash >>> 0;
}
module.exports = hash;
+27
View File
@@ -0,0 +1,27 @@
{
"name": "string-hash",
"version": "1.1.3",
"description": "fast string hashing function",
"license": "CC0-1.0",
"keywords": [
"string",
"hashing"
],
"author": {
"name": "The Dark Sky Company",
"email": "developer@darksky.net"
},
"repository": {
"type": "git",
"url": "git://github.com/darkskyapp/string-hash.git"
},
"main": "./index",
"dependencies": {
},
"devDependencies": {
"mocha": "*"
},
"scripts": {
"test": "mocha"
}
}
+13
View File
@@ -0,0 +1,13 @@
"use strict";
var assert = require("assert"),
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);
});
it("should hash \"Hello, world!\" to 343662184", function() {
assert.equal(hash("Hello, world!"), 343662184);
});
});