@jskit-ai/kernel 0.1.56 → 0.1.57
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/package.json
CHANGED
|
@@ -198,6 +198,13 @@ function normalizeRecordId(value, { fallback = null } = {}) {
|
|
|
198
198
|
return normalizeCanonicalRecordIdText(value, { fallback });
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
if (typeof value === "number") {
|
|
202
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
203
|
+
return fallback;
|
|
204
|
+
}
|
|
205
|
+
return normalizeCanonicalRecordIdText(value, { fallback });
|
|
206
|
+
}
|
|
207
|
+
|
|
201
208
|
if (typeof value === "bigint") {
|
|
202
209
|
if (value < 1n) {
|
|
203
210
|
return fallback;
|
|
@@ -174,11 +174,13 @@ test("normalizeOrNull normalizes non-nullish values and coerces nullish to null"
|
|
|
174
174
|
);
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
test("normalizeRecordId accepts canonical string and bigint identifiers
|
|
177
|
+
test("normalizeRecordId accepts canonical string, safe integer, and bigint identifiers", () => {
|
|
178
178
|
const unsafeNumericId = Number(9007199254740993n);
|
|
179
179
|
assert.equal(normalizeRecordId(" 7 "), "7");
|
|
180
|
+
assert.equal(normalizeRecordId(7), "7");
|
|
180
181
|
assert.equal(normalizeRecordId(10n), "10");
|
|
181
|
-
assert.equal(normalizeRecordId(7), null);
|
|
182
|
+
assert.equal(normalizeRecordId(7.5), null);
|
|
183
|
+
assert.equal(normalizeRecordId(0), null);
|
|
182
184
|
assert.equal(normalizeRecordId(unsafeNumericId), null);
|
|
183
185
|
assert.equal(normalizeRecordId(""), null);
|
|
184
186
|
assert.equal(normalizeRecordId(null), null);
|