Socket
Socket
Sign inDemoInstall

bsert

Package Overview
Dependencies
Maintainers
3
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.12 to 0.0.13

103

lib/assert.js

@@ -24,2 +24,3 @@ /*!

let generatedMessage = Boolean(options.generatedMessage);
let start = null;

@@ -45,6 +46,2 @@ if (options.message != null)

super(message);
let start = this.constructor;
if (typeof options.stackStartFunction === 'function')

@@ -55,6 +52,6 @@ start = options.stackStartFunction;

this.type = 'AssertionError';
this.name = 'AssertionError [ERR_ASSERTION]';
super(message);
this.generatedMessage = generatedMessage;
this.code = 'ERR_ASSERTION';
this.generatedMessage = generatedMessage;
this.actual = options.actual;

@@ -64,7 +61,24 @@ this.expected = options.expected;

if (Error.captureStackTrace)
Object.defineProperty(this, 'name', {
value: 'AssertionError [ERR_ASSERTION]',
enumerable: false,
writable: true,
configurable: true
});
if (Error.captureStackTrace && start != null)
Error.captureStackTrace(this, start);
this.stack;
this.name = 'AssertionError';
}
toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
}
AssertionError.prototype.name = 'AssertionError';
AssertionError.prototype.type = 'AssertionError'; // Deprecated.
/*

@@ -346,2 +360,10 @@ * Assert

function match(string, regexp, message) {
testMatch(string, regexp, message, match, true);
}
function doesNotMatch(string, regexp, message) {
testMatch(string, regexp, message, doesNotMatch, false);
}
function deepEqual(actual, expected, message) {

@@ -568,5 +590,5 @@ if (!isDeepEqual(actual, expected, false)) {

if (typeof value === 'string'
&& isRegExp(expect)
&& expect.test(value)) {
if (typeof value === 'string' &&
isRegExp(expect) &&
expect.test(value)) {
continue;

@@ -594,2 +616,3 @@ }

// eslint-disable-next-line no-prototype-builtins
if (Error.isPrototypeOf(expected))

@@ -601,2 +624,31 @@ return false;

function testMatch(string, regexp, message, fn, expect) {
enforce(typeof string === 'string', 'string', 'string');
enforce(isRegExp(regexp), 'regexp', 'RegExp');
if (regexp.test(string) !== expect) {
if (isError(message))
throw message;
let generatedMessage = false;
if (message == null) {
message = `The input ${expect ? 'did' : 'was expected to'} `
+ `not match the regular expression ${regexp}. `
+ `Input:\n\n${stringify(string)}\n`;
generatedMessage = true;
}
throw new AssertionError({
actual: string,
expected: regexp,
message,
operator: fn.name,
generatedMessage,
stackStartFn: fn
});
}
}
/*

@@ -635,9 +687,4 @@ * Comparisons

if (isRegExp(a)) {
return a.source === b.source
&& a.global === b.global
&& a.multiline === b.multiline
&& a.lastIndex === b.lastIndex
&& a.ignoreCase === b.ignoreCase;
}
if (isRegExp(a))
return a.source === b.source && a.flags === b.flags;

@@ -658,4 +705,4 @@ if (isError(a)) {

const x = new Uint8Array(a.buffer);
const y = new Uint8Array(b.buffer);
const x = new Uint8Array(a.buffer, a.byteOffset, a.byteLength);
const y = new Uint8Array(b.buffer, b.byteOffset, b.byteLength);

@@ -903,6 +950,10 @@ if (x.length !== y.length)

switch (enc) {
if (enc.length > 9)
return false;
switch (enc.toLowerCase()) {
case 'ascii':
case 'binary':
case 'base64':
case 'base64url':
case 'hex':

@@ -913,2 +964,5 @@ case 'latin1':

case 'utf16le':
case 'ucs-2':
case 'utf-8':
case 'utf-16le':
return true;

@@ -933,8 +987,5 @@ }

if (enc === 'hex' && (expected.length & 1))
return null;
const raw = constructor.from(expected, enc);
if (enc === 'hex' && raw.length !== (expected.length >>> 1))
if (enc.length === 3 && raw.length * 2 !== expected.length)
return null;

@@ -966,2 +1017,4 @@

assert.ifError = ifError;
assert.match = match;
assert.doesNotMatch = doesNotMatch;
assert.deepEqual = deepEqual;

@@ -968,0 +1021,0 @@ assert.notDeepEqual = notDeepEqual;

{
"name": "bsert",
"version": "0.0.12",
"version": "0.0.13",
"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