New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@dmail/assert

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dmail/assert - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

90

dist/browser/main.js

@@ -284,9 +284,9 @@ System.register([], function (exports, module) {

if (comparison.failed) return false;
comparePropertiesDescriptors(comparison);
if (comparison.failed) return false;
compareProperties(comparison);
if (comparison.failed) return false;
compareSymbolsDescriptors(comparison);
if (comparison.failed) return false;
compareSymbols(comparison);
if (comparison.failed) return false;
comparePropertiesDescriptors(comparison);
if (comparison.failed) return false;
compareSymbolsDescriptors(comparison);
if (comparison.failed) return false; // always keep this one after properties because we must first ensure

@@ -433,3 +433,5 @@ // valueOf is on both actual and expected

comparer: function comparer() {
return actualPropertyNames.join("") === expectedPropertyNames.join("");
return expectedPropertyNames.every(function (name, index) {
return name === actualPropertyNames[index];
});
}

@@ -466,2 +468,13 @@ });

});
if (comparison.failed) return;
subcompare(comparison, {
type: "symbols-order",
actual: actualSymbols,
expected: expectedSymbols,
comparer: function comparer() {
return expectedSymbols.every(function (symbol, index) {
return symbol === actualSymbols[index];
});
}
});
};

@@ -532,2 +545,3 @@

var actualDescriptor = Object.getOwnPropertyDescriptor(actual, property);
if (!actualDescriptor) return;
var configurableComparison = subcompare(comparison, {

@@ -1178,3 +1192,3 @@ type: "property-configurable",

var propertyNameToDotNotationAllowed = function propertyNameToDotNotationAllowed(propertyName) {
return /^[a-z_$]+[0-9a-z_&]$/i.test(propertyName);
return /^[a-z_$]+[0-9a-z_&]$/i.test(propertyName) || /^[a-z_$]$/i.test(propertyName);
};

@@ -1368,3 +1382,3 @@

var defaultComparisonToErrorMessage = function defaultComparisonToErrorMessage(comparison) {
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);
var expectedValue = valueToString(comparison.expected);

@@ -1392,3 +1406,3 @@ var actualValue = valueToString(comparison.actual);

var isExtra = !expected && actual;
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);

@@ -1457,3 +1471,3 @@ if (isExtra) {

var rootComparison = comparisonToRootComparison(comparison);
var path = comparisonToPath(prototypeComparison, "actual");
var path = comparisonToPath(prototypeComparison);

@@ -1514,17 +1528,19 @@ var prototypeToString = function prototypeToString(prototype) {

if (comparison.type !== "properties") return undefined;
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);
var extra = comparison.actual.extra;
var missing = comparison.actual.missing;
var hasExtra = extra.length > 0;
var hasMissing = missing.length > 0;
if (extra && !missing) {
if (hasExtra && !hasMissing) {
return createUnexpectedPropertiesMessage({
path: path,
unexpectedProperties: uneval(extra)
unexpectedProperties: propertyNameArrayToString(extra)
});
}
if (missing && !extra) {
if (!hasExtra && hasMissing) {
return createMissingPropertiesMessage({
path: path,
missingProperties: uneval(missing)
missingProperties: propertyNameArrayToString(missing)
});

@@ -1535,4 +1551,4 @@ }

path: path,
unexpectedProperties: uneval(extra),
missingProperties: uneval(missing)
unexpectedProperties: propertyNameArrayToString(extra),
missingProperties: propertyNameArrayToString(missing)
});

@@ -1544,3 +1560,3 @@ };

unexpectedProperties = _ref.unexpectedProperties;
return "unexpected properties.\n--- path ---\n".concat(path, "\n--- unexpected properties ---\n").concat(unexpectedProperties);
return "unexpected properties.\n--- path ---\n".concat(path, "\n--- unexpected property names ---\n").concat(unexpectedProperties.join("\n"));
};

@@ -1551,3 +1567,3 @@

