Socket
Socket
Sign inDemoInstall

bsert

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bsert - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

129

lib/assert.js

@@ -343,3 +343,3 @@ /*!

function deepEqual(actual, expected, message) {
if (!isDeepEqual(actual, expected)) {
if (!isDeepEqual(actual, expected, false)) {
if (isError(message))

@@ -359,3 +359,3 @@ throw message;

function notDeepEqual(actual, expected, message) {
if (isDeepEqual(actual, expected)) {
if (isDeepEqual(actual, expected, true)) {
if (isError(message))

@@ -478,8 +478,7 @@ throw message;

return 'null';
return `[${objectName(value)}]`;
case 'boolean':
return value.toString();
return `${value}`;
case 'number':
return value.toString();
return `${value}`;
case 'string':

@@ -490,7 +489,7 @@ if (value.length > 80)

case 'symbol':
return value.toString();
return tryString(value);
case 'function':
return `[${objectName(value)}]`;
return `[${funcName(value)}]`;
case 'bigint':
return `${value.toString()}n`;
return `${value}n`;
default:

@@ -501,13 +500,18 @@ return `[${typeof value}]`;

function toString(str) {
if (typeof str === 'string')
return str;
function toString(value) {
if (typeof value === 'string')
return value;
if (isDate(str))
return String(str);
if (isError(value))
return tryString(value);
if (isError(str))
return String(str.message || '');
return stringify(value);
}
return stringify(str);
function tryString(value) {
try {
return String(value);
} catch (e) {
return 'Object';
}
}

@@ -570,3 +574,3 @@

if ((key in err) && isDeepEqual(value, expect))
if ((key in err) && isDeepEqual(value, expect, false))
continue;

@@ -600,4 +604,8 @@

function isDeepEqual(x, y) {
return compare(x, y, null);
function isDeepEqual(x, y, fail) {
try {
return compare(x, y, null);
} catch (e) {
return fail;
}
}

@@ -731,4 +739,4 @@

const ak = Object.keys(a);
const bk = Object.keys(b);
const ak = ownKeys(a);
const bk = ownKeys(b);

@@ -751,2 +759,23 @@ if (ak.length !== bk.length)

function ownKeys(obj) {
const keys = Object.keys(obj);
if (!Object.getOwnPropertySymbols)
return keys;
if (!Object.getOwnPropertyDescriptor)
return keys;
const symbols = Object.getOwnPropertySymbols(obj);
for (const symbol of symbols) {
const desc = Object.getOwnPropertyDescriptor(obj, symbol);
if (desc && desc.enumerable)
keys.push(symbol);
}
return keys;
}
/*

@@ -763,3 +792,7 @@ * Helpers

return Object.prototype.toString.call(obj);
try {
return Object.prototype.toString.call(obj);
} catch (e) {
return '[object Object]';
}
}

@@ -771,23 +804,49 @@

function objectName(value) {
if (value === undefined)
return 'undefined';
function objectName(obj) {
const type = objectType(obj);
if (value === null)
return 'null';
if (obj == null)
return type;
const name = objectType(value);
if (type !== 'Object' && type !== 'Error')
return type;
if (name !== 'Object' && name !== 'Error')
return name;
let ctor, name;
if (!value.constructor
|| typeof value.constructor.name !== 'string'
|| value.constructor.name.length === 0) {
return name;
try {
ctor = obj.constructor;
} catch (e) {
;
}
return value.constructor.name;
if (ctor == null)
return type;
try {
name = ctor.name;
} catch (e) {
return type;
}
if (typeof name !== 'string' || name.length === 0)
return type;
return name;
}
function funcName(func) {
let name;
try {
name = func.name;
} catch (e) {
;
}
if (typeof name !== 'string' || name.length === 0)
return 'Function';
return `Function: ${name}`;
}
function isArray(obj) {

@@ -794,0 +853,0 @@ return Array.isArray(obj);

{
"name": "bsert",
"version": "0.0.8",
"version": "0.0.9",
"description": "Minimal assert with type checking",

@@ -5,0 +5,0 @@ "keywords": [

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