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

fartest

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

fartest - npm Package Compare versions

Comparing version 2.1.3 to 2.1.4

inspect.js

50

deepEqual.js

@@ -0,1 +1,4 @@

import inspect from './inspect.js'
import chalk from 'chalk'
export const deepEqualResults = new class {

@@ -58,15 +61,21 @@ keys = []

for (const bValue of b) {
if (deepEqual(aValue, bValue, doneObjectComparisons))
if (deepEqual(aValue, bValue, doneObjectComparisons)) {
deepEqualResults.pop()
deepEqualResults.error = ""
continue nextFirstSetValue
}
}
return done(`Missing value '${aValue}' in the second set`)
return done(`Missing value ${inspect(aValue, false)} in the second set`)
}
nextSecondSetValue:
for (const aValue of b) {
for (const bValue of a) {
if (deepEqual(aValue, bValue, doneObjectComparisons))
for (const bValue of b) {
for (const aValue of a) {
if (deepEqual(aValue, bValue, doneObjectComparisons)) {
deepEqualResults.pop()
deepEqualResults.error = ""
continue nextSecondSetValue
}
}
return done(`Missing value '${bValue}' in the first set`)
return done(`Missing value ${inspect(bValue, false)} in the first set`)
}

@@ -77,11 +86,26 @@ }

for (const [key, value] of a.entries()) {
if (!b.has(key))
return done(`Key '${key}' is missing on the second map`)
if (!deepEqual(b.get(key), value, doneObjectComparisons, key))
return false
nextFirstMapValue:
for (const [keyA, valueA] of a.entries()) {
for (const [keyB, valueB] of b.entries()) {
if (deepEqual(keyA, keyB)) {
deepEqualResults.pop()
deepEqualResults.error = ""
if (!deepEqual(valueA, valueB))
return false
continue nextFirstMapValue
}
}
return done(`Key ${inspect(keyA, false)} is missing in the second map`)
}
for (const key of b.keys()) {
if (!a.has(key)) return done(`Key '${key}' is missing in the first map`)
nextSecondMapValue:
for (const keyB of b.keys()) {
for (const keyA of a.keys()) {
if (deepEqual(keyA, keyB)) {
deepEqualResults.pop()
deepEqualResults.error = ""
continue nextSecondMapValue
}
}
return done(`Key ${inspect(keyB, false)} is missing in the first map`)
}

@@ -88,0 +112,0 @@ }

@@ -10,13 +10,4 @@ /*-------------------------------------

import deepEqual, { deepEqualResults } from './deepEqual.js'
import util from 'util'
import inspect from './inspect.js'
const inspect = value => chalk.white(util.inspect(value, {
depth: 2,
maxStringLength: 20,
maxArrayLength: 3,
colors: true,
compact: true,
breakLength: Infinity,
}))
class Stage {

@@ -136,3 +127,3 @@ constructor(name) {

if (error) {
description += '\n ' + chalk.underline(`${error}`) + (key ? ` at key '${key}'` : '')
description += '\n ' + (`${error}`) + (key ? ` at key '${key}'` : '')
+ `:\n • ${inspect(a)}\n • ${inspect(b)}`

@@ -139,0 +130,0 @@ this.test(false, description)

{
"name": "fartest",
"version": "2.1.3",
"version": "2.1.4",
"type": "module",

@@ -5,0 +5,0 @@ "author": {

import start from './index'
start('Bold test', async function({stage, same}) {
let a: any = { }
a.self = a
a.z = {x: 12}
let b: any = { }
b.self = b
b.z = [11, 12, 11, 12, 11, 12, 11, 12, 11, 12]
same(a, b, "Circular reference")
start('Even test libraries should have tests', async function({stage, same, different}) {
stage('Numbers and strings')
same(5, 5)
different(5, "5")
same("5", "5")
stage('Objects')
const o = {x: 1, y: 2, z: 3}
same(o, {x: 1, y: 2, z: 3}, "Same simple objects")
same(o, {x: 1, z: 3, y: 2}, "Order does not matter")
different(o, {x: 1, y: 2}, "Missing key")
different(o, {x: 1, y: 2, z: 4}, "Different key value")
;(o as any).self = o
same(o, {x: 1, y: 2, z: 3, self: o}, "Same circular objects")
stage('Array')
same([1, 2, 3], [1, 2, 3], "Simple array equality")
different([1, 2, 3], [1, 3, 2], "Order in array is important")
stage('Set')
const set = new Set<any>([1, 2, 3])
same(set, new Set(set), "Simple set equality")
same(set, new Set([3, 2, 1]), "Reverse set equality")
different(set, new Set([2, 1]), "Should say '3' is missing in second set")
different(set, new Set([1, 2, 3, 4, 8]), "Should say '8' is missing in first set")
same(new Set([[1, 2, 3]]), new Set([[1, 2, 3]]), "Same deep equal values in set (array)")
different(new Set([[1, 2, 3]]), new Set([[1, 2]]), "Different deep equal values in set (array)")
same(new Set([{x: 1}, {y: 2, z: 3}]), new Set([{x: 1}, {y: 2, z: 3}]), "Same deep equal values in set (object)")
different(new Set([{x: 1}, {y: 2, z: 3}]), new Set([{x: 1}, {y: 2, z: 4}]), "Different deep equal values in set (object)")
stage('Map')
const mapA = new Map([
["foo", "foo"],
["bar", "bar"],
])
const mapB = new Map<Set<any>, string>()
mapB.set(set, "set")
same(mapA, new Map(mapA), "Simple map equality")
different(mapA, new Map([["foo", "foo"], ["bar", "bar!!!"]]), "Simple map difference")
same(mapB, new Map(mapB), "Same maps with objects as key")
different(mapB, new Map(), "Different maps with objects as key")
same(mapB, new Map([[new Set(set), 'set']]), "Same maps with deep same objects as keys")
different(mapB, new Map([[new Set(set), 'zut']]), "Different maps with deep same objects as keys but different values")
})
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