Comparing version 0.0.1 to 0.0.2
@@ -0,1 +1,7 @@ | ||
0.0.2 / 2014-01-19 | ||
================== | ||
* added tests | ||
* updated README | ||
0.0.1 / 2014-01-01 | ||
@@ -2,0 +8,0 @@ ================== |
{ | ||
"name": "xxhashjs", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "xxHash in Javascript", | ||
@@ -8,2 +8,3 @@ "main": "xxhash.js", | ||
"test": "mocha" | ||
, "prepublish": "lmd build xxhash; lmd build xxhash.min" | ||
}, | ||
@@ -26,2 +27,5 @@ "repository": { | ||
} | ||
, "devDependencies": { | ||
"lmd": "1.11.x" | ||
} | ||
} |
@@ -17,9 +17,6 @@ # Javascript implementation of xxHash | ||
```javascript | ||
<script src="/your/path/to/uint32.js"></script> | ||
<script src="/your/path/to/xxhash.js"></script> | ||
<script src="/your/path/to/xxhash.lmd.js"></script> | ||
``` | ||
NB. xxhashjs depends on the [uint32 library](https://github.com/pierrec/js-cuint) that emulates unsigned 32 bits integers in Javascript. | ||
## Examples | ||
@@ -40,3 +37,7 @@ | ||
* More examples in the examples directory: | ||
* Compute xxHash from a file data | ||
* Use xxHashjs in the browser | ||
## Usage | ||
@@ -70,4 +71,4 @@ | ||
Add data for hashing. The data can either be a string or a NodeJS Buffer object. | ||
* `XXH.digest()` | ||
Finalize the hash calculations | ||
* `XXH.digest()` (_UINT32_) | ||
Finalize the hash calculations and returns an UINT32 object. The hash value can be retrived with toString(<radix>). | ||
@@ -74,0 +75,0 @@ |
@@ -9,5 +9,3 @@ /** | ||
var UINT32 = typeof root['UINT32'] == 'function' | ||
? root['UINT32'] | ||
: require('cuint').UINT32 | ||
var UINT32 = require('cuint').UINT32 | ||
@@ -152,2 +150,14 @@ /* | ||
) | ||
this.v2.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
this.v3.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
this.v4.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
} else { | ||
@@ -158,35 +168,11 @@ this.v1.xxh_update( | ||
) | ||
} | ||
if (isString) { | ||
this.v2.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
} else { | ||
this.v2.xxh_update( | ||
(input[p+1] << 8) | input[p] | ||
, (input[p+3] << 8) | input[p+2] | ||
) | ||
} | ||
if (isString) { | ||
this.v3.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
} else { | ||
this.v3.xxh_update( | ||
(input[p+1] << 8) | input[p] | ||
, (input[p+3] << 8) | input[p+2] | ||
) | ||
} | ||
if (isString) { | ||
this.v4.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
} else { | ||
this.v4.xxh_update( | ||
(input[p+1] << 8) | input[p] | ||
@@ -212,2 +198,17 @@ , (input[p+3] << 8) | input[p+2] | ||
) | ||
p += 4 | ||
this.v2.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
p += 4 | ||
this.v3.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
p += 4 | ||
this.v4.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
} else { | ||
@@ -218,38 +219,14 @@ this.v1.xxh_update( | ||
) | ||
} | ||
p += 4 | ||
if (isString) { | ||
p += 4 | ||
this.v2.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
} else { | ||
this.v2.xxh_update( | ||
(input[p+1] << 8) | input[p] | ||
, (input[p+3] << 8) | input[p+2] | ||
) | ||
} | ||
p += 4 | ||
if (isString) { | ||
p += 4 | ||
this.v3.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
} else { | ||
this.v3.xxh_update( | ||
(input[p+1] << 8) | input[p] | ||
, (input[p+3] << 8) | input[p+2] | ||
) | ||
} | ||
p += 4 | ||
if (isString) { | ||
p += 4 | ||
this.v4.xxh_update( | ||
(input.charCodeAt(p+1) << 8) | input.charCodeAt(p) | ||
, (input.charCodeAt(p+3) << 8) | input.charCodeAt(p+2) | ||
) | ||
} else { | ||
this.v4.xxh_update( | ||
(input[p+1] << 8) | input[p] | ||
@@ -256,0 +233,0 @@ , (input[p+3] << 8) | input[p+2] |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
48968
15
1200
75
1
3
1