MCPcopy Create free account
hub / github.com/redis/node-redis / #decodeDoubleDecimal

Method #decodeDoubleDecimal

packages/client/lib/RESP/decoder.ts:414–440  ·  view source on GitHub ↗
(isNegative, decimalIndex, double, chunk)

Source from the content-addressed store, hash-verified

412 ];
413
414 #decodeDoubleDecimal(isNegative, decimalIndex, double, chunk) {
415 let cursor = this.#cursor;
416 do {
417 const byte = chunk[cursor];
418 switch (byte) {
419 case ASCII.E:
420 case ASCII.e: {
421 this.#cursor = cursor + 1; // skip E/e
422 const d = isNegative ? -double : double;
423 return this.#cursor === chunk.length ?
424 this.#decodeDoubleExponent.bind(this, d) :
425 this.#decodeDoubleExponent(d, chunk);
426 }
427
428 case ASCII['\r']:
429 this.#cursor = cursor + 2; // skip \r\n
430 return isNegative ? -double : double;
431 }
432
433 if (decimalIndex < Decoder.#DOUBLE_DECIMAL_MULTIPLIERS.length) {
434 double += (byte - ASCII['0']) * Decoder.#DOUBLE_DECIMAL_MULTIPLIERS[decimalIndex++];
435 }
436 } while (++cursor < chunk.length);
437
438 this.#cursor = cursor;
439 return this.#decodeDoubleDecimal.bind(this, isNegative, decimalIndex, double);
440 }
441
442 #decodeDoubleExponent(double, chunk) {
443 switch (chunk[this.#cursor]) {

Callers 1

Calls 1

#decodeDoubleExponentMethod · 0.95

Tested by

no test coverage detected