@superinstance/canary-hash 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +4 -3
- package/package.json +1 -1
- package/test.js +3 -2
package/index.js
CHANGED
|
@@ -18,18 +18,19 @@ function fnv1a64(s) {
|
|
|
18
18
|
return h;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
// The fleet canary: 0x024a555471370b18d (decimal 2,640,610,520,279,855,501)
|
|
22
|
+
const EXPECTED = 0x024a555471370b18dn;
|
|
22
23
|
const s = "café Δ 日本語";
|
|
23
|
-
const h = fnv1a64(s);
|
|
24
24
|
|
|
25
25
|
module.exports = { fnv1a64, EXPECTED, canaryString: s };
|
|
26
26
|
|
|
27
27
|
if (require.main === module) {
|
|
28
|
+
const h = fnv1a64(s);
|
|
28
29
|
console.log(`0x${h.toString(16).padStart(16, '0')}`);
|
|
29
30
|
if (h === EXPECTED) {
|
|
30
31
|
console.log("✓ Fleet canary verified: 0x024a555471370b18d");
|
|
31
32
|
} else {
|
|
32
|
-
console.error(`✗ FAIL: expected
|
|
33
|
+
console.error(`✗ FAIL: expected 0x${EXPECTED.toString(16).padStart(16, '0')}, got 0x${h.toString(16).padStart(16, '0')}`);
|
|
33
34
|
process.exit(1);
|
|
34
35
|
}
|
|
35
36
|
}
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const { fnv1a64, EXPECTED } = require('./index.js');
|
|
2
2
|
const h = fnv1a64("café Δ 日本語");
|
|
3
|
-
|
|
3
|
+
const formatted = `0x${h.toString(16).padStart(16, '0')}`;
|
|
4
|
+
console.log(formatted);
|
|
4
5
|
if (h !== EXPECTED) {
|
|
5
|
-
console.error(`✗ FAIL: expected
|
|
6
|
+
console.error(`✗ FAIL: expected ${EXPECTED.toString(16)}, got ${h.toString(16)}`);
|
|
6
7
|
process.exit(1);
|
|
7
8
|
}
|
|
8
9
|
console.log("✓ test passed");
|