How to use @agoric/marshal - 7 common examples

To help you get started, we’ve selected a few @agoric/marshal 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 / ERTP / core / config / seatConfig.js View on Github external
const insistSeat = seat => {
  const properties = Object.getOwnPropertyNames(seat);
  // The `handle` is how the use object will be looked up
  insist(properties.includes('handle'))`must include 'handle'`;
  insist(
    passStyleOf(seat.handle) === 'presence' &&
      Object.entries(seat.handle).length === 0 &&
      seat.handle.constructor === Object,
  )`handle should be an empty object`;
  insist(passStyleOf(seat) === 'copyRecord')`seat should be a record`;
  return seat;
};
github Agoric / ERTP / util / sameStructure.js View on Github external
function allComparable(passable) {
  const passStyle = passStyleOf(passable);
  switch (passStyle) {
    case 'null':
    case 'undefined':
    case 'string':
    case 'boolean':
    case 'number':
    case 'symbol':
    case 'bigint':
    case 'presence':
    case 'copyError': {
      return passable;
    }
    case 'promise': {
      return passable.then(nonp => allComparable(nonp));
    }
    case 'copyArray': {
github Agoric / ERTP / util / sameStructure.js View on Github external
function mustBeSameStructureInternal(left, right, message, path) {
  function complain(problem) {
    const template = harden([
      `${message}: ${problem} at ${pathStr(path)}: (`,
      ') vs (',
      ')',
    ]);
    insist(false)(template, left, right);
  }

  const leftStyle = passStyleOf(left);
  const rightStyle = passStyleOf(right);
  if (leftStyle === 'promise') {
    complain('Promise on left');
  }
  if (rightStyle === 'promise') {
    complain('Promise on right');
  }

  if (leftStyle !== rightStyle) {
    complain('different passing style');
  }
  switch (leftStyle) {
    case 'null':
    case 'undefined':
    case 'string':
    case 'boolean':
    case 'number':
github Agoric / ERTP / util / sameStructure.js View on Github external
function sameStructure(left, right) {
  const leftStyle = passStyleOf(left);
  const rightStyle = passStyleOf(right);
  insist(leftStyle !== 'promise')`\
Cannot structurally compare promises: ${left}`;
  insist(rightStyle !== 'promise')`\
Cannot structurally compare promises: ${right}`;

  if (leftStyle !== rightStyle) {
    return false;
  }
  switch (leftStyle) {
    case 'null':
    case 'undefined':
    case 'string':
    case 'boolean':
    case 'number':
    case 'symbol':
    case 'bigint':
github Agoric / ERTP / util / sameStructure.js View on Github external
function mustBeSameStructureInternal(left, right, message, path) {
  function complain(problem) {
    const template = harden([
      `${message}: ${problem} at ${pathStr(path)}: (`,
      ') vs (',
      ')',
    ]);
    insist(false)(template, left, right);
  }

  const leftStyle = passStyleOf(left);
  const rightStyle = passStyleOf(right);
  if (leftStyle === 'promise') {
    complain('Promise on left');
  }
  if (rightStyle === 'promise') {
    complain('Promise on right');
  }

  if (leftStyle !== rightStyle) {
    complain('different passing style');
  }
  switch (leftStyle) {
    case 'null':
    case 'undefined':
    case 'string':
    case 'boolean':
github Agoric / ERTP / util / sameStructure.js View on Github external
function sameStructure(left, right) {
  const leftStyle = passStyleOf(left);
  const rightStyle = passStyleOf(right);
  insist(leftStyle !== 'promise')`\
Cannot structurally compare promises: ${left}`;
  insist(rightStyle !== 'promise')`\
Cannot structurally compare promises: ${right}`;

  if (leftStyle !== rightStyle) {
    return false;
  }
  switch (leftStyle) {
    case 'null':
    case 'undefined':
    case 'string':
    case 'boolean':
    case 'number':
    case 'symbol':
github Agoric / ERTP / core / config / extentOps / listExtentOps.js View on Github external
isEmpty: list => {
      insist(passStyleOf(list) === 'copyArray')`list must be an array`;
      return list.length === 0;
    },
    includes: (whole, part) => {

@agoric/marshal

marshal

Apache-2.0
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular @agoric/marshal functions