@arcjet/stable-hash 1.1.0-rc → 1.2.0

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/edge-light.js CHANGED
@@ -1,10 +1,6 @@
1
1
  import { makeHasher } from './hasher.js';
2
- export { bool, string, stringSliceOrdered, uint32 } from './hasher.js';
2
+ export { bool, float64, string, stringSliceOrdered, uint32 } from './hasher.js';
3
3
 
4
- // @ts-ignore: this value exists in Edge Light, as it implements the DOM type for it.
5
- // See <https://vercel.com/docs/functions/runtimes/edge#crypto-apis>.
6
- // This can be verified by adding `/// <reference lib="dom" />` above.
7
- // But we don’t want to load the entire DOM types or edge-light-specific types.
8
4
  const hash = makeHasher(crypto.subtle);
9
5
 
10
6
  export { hash, makeHasher };
package/hasher.d.ts CHANGED
@@ -52,6 +52,17 @@ export declare function uint32(key: string, value: number): FieldHasher;
52
52
  * Hasher.
53
53
  */
54
54
  export declare function string(key: string, value: string): FieldHasher;
55
+ /**
56
+ * Create a hasher for a 64-bit floating point number.
57
+ *
58
+ * @param key
59
+ * Key.
60
+ * @param value
61
+ * Value.
62
+ * @returns
63
+ * Hasher.
64
+ */
65
+ export declare function float64(key: string, value: number): FieldHasher;
55
66
  /**
56
67
  * Create a hasher for an array of strings.
57
68
  *
package/hasher.js CHANGED
@@ -83,6 +83,23 @@ function string(key, value) {
83
83
  data.writeString(`"`);
84
84
  };
85
85
  }
86
+ /**
87
+ * Create a hasher for a 64-bit floating point number.
88
+ *
89
+ * @param key
90
+ * Key.
91
+ * @param value
92
+ * Value.
93
+ * @returns
94
+ * Hasher.
95
+ */
96
+ function float64(key, value) {
97
+ return (data) => {
98
+ data.writeString(key);
99
+ data.writeString(fieldSeparator);
100
+ data.writeString(value.toString());
101
+ };
102
+ }
86
103
  /**
87
104
  * Create a hasher for an array of strings.
88
105
  *
@@ -182,4 +199,4 @@ function hex(buf) {
182
199
  return out;
183
200
  }
184
201
 
185
- export { bool, makeHasher, string, stringSliceOrdered, uint32 };
202
+ export { bool, float64, makeHasher, string, stringSliceOrdered, uint32 };
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as crypto from 'node:crypto';
2
2
  import { makeHasher } from './hasher.js';
3
- export { bool, string, stringSliceOrdered, uint32 } from './hasher.js';
3
+ export { bool, float64, string, stringSliceOrdered, uint32 } from './hasher.js';
4
4
 
5
5
  const hash = makeHasher(crypto.subtle);
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcjet/stable-hash",
3
- "version": "1.1.0-rc",
3
+ "version": "1.2.0",
4
4
  "description": "Arcjet stable hashing utility",
5
5
  "keywords": [
6
6
  "arcjet",
@@ -54,10 +54,10 @@
54
54
  },
55
55
  "dependencies": {},
56
56
  "devDependencies": {
57
- "@arcjet/eslint-config": "1.1.0-rc",
58
- "@arcjet/rollup-config": "1.1.0-rc",
59
- "@rollup/wasm-node": "4.57.0",
60
- "@types/node": "25.0.10",
57
+ "@arcjet/eslint-config": "1.2.0",
58
+ "@arcjet/rollup-config": "1.2.0",
59
+ "@rollup/wasm-node": "4.57.1",
60
+ "@types/node": "24.11.0",
61
61
  "eslint": "9.39.2",
62
62
  "typescript": "5.9.3"
63
63
  },
package/workerd.js CHANGED
@@ -1,10 +1,6 @@
1
1
  import { makeHasher } from './hasher.js';
2
- export { bool, string, stringSliceOrdered, uint32 } from './hasher.js';
2
+ export { bool, float64, string, stringSliceOrdered, uint32 } from './hasher.js';
3
3
 
4
- // @ts-ignore: this value exists in Workerd, as it implements the DOM type for it.
5
- // See <https://developers.cloudflare.com/workers/runtime-apis/web-crypto/>.
6
- // This can be verified by adding `/// <reference lib="dom" />` above.
7
- // But we don’t want to load the entire DOM types or workerd-specific types.
8
4
  const hash = makeHasher(crypto.subtle);
9
5
 
10
6
  export { hash, makeHasher };