missingProperties = _ref2.missingProperties;
return "missing properties.\n--- path ---\n".concat(path, "\n--- missing properties ---\n").concat(missingProperties);
return "missing properties.\n--- path ---\n".concat(path, "\n--- missing property names ---\n").concat(missingProperties.join("\n"));
};

@@ -1559,8 +1575,14 @@

missingProperties = _ref3.missingProperties;
return "unexpected and missing properties.\n--- path ---\n".concat(path, "\n--- unexpected properties ---\n").concat(unexpectedProperties, "\n--- missing properties ---\n").concat(missingProperties);
return "unexpected and missing properties.\n--- path ---\n".concat(path, "\n--- unexpected property names ---\n").concat(unexpectedProperties.join("\n"), "\n--- missing property names ---\n").concat(missingProperties.join("\n"));
};
var propertyNameArrayToString = function propertyNameArrayToString(propertyNameArray) {
return propertyNameArray.map(function (propertyName) {
return uneval(propertyName);
});
};
var propertiesOrderComparisonToErrorMessage = function propertiesOrderComparisonToErrorMessage(comparison) {
if (comparison.type !== "properties-order") return undefined;
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);
var expected = comparison.expected;

@@ -1584,17 +1606,19 @@ var actual = comparison.actual;

if (comparison.type !== "symbols") return undefined;
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);
var extra = comparison.actual.extra;
var missing = comparison.actual.missing;
var hasExtra = extra.length > 0;
var hasMissing = missing.length > 0;
if (extra && !missing) {
if (hasExtra && !hasMissing) {
return createUnexpectedSymbolsMessage({
path: path,
unexpectedSymbols: uneval(extra)
unexpectedSymbols: symbolArrayToString(extra)
});
}
if (missing && !extra) {
if (!hasExtra && hasMissing) {
return createMissingSymbolsMessage({
path: path,
missingSymbols: uneval(missing)
missingSymbols: symbolArrayToString(missing)
});

@@ -1605,4 +1629,4 @@ }

path: path,
unexpectedSymbols: uneval(extra),
missingSymbols: uneval(missing)
unexpectedSymbols: symbolArrayToString(extra),
missingSymbols: symbolArrayToString(missing)
});

@@ -1614,3 +1638,3 @@ };

unexpectedSymbols = _ref.unexpectedSymbols;
return "unexpected symbols.\n--- path ---\n".concat(path, "\n--- unexpected symbols ---\n").concat(unexpectedSymbols);
return "unexpected symbols.\n--- path ---\n".concat(path, "\n--- unexpected symbol list ---\n").concat(unexpectedSymbols.join("\n"));
};

@@ -1621,3 +1645,3 @@

missingSymbols = _ref2.missingSymbols;
return "missing symbols.\n--- path ---\n".concat(path, "\n--- missing symbols ---\n").concat(missingSymbols);
return "missing symbols.\n--- path ---\n".concat(path, "\n--- missing symbol list ---\n").concat(missingSymbols.join("\n"));
};

@@ -1629,5 +1653,11 @@

missingSymbols = _ref3.missingSymbols;
return "unexpected and missing symbols.\n--- path ---\n".concat(path, "\n--- unexpected symbols ---\n").concat(unexpectedSymbols, "\n--- missing symbols ---\n").concat(missingSymbols);
return "unexpected and missing symbols.\n--- path ---\n".concat(path, "\n--- unexpected symbol list ---\n").concat(unexpectedSymbols.join("\n"), "\n--- missing symbol list ---\n").concat(missingSymbols.join("\n"));
};
var symbolArrayToString = function symbolArrayToString(symbolArray) {
return symbolArray.map(function (symbol) {
return uneval(symbol);
});
};
var comparisonToErrorMessage = function comparisonToErrorMessage(comparison) {

@@ -1634,0 +1664,0 @@ var failedComparison = deepestComparison(comparison);

@@ -280,9 +280,9 @@ 'use strict';

if (comparison.failed) return false;
comparePropertiesDescriptors(comparison);
if (comparison.failed) return false;
compareProperties(comparison);
if (comparison.failed) return false;
compareSymbolsDescriptors(comparison);
if (comparison.failed) return false;
compareSymbols(comparison);
if (comparison.failed) return false;
comparePropertiesDescriptors(comparison);
if (comparison.failed) return false;
compareSymbolsDescriptors(comparison);
if (comparison.failed) return false; // always keep this one after properties because we must first ensure

@@ -429,3 +429,5 @@ // valueOf is on both actual and expected

comparer: function comparer() {
return actualPropertyNames.join("") === expectedPropertyNames.join("");
return expectedPropertyNames.every(function (name, index) {
return name === actualPropertyNames[index];
});
}

@@ -462,2 +464,13 @@ });

});
if (comparison.failed) return;
subcompare(comparison, {
type: "symbols-order",
actual: actualSymbols,
expected: expectedSymbols,
comparer: function comparer() {
return expectedSymbols.every(function (symbol, index) {
return symbol === actualSymbols[index];
});
}
});
};

