Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
inspect-with-kind
Advanced tools
Readme
util.inspect
with additional type information
const {inspect} = require('util');
const inspectWithKind = require('inspect-with-kind');
inspect([1, 2, 3]); //=> '[ 1, 2, 3 ]'
inspectWithKind([1, 2, 3]); //=> '[ 1, 2, 3 ] (array)'
npm install inspect-with-kind
const inspectWithKind = require('inspect-with-kind');
value: any type
options: Object
(util.inspect
options)
Return: string
Almost the same as util.inspect
, but:
boolean
, string
, number
, bigint
, Array
, RegExp
, Date
, arguments
or a plain Object
.breakLength
option defaults to Infinity
.maxArrayLength
option defaults to 10
.const util = require('util');
const inspectWithKind = require('inspect-with-kind');
// appends type info
util.inspect(1); //=> '1'
inspectWithKind(1); //=> '1 (number)'
util.inspect('1'); //=> '\'1\''
inspectWithKind('1'); //=> '\'1\' (string)'
// doesn't appends type info, because <Buffer ...> clearly expresses what it is
util.inspect(Buffer.from('1')); //=> '<Buffer 31>'
inspectWithKind(Buffer.from('1')); //=> '<Buffer 31>'
// omits stack trace
util.inspect(new Error('error!')); //=> 'Error: error!\n at repl:1:14\n at ContextifyScript ...'
inspectWithKind(new Error('error!')); //=> 'Error: error!'
This module is useful for making TypeError
error messages in your Node.js library.
const inspectWithKind = require('inspect-with-kind');
module.exports = function reverse(v) {
if (typeof v !== 'boolean') {
throw new TypeError(`Expected a Boolean value, but got ${inspectWithKind(v)}.`);
}
return !v;
};
const reverse = require('./reverse.js');
reverse(/true/); // TypeError: Expected a Boolean value, but got /true/ (regexp).
ISC License © 2017 Shinnosuke Watanabe
FAQs
`util.inspect` with additional type information
The npm package inspect-with-kind receives a total of 117,123 weekly downloads. As such, inspect-with-kind popularity was classified as popular.
We found that inspect-with-kind demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.