JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 26579
  • Score
    100M100P100Q153591F
  • License MIT

Node's util.inspect, extracted for use on the Web

Package Exports

  • node-inspect-extracted

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (node-inspect-extracted) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-inspect-extracted

This library provides an as-faithful-as-possible implementation of Node.js's util.inspect function.

It was built in such a way that it can be kept up-to-date with node's implementation, by taking the code directly from node's repo, and changing nothing but the require() statements. All of the node built-in functions are emulated. Many of the incompatibilities generated from that emulation are not interesting for Web use cases.

Installation

npm install node-inspect-extracted

Use

This should work in node (for testing) and browsers, using either require, import, or as window.Inspect if you include this in your page as a script tag.

With require:

const { inspect } = require('node-inspect-extracted');
console.log(inspect(1));

With import:

import * as inspect from 'node-inspect-extracted';
console.log(inspect.inspect(2));

From the browser:

<script src="https://unpkg.com/node-inspect-extracted/dist/inspect.js"></script>
<script>
  console.log(Inspect.inspect(3));
</script>

LICENSE

This code is an adaptation of the Node.js internal implementation, mostly from the file lib/internal/util/inspect.js, which does not have the Joyent copyright header. The maintainers of this package will not assert copyright over this code, but will assign ownership to the Node.js contributors, with the same license as specified in the Node.js codebase; the portion adapted here should all be plain MIT license.

Tests Coverage Status