How to use prando - 10 common examples

To help you get started, we’ve selected a few prando examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledger-live-common / src / __tests__ / helpers / countervalue.js View on Github external
const getPairHistory = (ticker, fiat) => date =>
    !date
      ? 1 // for the test, we make countervalue value 1 at current price
      : date > new Date()
        ? 0 // let's assume we return 0 for future
        : 0.0000001 * (Date.now() - date) +
          new Prando(`${ticker}-${fiat}`).next(0, 99);
  const calculateCounterValue = makeCalculateCounterValue(getPairHistory);
github jamesporter / solandra / src / lib / sCanvas.ts View on Github external
rngSeed?: string | number,
    time?: number
  ) {
    ctx.resetTransform()
    this.aspectRatio = width / height
    // i.e. size 1 = entire width
    this.originalScale = width
    // i.e. size 1/100 of width
    ctx.scale(width, width)
    ctx.lineWidth = 0.01
    ctx.lineJoin = "round"
    ctx.strokeStyle = "black"
    ctx.fillStyle = "gray"
    this.lineStyle = { cap: "round" }

    this.rng = new Prando(rngSeed)
    // RNG is pretty poor with similar integer seeds, iterates it 100 times which seems to improve
    // will probably replace with better RNG?
    this.rng.skip(100)
    this.t = time || 0
  }
github LedgerHQ / ledger-live-desktop / src / bridge / makeMockBridge.js View on Github external
Observable.create(o => {
        const rng = new Prando()
        const op = genOperation(account, account.operations, account.currency, rng)
        op.type = 'OUT'
        op.value = t.amount
        op.blockHash = null
        op.blockHeight = null
        op.senders = [account.freshAddress]
        op.recipients = [t.recipient]
        op.blockHeight = account.blockHeight
        op.date = new Date()
        broadcasted[account.id] = (broadcasted[account.id] || []).concat(op)
        o.next({ type: 'signed' })
        o.next({ type: 'broadcasted', operation: { ...op } })
      }),
  }
github LedgerHQ / ledger-live-common / src / mock / account.js View on Github external
function genTokenAccount(
  index: number,
  account: Account
): $Exact {
  const rng = new Prando(account.id + "|" + index);
  const tokens = listTokensForCryptoCurrency(account.currency).filter(t =>
    hardcodedMarketcap.includes(t.id)
  );
  const token = rng.nextArrayItem(tokens);
  const tokenAccount = {
    type: "TokenAccount",
    id: account.id + "|" + index,
    parentId: account.id,
    token,
    operationsCount: 0,
    operations: [],
    pendingOperations: [],
    balance: BigNumber(0)
  };

  const operationsSize = rng.nextInt(1, 200);
github LedgerHQ / ledger-live-common / src / mock / account.js View on Github external
export function genAddingOperationsInAccount(
  account: Account,
  count: number,
  seed: number | string
): Account {
  const rng = new Prando(seed);
  const copy: Account = { ...account };
  copy.operations = Array(count)
    .fill(null)
    .reduce(ops => {
      const op = genOperation(copy, copy, ops, rng);
      return ops.concat(op);
    }, copy.operations);
  copy.balance = ensureNoNegative(copy.operations);
  return copy;
}
github LedgerHQ / ledger-live-common / src / bridge / mockHelpers.js View on Github external
await delay(1000);
      if (cancelled) return;

      for (let i = 0; i <= 1; i += 0.1) {
        o.next({ type: "device-streaming", progress: i });
        await delay(300);
      }

      o.next({ type: "device-signature-requested" });

      await delay(2000);
      if (cancelled) return;

      o.next({ type: "device-signature-granted" });

      const rng = new Prando();
      const op = genOperation(account, account, account.operations, rng);
      op.type = "OUT";
      op.value = transaction.amount;
      op.blockHash = null;
      op.blockHeight = null;
      op.senders = [account.freshAddress];
      op.recipients = [transaction.recipient];
      op.blockHeight = account.blockHeight;
      op.date = new Date();

      await delay(1000);
      if (cancelled) return;
      broadcasted[account.id] = (broadcasted[account.id] || []).concat(op);
      o.next({
        type: "signed",
        signedOperation: {
github LedgerHQ / ledger-live-common / src / bridge / makeMockBridge.js View on Github external
timeout = setTimeout(() => {
          const rng = new Prando();
          const op = genOperation(account, account, account.operations, rng);
          op.type = "OUT";
          op.value = t.amount;
          op.blockHash = null;
          op.blockHeight = null;
          op.senders = [account.freshAddress];
          op.recipients = [t.recipient];
          op.blockHeight = account.blockHeight;
          op.date = new Date();
          broadcasted[account.id] = (broadcasted[account.id] || []).concat(op);
          o.next({ type: "broadcasted", operation: { ...op } });
          o.complete();
        }, 3000);
      }, 3000);
github jamesporter / solandra / src / lib / sCanvas.ts View on Github external
resetRandomNumberGenerator(seed?: number | string) {
    this.rng = new Prando(seed)
  }
github Thorium-Sim / thorium / client / src / components / views / CommDecoding / index.js View on Github external
onClick={() => {
                    this.rng = new Prando(selectedMessage.id);
                    this.setState(
                      {
                        decodedMessage: "",
                        message: selectedMessage.message,
                        ra: selectedMessage.ra,
                        rf: selectedMessage.rf
                      },
                      this.decode.bind(this)
                    );
                  }}
                >
github LedgerHQ / ledger-live-common / src / mock / account.js View on Github external
export function genAccount(
  id: number | string,
  opts: GenAccountOptions = {}
): $Exact {
  const rng = new Prando(id);
  const currency = opts.currency || rng.nextArrayItem(currencies);
  const operationsSize = opts.operationsSize || rng.nextInt(1, 200);
  const address = genAddress(currency, rng);
  const derivationPath = runDerivationScheme(
    getDerivationScheme({ currency, derivationMode: "" }),
    currency
  );
  const freshAddress = { address, derivationPath };

  const account: $Exact = {
    type: "Account",
    id: `mock:1:${currency.id}:${id}:`,
    seedIdentifier: "mock",
    derivationMode: "",
    xpub: genHex(64, rng),
    index: 1,

prando

Deterministic pseudo-random number generator for JavaScript and TypeScript

MIT
Latest version published 4 years ago

Package Health Score

50 / 100
Full package analysis

Popular prando functions