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

chai

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chai - npm Package Compare versions

Comparing version 4.1.2 to 4.2.0

4

CONTRIBUTING.md

@@ -157,3 +157,3 @@ # Chai Contribution Guidelines

- Build chai.js
- Bump the version numbers accross the project
- Bump the version numbers across the project
- Make a commit within git

@@ -167,3 +167,3 @@

1. Go to te [Releases page on Github](https://github.com/chaijs/chai/releases)
1. Go to the [Releases page on Github](https://github.com/chaijs/chai/releases)
2. Hit "Draft a new release" (if you can't see this, you're not a core contributor!)

@@ -170,0 +170,0 @@ 3. Write human-friendly Release Notes based on changelog.

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

exports.version = '4.1.2';
exports.version = '4.2.0';

@@ -16,0 +16,0 @@ /*!

@@ -93,3 +93,3 @@ module.exports = {

proxyExcludedKeys: ['then', 'inspect', 'toJSON']
proxyExcludedKeys: ['then', 'catch', 'inspect', 'toJSON']
};

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

/**
* ### .fail([message])
* ### .fail(actual, expected, [message], [operator])

@@ -18,2 +19,9 @@ *

*
* expect.fail();
* expect.fail("custom error message");
* expect.fail(1, 2);
* expect.fail(1, 2, "custom error message");
* expect.fail(1, 2, "custom error message", ">");
* expect.fail(1, 2, undefined, ">");
*
* @name fail

@@ -29,2 +37,7 @@ * @param {Mixed} actual

chai.expect.fail = function (actual, expected, message, operator) {
if (arguments.length < 2) {
message = actual;
actual = undefined;
}
message = message || 'expect.fail()';

@@ -31,0 +44,0 @@ throw new chai.AssertionError(message, {

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

/**
* ### .fail([message])
* ### .fail(actual, expected, [message], [operator])

@@ -50,2 +51,10 @@ *

*
* should.fail();
* should.fail("custom error message");
* should.fail(1, 2);
* should.fail(1, 2, "custom error message");
* should.fail(1, 2, "custom error message", ">");
* should.fail(1, 2, undefined, ">");
*
*
* @name fail

@@ -61,2 +70,7 @@ * @param {Mixed} actual

should.fail = function (actual, expected, message, operator) {
if (arguments.length < 2) {
message = actual;
actual = undefined;
}
message = message || 'should.fail()';

@@ -63,0 +77,0 @@ throw new chai.AssertionError(message, {

@@ -1,3 +0,1 @@

var config = require('../config');
var fnLengthDesc = Object.getOwnPropertyDescriptor(function () {}, 'length');

@@ -4,0 +2,0 @@

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

/*!
* Module dependancies
* Module dependencies
*/

@@ -24,3 +24,3 @@

* @param {Mixed} second element to compare
* @returns {Number} -1 if 'a' should come before 'b'; otherwise 1
* @returns {Number} -1 if 'a' should come before 'b'; otherwise 1
* @name compareByInspect

@@ -27,0 +27,0 @@ * @namespace Utils

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

/*!
* Module dependancies
* Module dependencies
*/

@@ -14,3 +14,2 @@

, getActual = require('./getActual')
, inspect = require('./inspect')
, objDisplay = require('./objDisplay');

@@ -17,0 +16,0 @@

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

/*!
* Module dependancies
* Module dependencies
*/

@@ -11,0 +11,0 @@

@@ -108,3 +108,3 @@ // This is (almost) directly from Node.js utils

// Some type of object without properties can be shortcutted.
// Some type of object without properties can be shortcut.
// In IE, errors have a single `stack` property, or if they are vanilla `Error`,

@@ -200,3 +200,2 @@ // a `stack` plus `description` property; ignore those for consistency.

function formatPrimitive(ctx, value) {

@@ -231,3 +230,2 @@ switch (typeof value) {

function formatError(value) {

@@ -237,3 +235,2 @@ return '[' + Error.prototype.toString.call(value) + ']';

function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {

@@ -341,8 +338,4 @@ var output = [];

function reduceToSingleString(output, base, braces) {
var numLinesEst = 0;
var length = output.reduce(function(prev, cur) {
numLinesEst++;
if (cur.indexOf('\n') >= 0) numLinesEst++;
return prev + cur.length + 1;

@@ -349,0 +342,0 @@ }, 0);

@@ -21,5 +21,5 @@ var config = require('../config');

module.exports = function isProxyEnabled() {
return config.useProxy &&
return config.useProxy &&
typeof Proxy !== 'undefined' &&
typeof Reflect !== 'undefined';
};

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

/*!
* Module dependancies
* Module dependencies
*/

@@ -11,0 +11,0 @@

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

*
* Overwites an already existing chainable method
* Overwrites an already existing chainable method
* and provides access to the previous function or

@@ -16,0 +16,0 @@ * property. Must return functions to be used for

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

*
* Overwites an already existing method and provides
* Overwrites an already existing method and provides
* access to previous function. Must return function

@@ -19,0 +19,0 @@ * to be used for name.

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

*
* Overwites an already existing property getter and provides
* Overwrites an already existing property getter and provides
* access to previous value. Must return function to use as getter.

@@ -18,0 +18,0 @@ *

@@ -21,3 +21,3 @@ var config = require('../config');

* method prior to reading the non-existent property.
*
*
* If proxies are unsupported or disabled via the user's Chai config, then

@@ -53,15 +53,27 @@ * return object without modification.

var orderedProperties = getProperties(target).filter(function(property) {
return !Object.prototype.hasOwnProperty(property) &&
builtins.indexOf(property) === -1;
}).sort(function(a, b) {
return stringDistance(property, a) - stringDistance(property, b);
// If the property is reasonably close to an existing Chai property,
// suggest that property to the user. Only suggest properties with a
// distance less than 4.
var suggestion = null;
var suggestionDistance = 4;
getProperties(target).forEach(function(prop) {
if (
!Object.prototype.hasOwnProperty(prop) &&
builtins.indexOf(prop) === -1
) {
var dist = stringDistanceCapped(
property,
prop,
suggestionDistance
);
if (dist < suggestionDistance) {
suggestion = prop;
suggestionDistance = dist;
}
}
});
if (orderedProperties.length &&
stringDistance(orderedProperties[0], property) < 4) {
// If the property is reasonably close to an existing Chai property,
// suggest that property to the user.
if (suggestion !== null) {
throw Error('Invalid Chai property: ' + property +
'. Did you mean "' + orderedProperties[0] + '"?');
'. Did you mean "' + suggestion + '"?');
} else {

@@ -94,30 +106,40 @@ throw Error('Invalid Chai property: ' + property);

/**
* # stringDistance(strA, strB)
* Return the Levenshtein distance between two strings.
* # stringDistanceCapped(strA, strB, cap)
* Return the Levenshtein distance between two strings, but no more than cap.
* @param {string} strA
* @param {string} strB
* @return {number} the string distance between strA and strB
* @param {number} number
* @return {number} min(string distance between strA and strB, cap)
* @api private
*/
function stringDistance(strA, strB, memo) {
if (!memo) {
// `memo` is a two-dimensional array containing a cache of distances
// memo[i][j] is the distance between strA.slice(0, i) and
// strB.slice(0, j).
memo = [];
for (var i = 0; i <= strA.length; i++) {
memo[i] = [];
}
function stringDistanceCapped(strA, strB, cap) {
if (Math.abs(strA.length - strB.length) >= cap) {
return cap;
}
if (!memo[strA.length] || !memo[strA.length][strB.length]) {
if (strA.length === 0 || strB.length === 0) {
memo[strA.length][strB.length] = Math.max(strA.length, strB.length);
} else {
memo[strA.length][strB.length] = Math.min(
stringDistance(strA.slice(0, -1), strB, memo) + 1,
stringDistance(strA, strB.slice(0, -1), memo) + 1,
stringDistance(strA.slice(0, -1), strB.slice(0, -1), memo) +
(strA.slice(-1) === strB.slice(-1) ? 0 : 1)
var memo = [];
// `memo` is a two-dimensional array containing distances.
// memo[i][j] is the distance between strA.slice(0, i) and
// strB.slice(0, j).
for (var i = 0; i <= strA.length; i++) {
memo[i] = Array(strB.length + 1).fill(0);
memo[i][0] = i;
}
for (var j = 0; j < strB.length; j++) {
memo[0][j] = j;
}
for (var i = 1; i <= strA.length; i++) {
var ch = strA.charCodeAt(i - 1);
for (var j = 1; j <= strB.length; j++) {
if (Math.abs(i - j) >= cap) {
memo[i][j] = cap;
continue;
}
memo[i][j] = Math.min(
memo[i - 1][j] + 1,
memo[i][j - 1] + 1,
memo[i - 1][j - 1] +
(ch === strB.charCodeAt(j - 1) ? 0 : 1)
);

@@ -124,0 +146,0 @@ }

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

/*!
* Module dependancies
* Module dependencies
*/

@@ -11,0 +11,0 @@

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

*
* var anotherAsseriton = new Assertion(myObj);
* var anotherAssertion = new Assertion(myObj);
* utils.transferFlags(assertion, anotherAssertion, false);

@@ -22,0 +22,0 @@ *

@@ -20,3 +20,3 @@ {

],
"version": "4.1.2",
"version": "4.2.0",
"repository": {

@@ -37,20 +37,21 @@ "type": "git",

"dependencies": {
"assertion-error": "^1.0.1",
"check-error": "^1.0.1",
"deep-eql": "^3.0.0",
"assertion-error": "^1.1.0",
"check-error": "^1.0.2",
"deep-eql": "^3.0.1",
"get-func-name": "^2.0.0",
"pathval": "^1.0.0",
"type-detect": "^4.0.0"
"pathval": "^1.1.0",
"type-detect": "^4.0.5"
},
"devDependencies": {
"browserify": "^14.4.0",
"browserify": "^16.0.0",
"bump-cli": "^1.1.3",
"codecov": "^3.0.0",
"istanbul": "^0.4.3",
"karma": "^1.0.0",
"karma": "^2.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.0.1",
"karma-phantomjs-launcher": "^1.0.0",
"karma-sauce-launcher": "^1.0.0",
"mocha": "^3.0.0"
"karma-sauce-launcher": "^1.2.0",
"mocha": "^5.0.0"
}
}

@@ -26,3 +26,3 @@ <h1 align=center>

</a>
<a href="https://www.npmjs.com/packages/chai">
<a href="https://www.npmjs.com/package/chai">
<img

@@ -53,6 +53,6 @@ alt="node:?"

</a>
<a href="https://coveralls.io/r/chaijs/chai">
<a href="https://codecov.io/gh/chaijs/chai">
<img
alt="coverage:?"
src="https://img.shields.io/coveralls/chaijs/chai/master.svg?style=flat-square"
src="https://img.shields.io/codecov/c/github/chaijs/chai.svg?style=flat-square"
/>

@@ -91,3 +91,3 @@ </a>

Chai is an _assertion library_, similar to Node's build in `assert`. It makes testing much easier by giving you lots of assertions you can run against your code.
Chai is an _assertion library_, similar to Node's built-in `assert`. It makes testing much easier by giving you lots of assertions you can run against your code.

@@ -94,0 +94,0 @@ ## Installation

@@ -27,11 +27,2 @@

/*!
* Opera
*/
exports['SL_Opera'] = {
base: 'SauceLabs'
, browserName: 'opera'
};
/*!
* Internet Explorer

@@ -38,0 +29,0 @@ */

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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