@@ -528,2 +541,3 @@

var actualDescriptor = Object.getOwnPropertyDescriptor(actual, property);
if (!actualDescriptor) return;
var configurableComparison = subcompare(comparison, {

@@ -1171,3 +1185,3 @@ type: "property-configurable",

var propertyNameToDotNotationAllowed = function propertyNameToDotNotationAllowed(propertyName) {
return /^[a-z_$]+[0-9a-z_&]$/i.test(propertyName);
return /^[a-z_$]+[0-9a-z_&]$/i.test(propertyName) || /^[a-z_$]$/i.test(propertyName);
};

@@ -1359,3 +1373,3 @@

var defaultComparisonToErrorMessage = function defaultComparisonToErrorMessage(comparison) {
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);
var expectedValue = valueToString(comparison.expected);

@@ -1383,3 +1397,3 @@ var actualValue = valueToString(comparison.actual);

var isExtra = !expected && actual;
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);

@@ -1448,3 +1462,3 @@ if (isExtra) {

var rootComparison = comparisonToRootComparison(comparison);
var path = comparisonToPath(prototypeComparison, "actual");
var path = comparisonToPath(prototypeComparison);

@@ -1505,17 +1519,19 @@ var prototypeToString = function prototypeToString(prototype) {

if (comparison.type !== "properties") return undefined;
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);
var extra = comparison.actual.extra;
var missing = comparison.actual.missing;
var hasExtra = extra.length > 0;
var hasMissing = missing.length > 0;
if (extra && !missing) {
if (hasExtra && !hasMissing) {
return createUnexpectedPropertiesMessage({
path: path,
unexpectedProperties: uneval(extra)
unexpectedProperties: propertyNameArrayToString(extra)
});
}
if (missing && !extra) {
if (!hasExtra && hasMissing) {
return createMissingPropertiesMessage({
path: path,
missingProperties: uneval(missing)
missingProperties: propertyNameArrayToString(missing)
});

@@ -1526,4 +1542,4 @@ }

path: path,
unexpectedProperties: uneval(extra),
missingProperties: uneval(missing)
unexpectedProperties: propertyNameArrayToString(extra),
missingProperties: propertyNameArrayToString(missing)
});

@@ -1535,3 +1551,3 @@ };

unexpectedProperties = _ref.unexpectedProperties;
return "unexpected properties.\n--- path ---\n".concat(path, "\n--- unexpected properties ---\n").concat(unexpectedProperties);
return "unexpected properties.\n--- path ---\n".concat(path, "\n--- unexpected property names ---\n").concat(unexpectedProperties.join("\n"));
};

@@ -1542,3 +1558,3 @@

missingProperties = _ref2.missingProperties;
return "missing properties.\n--- path ---\n".concat(path, "\n--- missing properties ---\n").concat(missingProperties);
return "missing properties.\n--- path ---\n".concat(path, "\n--- missing property names ---\n").concat(missingProperties.join("\n"));
};

@@ -1550,8 +1566,14 @@

