INNER CODE UNIT · TypeScript

bits

blueshift-gg/doppler · packages/core/index.ts:189

  const bits = BigInt(8 * size);
  const n = BigInt(x);
  const min = signed ? -(1n << (bits - 1n)) : 0n;
  const max = (1n << (signed ? bits - 1n : bits)) - 1n;
  if (n < min || n > max) throw new RangeError(`${name}: ${x} does not fit ${type}`);
  if (size === 8) view.setBigUint64(at, BigInt.asUintN(64, n), true);
  else if (size === 4) view.setUint32(at, Number(BigInt.asUintN(32, n)), true);
  else if (size === 2) view.setUint16(at, Number(BigInt.asUintN(16, n)), true);
  else view.setUint8(at, Number(BigInt.asUintN(8, n)));
}

/** One program, one admin, one payload layout, one feed account. */
export class Feed<F extends readonly FieldLike[] = readonly Field[]> {
  private constructor(
    readonly manifest: Manifest<F>,
    /** `createWithSeed(admin, seed, loader)`. */
    readonly program: string,
    /** The feed account: `createWithSeed(admin, FEED_SEED, program)`. */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…