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

lazy-assert

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy-assert - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

src/__test/lazy-assert-without-fs.test.js

2

package.json
{
"name": "lazy-assert",
"version": "0.1.4",
"version": "0.1.5",
"description": "An way of doing assertion for lazy people ...",

@@ -5,0 +5,0 @@ "main": "src/index.js",

var assert = require('assert');
var utils = require('./utils');
var fs = require('fs');
try {
var fs = require('fs');
}
catch (ex) {
fs = require('./fake-fs');
}
/**

@@ -281,2 +287,30 @@ * @start-def: lazyAssert: {}

compare: function (peekKey, actualTargetValue, expectedPreparedValue, depthOrPlugin) {
var actualString = utils.trim(lazyAssert.stringify(actualTargetValue, depthOrPlugin));
var expectedString = utils.trim(lazyAssert.innerStringify(expectedPreparedValue));
// console.log('@@d');
// console.log('"' + actualString + '"');
// console.log('"' + expectedString + '"');
// console.log(actualString === expectedString);
if (actualString !== expectedString) {
console.warn('[WARN] peek <' + peekKey + '> did not match the expected value, the actual prepared value is : ');
console.warn('[WARN] ', JSON.stringify(lazyAssert.prepareValue(actualTargetValue, depthOrPlugin), null, 2));
return false;
}
return true;
},
assert: function (peekKey, actualTargetValue, expectedPreparedValue, depthOrPlugin) {
var actualString = utils.trim(lazyAssert.stringify(actualTargetValue, depthOrPlugin));
var expectedString = utils.trim(lazyAssert.innerStringify(expectedPreparedValue, depthOrPlugin));
if (actualString !== expectedString) {
console.warn('[WARN] peek <' + peekKey + '> did not match the expected value, the actual prepared value is : ');
console.warn('[WARN] ', JSON.stringify(lazyAssert.prepareValue(actualTargetValue, depthOrPlugin), null, 2));
}
assert.equal(actualString, expectedString, peekKey);
},
newPeek: function (peekKey) {

@@ -283,0 +317,0 @@ var peek = new Peek(peekKey);

@@ -57,5 +57,5 @@ var utils = require('./utils');

if (pattern.hasOwnProperty(key)) {
if (typeof subPattern === 'function') {
if (typeof pattern[key] === 'function') {
// match function
result[key] = inner.patternFunction(object[key], key, pattern);
result[key] = inner.patternFunction(object[key], key, pattern[key]);
}

@@ -62,0 +62,0 @@ else {

var npath = require('path');
var fs = require('fs');
try {
var fs = require('fs');
}
catch (ex) {
}
/**

@@ -106,5 +112,14 @@ * @start-def: utils: {}

}
}
},
/**
* // remove the leading/following whitespaces
* @def: .trim: string => string
*/
trim: function(string) {
string = string || '';
return string.replace(/^\s+/, '').replace(/\s+$/, '');
},
};
module.exports = utils;
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