missingProperties = _ref3.missingProperties;
return "unexpected and missing properties.\n--- path ---\n".concat(path, "\n--- unexpected properties ---\n").concat(unexpectedProperties, "\n--- missing properties ---\n").concat(missingProperties);
return "unexpected and missing properties.\n--- path ---\n".concat(path, "\n--- unexpected property names ---\n").concat(unexpectedProperties.join("\n"), "\n--- missing property names ---\n").concat(missingProperties.join("\n"));
};
var propertyNameArrayToString = function propertyNameArrayToString(propertyNameArray) {
return propertyNameArray.map(function (propertyName) {
return uneval(propertyName);
});
};
var propertiesOrderComparisonToErrorMessage = function propertiesOrderComparisonToErrorMessage(comparison) {
if (comparison.type !== "properties-order") return undefined;
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);
var expected = comparison.expected;

@@ -1575,17 +1597,19 @@ var actual = comparison.actual;

if (comparison.type !== "symbols") return undefined;
var path = comparisonToPath(comparison, "actual");
var path = comparisonToPath(comparison);
var extra = comparison.actual.extra;
var missing = comparison.actual.missing;
var hasExtra = extra.length > 0;
var hasMissing = missing.length > 0;
if (extra && !missing) {
if (hasExtra && !hasMissing) {
return createUnexpectedSymbolsMessage({
path: path,
unexpectedSymbols: uneval(extra)
unexpectedSymbols: symbolArrayToString(extra)
});
}
if (missing && !extra) {
if (!hasExtra && hasMissing) {
return createMissingSymbolsMessage({
path: path,
missingSymbols: uneval(missing)
missingSymbols: symbolArrayToString(missing)
});

@@ -1596,4 +1620,4 @@ }

path: path,
unexpectedSymbols: uneval(extra),
missingSymbols: uneval(missing)
unexpectedSymbols: symbolArrayToString(extra),
missingSymbols: symbolArrayToString(missing)
});

@@ -1605,3 +1629,3 @@ };

unexpectedSymbols = _ref.unexpectedSymbols;
return "unexpected symbols.\n--- path ---\n".concat(path, "\n--- unexpected symbols ---\n").concat(unexpectedSymbols);
return "unexpected symbols.\n--- path ---\n".concat(path, "\n--- unexpected symbol list ---\n").concat(unexpectedSymbols.join("\n"));
};

@@ -1612,3 +1636,3 @@

missingSymbols = _ref2.missingSymbols;
return "missing symbols.\n--- path ---\n".concat(path, "\n--- missing symbols ---\n").concat(missingSymbols);
return "missing symbols.\n--- path ---\n".concat(path, "\n--- missing symbol list ---\n").concat(missingSymbols.join("\n"));
};

@@ -1620,5 +1644,11 @@

missingSymbols = _ref3.missingSymbols;
return "unexpected and missing symbols.\n--- path ---\n".concat(path, "\n--- unexpected symbols ---\n").concat(unexpectedSymbols, "\n--- missing symbols ---\n").concat(missingSymbols);
return "unexpected and missing symbols.\n--- path ---\n".concat(path, "\n--- unexpected symbol list ---\n").concat(unexpectedSymbols.join("\n"), "\n--- missing symbol list ---\n").concat(missingSymbols.join("\n"));
};
var symbolArrayToString = function symbolArrayToString(symbolArray) {
return symbolArray.map(function (symbol) {
return uneval(symbol);
});
};
var comparisonToErrorMessage = function comparisonToErrorMessage(comparison) {

@@ -1625,0 +1655,0 @@ var failedComparison = deepestComparison(comparison);

{
"name": "@dmail/assert",
"version": "3.3.0",
"version": "3.4.0",
"license": "MIT",

@@ -24,3 +24,3 @@ "repository": {

"devDependencies": {
"@jsenv/core": "5.23.0",
"@jsenv/core": "5.25.0",
"@jsenv/codecov-upload": "1.2.0",

@@ -27,0 +27,0 @@ "@jsenv/eslint-config": "8.0.0",

@@ -11,25 +11,8 @@ # assert

```js
import { assert } from "@dmail/assert"
Live browser example: https://dmail.github.io/assert/#browser-example.
const actual = { foo: true }
const expected = { foo: false }
assert({
actual,
expected,
})
```
Live node example: https://dmail.github.io/assert/#node-example
Terminal output screenshot:
![terminal output screenshot](./doc/example-terminal-output-screenshot.png)
You can also check [test/](./test) folder for more examples
## Installing
Not supported: Made only for my usage for now.
## Licensing
MIT

@@ -96,12 +96,12 @@ /* eslint-disable no-use-before-define */

compareProperties(comparison)
comparePropertiesDescriptors(comparison)
if (comparison.failed) return false
compareSymbols(comparison)
compareProperties(comparison)
if (comparison.failed) return false
comparePropertiesDescriptors(comparison)
compareSymbolsDescriptors(comparison)
if (comparison.failed) return false
compareSymbolsDescriptors(comparison)
compareSymbols(comparison)
if (comparison.failed) return false

@@ -213,4 +213,4 @@

})
if (comparison.failed) return
if (comparison.failed) return
subcompare(comparison, {

@@ -220,3 +220,4 @@ type: "properties-order",

expected: expectedPropertyNames,
comparer: () => actualPropertyNames.join("") === expectedPropertyNames.join(""),
comparer: () =>
expectedPropertyNames.every((name, index) => name === actualPropertyNames[index]),
})

@@ -241,2 +242,10 @@ }

})
if (comparison.failed) return
subcompare(comparison, {
type: "symbols-order",
actual: actualSymbols,
expected: expectedSymbols,
comparer: () => expectedSymbols.every((symbol, index) => symbol === actualSymbols[index]),
})
}

@@ -267,2 +276,3 @@

const actualDescriptor = Object.getOwnPropertyDescriptor(actual, property)
if (!actualDescriptor) return

