MCPcopy Create free account
hub / github.com/denoland/std / bareItemsEqual

Function bareItemsEqual

http/unstable_structured_fields_test.ts:824–843  ·  view source on GitHub ↗
(a: BareItem, b: BareItem)

Source from the content-addressed store, hash-verified

822
823// Compare bare items for equality
824function bareItemsEqual(a: BareItem, b: BareItem): boolean {
825 // Handle integer/decimal comparison - JSON loses distinction between 1 and 1.0
826 if (
827 (a.type === "integer" || a.type === "decimal") &&
828 (b.type === "integer" || b.type === "decimal")
829 ) {
830 return (a.value as number) === (b.value as number);
831 }
832 if (a.type !== b.type) return false;
833 if (a.type === "binary" && b.type === "binary") {
834 const aVal = a.value as Uint8Array;
835 const bVal = b.value as Uint8Array;
836 if (aVal.length !== bVal.length) return false;
837 return aVal.every((v, i) => v === bVal[i]);
838 }
839 if (a.type === "date" && b.type === "date") {
840 return (a.value as Date).getTime() === (b.value as Date).getTime();
841 }
842 return a.value === b.value;
843}
844
845// Compare parameters for equality
846function paramsEqual(

Callers 2

paramsEqualFunction · 0.85
itemsEqualFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected