Socket
Socket
Sign inDemoInstall

loupe

Package Overview
Dependencies
1
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    loupe

Inspect utility for Node.js and browsers


Version published
Weekly downloads
8.9M
decreased by-0.01%
Maintainers
2
Install size
67.2 kB
Created
Weekly downloads
 

Package description

What is loupe?

The loupe npm package is a library that allows you to inspect JavaScript objects in a detailed and structured way. It is particularly useful for debugging and understanding complex structures by providing a clear visualization of the object's properties, including those that are not enumerable or are inherited through the prototype chain.

What are loupe's main functionalities?

Inspecting objects

This feature allows you to inspect JavaScript objects and see their structure and contents in a human-readable format. The code sample demonstrates how to use loupe to inspect a simple object.

const loupe = require('loupe');
console.log(loupe({ a: 1, b: { c: 2 } }));

Inspecting arrays

Loupe can also be used to inspect arrays, including nested arrays, to visualize their contents and structure.

const loupe = require('loupe');
console.log(loupe([1, 2, 3, [4, 5]]));

Inspecting functions

This feature is useful for inspecting functions, including their name, length (number of expected arguments), and code. The code sample shows how to inspect a simple function.

const loupe = require('loupe');
function exampleFunction() { return true; }
console.log(loupe(exampleFunction));

Inspecting prototypes

Loupe can inspect objects and their prototypes, revealing inherited properties. The code sample demonstrates inspecting an instance of a custom class.

const loupe = require('loupe');
function MyClass() { this.a = 1; }
MyClass.prototype.b = 2;
console.log(loupe(new MyClass()));

Other packages similar to loupe

Readme

Source

npm Build Codecov branch

What is loupe?

Loupe turns the object you give it into a string. It's similar to Node.js' util.inspect() function, but it works cross platform, in most modern browsers as well as Node.

Installation

Node.js

loupe is available on npm. To install it, type:

$ npm install loupe

Browsers

You can also use it within the browser; install via npm and use the loupe.js file found within the download. For example:

<script src="./node_modules/loupe/loupe.js"></script>

Usage

const { inspect } = require('loupe');
inspect({ foo: 'bar' }); // => "{ foo: 'bar' }"
inspect(1); // => '1'
inspect('foo'); // => "'foo'"
inspect([ 1, 2, 3 ]); // => '[ 1, 2, 3 ]'
inspect(/Test/g); // => '/Test/g'

// ...

Tests

$ npm test

Coverage:

$ npm run upload-coverage

License

(The MIT License)

Copyright (c) 2011-2013 Jake Luer jake@alogicalparadox.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FAQs

Last updated on 08 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc