util#inspect JavaScript Examples

The following examples show how to use util#inspect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From action-dependabot-auto-merge with MIT License 6 votes vote down vote up
// error handler
function errorHandler ({ message, stack, request }) {
  core.error(`${message}\n${stack}`)

  // debugging for API calls
  if (request) {
    const { method, url, body, headers } = request
    core.debug(`${method} ${url}\n\n${inspect(headers)}\n\n${inspect(body)}`)
  }

  process.exit(1)
}
Example #2
Source File: index.js    From react-native-ipfs-demo with MIT License 6 votes vote down vote up
addString = (client) => async () => {
  console.log('Demo App .add string start');

  const file = {
    path: '/tmp/rn-ipfs-add-string',
    content: '邑中陽裏人也,姓劉氏。母媼嘗息大澤之陂,夢與神遇',
  };
  try {
    console.log('Demo App .add string', {
      result: inspect(await client.add(file)),
    });
  } catch (error) {
    console.error('Demo App .add string', {error});
  }
}
Example #3
Source File: index.js    From react-native-ipfs-demo with MIT License 6 votes vote down vote up
addUint8Array = (client) => async () => {
  console.log('Demo App .add string start');

  const file = {
    path: '/tmp/rn-ipfs-add-uint8array',
    content: Uint8Array.from('123456789'),
  };
  try {
    console.log('Demo App .add Uint8Array', {
      result: inspect(await client.add(file)),
    });
  } catch (error) {
    console.error('Demo App .add Uint8Array', {error});
  }
}
Example #4
Source File: index.js    From react-native-ipfs-demo with MIT License 6 votes vote down vote up
addUint8Arrays = (client) => async () => {
  console.log('Demo App .add Uint8Arrays start');

  const file = {
    path: '/tmp/rn-ipfs-add-uint8arrays',
    content: [
      Uint8Array.from('123456789'),
      Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9]),
    ],
  };
  try {
    console.log('Demo App .add Uint8Arrays', {
      result: inspect(await client.add(file)),
    });
  } catch (error) {
    console.error('Demo App .add Uint8Arrays', {error});
  }
}
Example #5
Source File: index.js    From react-native-ipfs-demo with MIT License 6 votes vote down vote up
addNumbers = (client) => async () => {
  console.log('Demo App .add numbers start');

  const file = {
    path: '/tmp/rn-ipfs-add-numbers',
    content: [1, 2, 3, 4, 5, 6, 7, 8, 9],
  };
  try {
    console.log('Demo App .add numbers', {
      result: inspect(await client.add(file)),
    });
  } catch (error) {
    console.error('Demo App .add numbers', {error});
  }
}
Example #6
Source File: index.js    From react-native-ipfs-demo with MIT License 6 votes vote down vote up
addBlob = (client) => async () => {
  console.log('Demo App .add blob start');

  const buffer = new ArrayBuffer(9);
  const view = new Uint8Array(buffer);

  view.set([1, 2, 3, 4, 5, 6, 7, 8, 9]);

  const file = {
    path: '/tmp/rn-ipfs-add-blob',
    content: new Blob(['React Native IPFS', view.buffer]),
  };
  try {
    console.log('Demo App .add blob', {
      result: inspect(await client.add(file)),
    });
  } catch (error) {
    console.error('Demo App .add blob', {error});
  }
}
Example #7
Source File: index.js    From react-native-ipfs-demo with MIT License 6 votes vote down vote up
IdScreen = () => {
  const {client} = useIpfs();

  const id = async () => {
    try {
      console.log('Demo App .id start');
      console.log('Demo App .id', {result: inspect(await client.id())});
    } catch (error) {
      console.error('Demo App .id', {error});
    }
  };

  return (
    <View>
      <Button mode="contained" onPress={id}>
        Press me
      </Button>
    </View>
  );
}
Example #8
Source File: index.js    From react-native-ipfs-demo with MIT License 6 votes vote down vote up
LsScreen = () => {
  const {client} = useIpfs();

  const ls = async () => {
    const CID = 'QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr';

    try {
      console.log('Demo App .ls start');
      for await (const file of client.ls(CID)) {
        console.log('Demo App .ls', {file: inspect(file)});
      }
    } catch (error) {
      console.error('Demo App .ls', {error});
    }
  };

  return (
    <View>
      <Button mode="contained" onPress={ls}>
        Press me
      </Button>
    </View>
  );
}
Example #9
Source File: terminal.js    From bot with GNU General Public License v3.0 6 votes vote down vote up
terminal = {
  log(message) {
    const insp = inspect(message);
    stdout.write(`${kleur.gray(`[${getTimestamp()}]`)} ${kleur.white(insp)}\n`);
  },
  warn(message) {
    const insp = inspect(message);
    stdout.write(
      `${kleur.gray(`[${getTimestamp()}]`)} ${kleur.yellow(insp)}\n`
    );
  },
  error(message) {
    const insp = inspect(message);
    stderr.write(`${kleur.gray(`[${getTimestamp()}]`)} ${kleur.red(insp)}\n`);
  },
  info(message) {
    const insp = inspect(message);
    stdout.write(`${kleur.gray(`[${getTimestamp()}]`)} ${kleur.blue(insp)}\n`);
  },
  success(message) {
    const insp = inspect(message);
    stdout.write(`${kleur.gray(`[${getTimestamp()}]`)} ${kleur.green(insp)}\n`);
  }
}
Example #10
Source File: bot.js    From gidget with Apache License 2.0 5 votes vote down vote up
process.on("unhandledRejection", error => {
  console.error("Unhandled promise rejection:", error);
  //This will be useful to finding unknown errors sometimes
  if (error.requestData?.json) console.error(inspect(error.requestData.json, { depth: 5 }));
});
Example #11
Source File: index.js    From react-native-ipfs-demo with MIT License 5 votes vote down vote up
GetScreen = () => {
  const {client} = useIpfs();

  const get = async () => {
    const CID = 'QmfGBRT6BbWJd7yUc2uYdaUZJBbnEFvTqehPFoSMQ6wgdr';
    try {
      console.log('Demo App .get start');

      for await (const file of client.get(CID)) {
        if (!file.content) {
          continue;
        }

        const content = [];

        for await (const chunk of file.content) {
          content.push(chunk);
        }

        console.log(
          'Demo App .get',
          inspect({
            file,
            content,
          }),
        );
      }
    } catch (error) {
      console.error('Demo App .get', {error});
    }
  };

  return (
    <View>
      <Button mode="contained" onPress={get}>
        Press me
      </Button>
    </View>
  );
}
Example #12
Source File: inspect.js    From action-install-gh-release with Apache License 2.0 5 votes vote down vote up
custom = inspect.custom