Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arginfo

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arginfo

Simple function for creating a string representation of an arbitrary javascript data value. Useful for printing bad argument values to console error output

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

arginfo

Install

$ npm install arginfo

Usage

Calling arginfo(arg) returns a string representation of arg using node.js' util.inspect. It prefixes the value with the type of the argument (whether it is a primitive type or a built-in object) such that the formatting is consistent across all built-in types:

arginfo(2); // [number: 2]
arginfo({}); // [object: {}]
arginfo('?'); // [string: '?']
arginfo(true); // [boolean: true]
arginfo(/org/); // [RegExp: /org/]
arginfo(new Set()); // [Set: {}]
arginfo(new String('')); // [String: '']
arginfo(new Error('wtf')); // [Error: wtf]

Example

var arginfo = require('arginfo');

function test(str) {
	if('string' !== typeof str) {
		console.error('test expects string. instead got: '+arginfo(str));
	}
}

Settings

By default, arginfo will call util.inspect with a depth of null. To limit the inspection depth of printing object properties, use arginfo.depth. eg:

var arginfo = require('arginfo');
arginfo.depth(1);
arginfo({
	a: {
		b: {
			c:'d'
		}
	}
});  // [object: { a: { b: [Object] } }]

Types

Primitive types:

  • boolean
  • number
  • string
  • object
  • function
  • symbol

Built-in objects:

  • Boolean
  • Number
  • String
  • Array
  • Error
  • RegExp
  • Date
  • Map
  • Set
  • WeakMap
  • WeakSet
  • Promise
  • Generator
  • DataView
  • ArrayBuffer

Keywords

FAQs

Package last updated on 02 Nov 2015

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc