MCPcopy Create free account
hub / github.com/TanStack/db / update

Method update

packages/db-ivm/src/hashing/murmur.ts:66–119  ·  view source on GitHub ↗
(chunk: symbol | string | number | bigint)

Source from the content-addressed store, hash-verified

64 }
65
66 update(chunk: symbol | string | number | bigint): void {
67 switch (typeof chunk) {
68 case `symbol`: {
69 this.update(SYMBOL_MARKER)
70 const description = chunk.description
71 if (!description) {
72 return
73 }
74
75 for (let i = 0; i < description.length; i++) {
76 const code = description.charCodeAt(i)
77 this.writeByte(code & 0xff)
78 this.writeByte((code >>> 8) & 0xff)
79 }
80 return
81 }
82 case `string`:
83 this.update(STRING_MARKER)
84 for (let i = 0; i < chunk.length; i++) {
85 const code = chunk.charCodeAt(i)
86 this.writeByte(code & 0xff)
87 this.writeByte((code >>> 8) & 0xff)
88 }
89 return
90 case `number`:
91 dv.setFloat64(0, chunk, true) // fixed little-endian
92 this.writeByte(u8[0]!)
93 this.writeByte(u8[1]!)
94 this.writeByte(u8[2]!)
95 this.writeByte(u8[3]!)
96 this.writeByte(u8[4]!)
97 this.writeByte(u8[5]!)
98 this.writeByte(u8[6]!)
99 this.writeByte(u8[7]!)
100 return
101 case `bigint`: {
102 let value = chunk
103 if (value < 0n) {
104 value = -value
105 this.update(NEG_BIG_INT_MARKER)
106 } else {
107 this.update(BIG_INT_MARKER)
108 }
109 while (value > 0n) {
110 this.writeByte(Number(value & 0xffn))
111 value >>= 8n
112 }
113 if (chunk === 0n) this.writeByte(0)
114 return
115 }
116 default:
117 throw new TypeError(`Unsupported input type: ${typeof chunk}`)
118 }
119 }
120
121 digest(): number {
122 if (this.carryBytes > 0) {

Callers 5

hashDateFunction · 0.95
hashUint8ArrayFunction · 0.95
hashTemporalFunction · 0.95
hashPlainObjectFunction · 0.95
updateHasherFunction · 0.45

Calls 1

writeByteMethod · 0.95

Tested by

no test coverage detected