@@ -269,0 +279,0 @@ const configurableComparison = subcompare(comparison, {

export const propertyNameToDotNotationAllowed = (propertyName) => {
return /^[a-z_$]+[0-9a-z_&]$/i.test(propertyName)
return /^[a-z_$]+[0-9a-z_&]$/i.test(propertyName) || /^[a-z_$]$/i.test(propertyName)
}

@@ -5,3 +5,3 @@ import { comparisonToPath } from "../comparisonToPath.js"

export const defaultComparisonToErrorMessage = (comparison) => {
const path = comparisonToPath(comparison, "actual")
const path = comparisonToPath(comparison)
const expectedValue = valueToString(comparison.expected)

@@ -8,0 +8,0 @@ const actualValue = valueToString(comparison.actual)

@@ -1,2 +0,2 @@

import { uneval } from "/node_modules/@dmail/uneval/index.js"
import { uneval } from "@dmail/uneval"
import { comparisonToPath } from "../comparisonToPath.js"

@@ -7,15 +7,20 @@

const path = comparisonToPath(comparison, "actual")
const path = comparisonToPath(comparison)
const extra = comparison.actual.extra
const missing = comparison.actual.missing
const hasExtra = extra.length > 0
const hasMissing = missing.length > 0
if (extra && !missing) {
if (hasExtra && !hasMissing) {
return createUnexpectedPropertiesMessage({
path,
unexpectedProperties: uneval(extra),
unexpectedProperties: propertyNameArrayToString(extra),
})
}
if (missing && !extra) {
return createMissingPropertiesMessage({ path, missingProperties: uneval(missing) })
if (!hasExtra && hasMissing) {
return createMissingPropertiesMessage({
path,
missingProperties: propertyNameArrayToString(missing),
})
}

@@ -25,4 +30,4 @@

path,
unexpectedProperties: uneval(extra),
missingProperties: uneval(missing),
unexpectedProperties: propertyNameArrayToString(extra),
missingProperties: propertyNameArrayToString(missing),
})

@@ -37,4 +42,5 @@ }

${path}
--- unexpected properties ---
${unexpectedProperties}`
--- unexpected property names ---
${unexpectedProperties.join(`
`)}`

@@ -44,4 +50,5 @@ const createMissingPropertiesMessage = ({ path, missingProperties }) => `missing properties.

${path}
--- missing properties ---
${missingProperties}`
--- missing property names ---
${missingProperties.join(`
`)}`

@@ -55,5 +62,11 @@ const createUnexpectedAndMissingPropertiesMessage = ({

${path}
--- unexpected properties ---
${unexpectedProperties}
--- missing properties ---
${missingProperties}`
--- unexpected property names ---
${unexpectedProperties.join(`
`)}
--- missing property names ---
${missingProperties.join(`
`)}`
const propertyNameArrayToString = (propertyNameArray) => {
return propertyNameArray.map((propertyName) => uneval(propertyName))
}

@@ -7,3 +7,3 @@ import { uneval } from "/node_modules/@dmail/uneval/index.js"

const path = comparisonToPath(comparison, "actual")
const path = comparisonToPath(comparison)
const expected = comparison.expected

@@ -10,0 +10,0 @@ const actual = comparison.actual

@@ -11,3 +11,3 @@ import { uneval } from "/node_modules/@dmail/uneval/index.js"

const rootComparison = comparisonToRootComparison(comparison)
const path = comparisonToPath(prototypeComparison, "actual")
const path = comparisonToPath(prototypeComparison)
const prototypeToString = (prototype) => {

@@ -14,0 +14,0 @@ const wellKnown = valueToWellKnown(prototype)

@@ -10,3 +10,3 @@ import { comparisonToPath } from "../comparisonToPath.js"

const isExtra = !expected && actual
const path = comparisonToPath(comparison, "actual")
const path = comparisonToPath(comparison)

@@ -13,0 +13,0 @@ if (isExtra) {

@@ -1,2 +0,2 @@

import { uneval } from "/node_modules/@dmail/uneval/index.js"
import { uneval } from "@dmail/uneval"
import { comparisonToPath } from "../comparisonToPath.js"

@@ -7,12 +7,14 @@

const path = comparisonToPath(comparison, "actual")
const path = comparisonToPath(comparison)
const extra = comparison.actual.extra
const missing = comparison.actual.missing
const hasExtra = extra.length > 0
const hasMissing = missing.length > 0
if (extra && !missing) {
return createUnexpectedSymbolsMessage({ path, unexpectedSymbols: uneval(extra) })
if (hasExtra && !hasMissing) {
return createUnexpectedSymbolsMessage({ path, unexpectedSymbols: symbolArrayToString(extra) })
}
if (missing && !extra) {
return createMissingSymbolsMessage({ path, missingSymbols: uneval(missing) })
if (!hasExtra && hasMissing) {
return createMissingSymbolsMessage({ path, missingSymbols: symbolArrayToString(missing) })
}

@@ -22,4 +24,4 @@

path,
unexpectedSymbols: uneval(extra),
missingSymbols: uneval(missing),
unexpectedSymbols: symbolArrayToString(extra),
missingSymbols: symbolArrayToString(missing),
})

@@ -31,4 +33,5 @@ }

${path}
--- unexpected symbols ---
${unexpectedSymbols}`
--- unexpected symbol list ---
${unexpectedSymbols.join(`
`)}`

@@ -38,4 +41,5 @@ const createMissingSymbolsMessage = ({ path, missingSymbols }) => `missing symbols.

${path}
--- missing symbols ---
${missingSymbols}`
--- missing symbol list ---
${missingSymbols.join(`
`)}`

@@ -49,5 +53,11 @@ const createUnexpectedAndMissingSymbolsMessage = ({

${path}
--- unexpected symbols ---
${unexpectedSymbols}
--- missing symbols ---
${missingSymbols}`
--- unexpected symbol list ---
${unexpectedSymbols.join(`
`)}
--- missing symbol list ---
${missingSymbols.join(`
`)}`
const symbolArrayToString = (symbolArray) => {
return symbolArray.map((symbol) => uneval(symbol))
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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