How to use the @agoric/nat function in @agoric/nat

To help you get started, we’ve selected a few @agoric/nat 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 agoric-labs / PlaygroundVat / test / test-nat.js View on Github external
exports.foo = a => {
    /* eslint-disable-next-line no-shadow, global-require */
    const Nat = require('@agoric/nat');
    return Nat(a);
  };
}
github Agoric / ERTP / more / pixels / types / pixel.js View on Github external
function insistWithinBounds(num, canvasSize) {
  Nat(num);
  Nat(canvasSize);
  // 0 to canvasSize - 1
  insist(num >= 0 && num < canvasSize)`\
  pixel position must be within bounds`;
}
github Agoric / ERTP / more / pixels / types / pixel.js View on Github external
function insistWithinBounds(num, canvasSize) {
  Nat(num);
  Nat(canvasSize);
  // 0 to canvasSize - 1
  insist(num >= 0 && num < canvasSize)`\
  pixel position must be within bounds`;
}
github Agoric / ERTP / core / zoe / contractUtils.js View on Github external
  divide: (x, y) => Nat(Math.floor(x / y)),
});
github Agoric / ERTP / core / zoe / contractUtils.js View on Github external
  add: (x, y) => Nat(x + y),
  subtract: (x, y) => Nat(x - y),
github Agoric / ERTP / core / config / extentOps / natExtentOps.js View on Github external
    with: (left, right) => Nat(left + right),
    without: (whole, part) => Nat(whole - part),
github Agoric / ERTP / more / pixels / gallery.js View on Github external
function getPixelColor(x, y) {
    const rawPixel = harden({ x: Nat(x), y: Nat(y) });
    return state[rawPixel.x][rawPixel.y];
  }
github Agoric / ERTP / core / zoe / contractUtils.js View on Github external
  multiply: (x, y) => Nat(x * y),
  divide: (x, y) => Nat(Math.floor(x / y)),

@agoric/nat

Ensures that a number is within the natural numbers (0, 1, 2...) or throws a RangeError

Apache-2.0
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis

Popular @agoric/nat functions