From 2b652fbdecced27d64c1abcc428015563c26bb44 Mon Sep 17 00:00:00 2001 From: ninevra Date: Thu, 15 Jul 2021 12:51:47 -0700 Subject: [PATCH 01/11] Test compare() with empty list slots --- test/compare.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/compare.js b/test/compare.js index e385978..bf8ce0d 100644 --- a/test/compare.js +++ b/test/compare.js @@ -66,3 +66,11 @@ test('arrays are also compared by property', t => { a4[-1] = -1 t.false(compare(a3, a4).pass) }) + +test('empty array slots do not equal undefined', t => { + t.false(compare(new Array(1), Array.from({ length: 1 })).pass) +}) + +test('empty arraylike slots do not equal undefined', t => { + t.false(compare({ length: 2, 0: 'a' }, { length: 2, 0: 'a', 1: undefined }).pass) +}) From 22c333d8ef41db4c2127867d69690d01889147b3 Mon Sep 17 00:00:00 2001 From: ninevra Date: Mon, 19 Jul 2021 13:26:32 -0700 Subject: [PATCH 02/11] Add an "empty primitive" descriptor --- lib/complexValues/object.js | 8 +++++++- lib/describe.js | 6 ++++++ lib/primitiveValues/empty.js | 32 ++++++++++++++++++++++++++++++++ lib/themeUtils.js | 1 + 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 lib/primitiveValues/empty.js diff --git a/lib/complexValues/object.js b/lib/complexValues/object.js index d4e904c..dfb7558 100644 --- a/lib/complexValues/object.js +++ b/lib/complexValues/object.js @@ -76,6 +76,7 @@ function DescribedMixin (base) { this.value = props.value this.describeAny = props.describeAny + this.describeEmpty = props.describeEmpty this.describeItem = props.describeItem this.describeMapEntry = props.describeMapEntry this.describeProperty = props.describeProperty @@ -119,7 +120,12 @@ function DescribedMixin (base) { const current = index index++ - return this.describeItem(current, this.describeAny(this.value[current])) + + if (current in this.value) { + return this.describeItem(current, this.describeAny(this.value[current])) + } else { + return this.describeItem(current, this.describeEmpty()) + } } return { size, next } diff --git a/lib/describe.js b/lib/describe.js index 944e08e..71c68ca 100644 --- a/lib/describe.js +++ b/lib/describe.js @@ -25,6 +25,7 @@ const propertyDescriptor = require('./metaDescriptors/property') const pluginRegistry = require('./pluginRegistry') const bigIntValue = require('./primitiveValues/bigInt') const booleanValue = require('./primitiveValues/boolean') +const emptyValue = require('./primitiveValues/empty') const nullValue = require('./primitiveValues/null') const numberValue = require('./primitiveValues/number') const stringValue = require('./primitiveValues/string') @@ -55,6 +56,10 @@ const SpecializedComplexes = new Map([ ['Uint8ClampedArray', typedArrayValue.describe], ]) +function describeEmpty () { + return emptyValue.describe() +} + function describePrimitive (value) { if (value === null) return nullValue.describe() if (value === undefined) return undefinedValue.describe() @@ -120,6 +125,7 @@ function describeComplex (value, registry, tryPlugins, describeAny, describeItem const descriptor = describeValue({ ctor, describeAny, + describeEmpty, describeItem, describeMapEntry, describeProperty, diff --git a/lib/primitiveValues/empty.js b/lib/primitiveValues/empty.js new file mode 100644 index 0000000..5bb9d48 --- /dev/null +++ b/lib/primitiveValues/empty.js @@ -0,0 +1,32 @@ +'use strict' + +const constants = require('../constants') +const formatUtils = require('../formatUtils') +const lineBuilder = require('../lineBuilder') + +const DEEP_EQUAL = constants.DEEP_EQUAL +const UNEQUAL = constants.UNEQUAL + +function describe () { + return new EmptyValue() +} +exports.describe = describe + +exports.deserialize = describe + +const tag = Symbol('EmptyValue') +exports.tag = tag + +class EmptyValue { + compare (expected) { + return expected.tag === tag + ? DEEP_EQUAL + : UNEQUAL + } + + formatDeep (theme) { + return lineBuilder.single(formatUtils.wrap(theme.empty, '')) + } +} +Object.defineProperty(EmptyValue.prototype, 'isPrimitive', { value: true }) +Object.defineProperty(EmptyValue.prototype, 'tag', { value: tag }) diff --git a/lib/themeUtils.js b/lib/themeUtils.js index 871c19d..46c7e6d 100644 --- a/lib/themeUtils.js +++ b/lib/themeUtils.js @@ -35,6 +35,7 @@ const defaultTheme = freezeTheme({ expected: '+ ', padding: ' ', }, + empty: { open: '', close: '' }, error: { ctor: { open: '(', close: ')' }, name: { open: '', close: '' }, From ff9314d0454a466343fc9f02f5b9958b8b01ee29 Mon Sep 17 00:00:00 2001 From: ninevra Date: Mon, 19 Jul 2021 13:27:50 -0700 Subject: [PATCH 03/11] Correct existing sparse array tests --- test/lodash-isequal-comparison.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lodash-isequal-comparison.js b/test/lodash-isequal-comparison.js index 2290e91..4a09b5e 100644 --- a/test/lodash-isequal-comparison.js +++ b/test/lodash-isequal-comparison.js @@ -82,7 +82,7 @@ test('compare arrays', t => { array2[1] = undefined array2[2] = 3 - t.true(isEqual(array1, array2)) + t.false(isEqual(array1, array2)) array1 = [new Object(1), false, new Object('a'), /x/, new Date(2012, 4, 23), ['a', 'b', [new Object('c')]], { a: 1 }] array2 = [1, new Object(false), 'a', /x/, new Date(2012, 4, 23), ['a', new Object('b'), ['c']], { a: 1 }] @@ -132,7 +132,7 @@ test('compare sparse arrays', t => { const array = new Array(1) t.true(isEqual(array, new Array(1))) - t.true(isEqual(array, [undefined])) + t.false(isEqual(array, [undefined])) t.false(isEqual(array, new Array(2))) }) From ddf8e8e75787b370d0fe0742380ca6f570465728 Mon Sep 17 00:00:00 2001 From: ninevra Date: Mon, 19 Jul 2021 13:42:01 -0700 Subject: [PATCH 04/11] Test formatting and diffing sparse arrays --- test/diff.js | 8 ++++++++ test/format.js | 9 +++++++++ test/snapshots/diff.js.md | 23 +++++++++++++++++++++++ test/snapshots/diff.js.snap | Bin 5492 -> 5591 bytes test/snapshots/format.js.md | 18 ++++++++++++++++++ test/snapshots/format.js.snap | Bin 4650 -> 4721 bytes 6 files changed, 58 insertions(+) diff --git a/test/diff.js b/test/diff.js index 30f1d81..67e77cf 100644 --- a/test/diff.js +++ b/test/diff.js @@ -566,3 +566,11 @@ test('diff pointers hidden behind maxDepth', t => { concordance.diffDescriptors(concordance.deserialize(serialized), concordance.describe(undefined), { maxDepth: 1 }) }) }) + +test('diffs sparse arrays', t => { + t.snapshot(diff(new Array(3), Array.from({ length: 3 }))) + + const array = new Array(3) + array[1] = undefined + t.snapshot(diff(array, Array.from({ length: 3 }))) +}) diff --git a/test/format.js b/test/format.js index 9549b1e..0e40791 100644 --- a/test/format.js +++ b/test/format.js @@ -467,3 +467,12 @@ test('format pointers hidden behind maxDepth', t => { concordance.formatDescriptor(concordance.deserialize(serialized), { maxDepth: 1 }) }) }) + +test('formats sparse arrays', t => { + const array1 = new Array(3) + t.snapshot(format(array1)) + + const array2 = new Array(3) + array2[1] = undefined + t.snapshot(format(array2)) +}) diff --git a/test/snapshots/diff.js.md b/test/snapshots/diff.js.md index 8df31a4..0e6cf7f 100644 --- a/test/snapshots/diff.js.md +++ b/test/snapshots/diff.js.md @@ -1253,3 +1253,26 @@ Generated by [AVA](https://avajs.dev). %diffGutters.actual#- % e%property.separator#: %%object.ctor.open%Object%object.ctor.close% %object.openBracket#{% %maxDepth#…% %object.closeBracket#}%%property.after#,%␊ %diffGutters.actual#- % %object.closeBracket#}%%property.after#,%␊ %diffGutters.padding# %%object.closeBracket#}%` + +## diffs sparse arrays + +> Snapshot 1 + + `%diffGutters.padding# %%list.openBracket#[%␊ + %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ + %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ + %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ + %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ + %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ + %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ + %diffGutters.padding# %%list.closeBracket#]%` + +> Snapshot 2 + + `%diffGutters.padding# %%list.openBracket#[%␊ + %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ + %diffGutters.padding# % %undefined.open%undefined%undefined.close%%item.after#,%␊ + %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ + %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ + %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ + %diffGutters.padding# %%list.closeBracket#]%` diff --git a/test/snapshots/diff.js.snap b/test/snapshots/diff.js.snap index 42c8b924281743acd3975b6b98968517d67c6355..ccf00017f56f54ae108a4313a6498d8b98df24bc 100644 GIT binary patch delta 5588 zcmV;_6)WoWD%UH2K~_N^Q*L2!b7*gLAa*he0st08uhv?s^%dOT6m_N(6>uMm2mk;8 z00003?L7&26h+q6lVC({L_lOsFb)gRgpfc&xFiXn;Sf233t5iNq!T905qf$s;ZmY5 ztOBwUSFXSUDhd%~cUctJxQYk@tH`DNEOPmSe1d=?t{}L7ovtKI&-7K()iXUa?dSWL zyzZ*5epkJ!_v&@0I|0Z5M4M-x8n9;3v4Llnl;^&mvy1>W|21a+i8*@W?k;x^{qSG+ ztm(cdA$L|3hdmPoVQ~zEibeq3+2+vpn7LJ_o@_m7RqIaQw~peljhjMP(gMP+R_vXF zFAPao|MTa6A1?mtz;7-+kwb9Uz4rjn@NZ{xjvZM{{?fQScI?LYQX6vE#cd$0yBETs z`ygCs525gW2q$A9{H+6oQJo>sNdPq8(A7DAdFE_;MUKllVd>In4!gb!gddY3TugaokM=bn3ao$+?&?Jccd!A69i0auW;}!| z6CoVVhj7&bK+gCL$M+>%>a~AE#^?^r{09jRJCOol_>QbIjWRp@FuH}g?Y)2Qd@Y*8 zPAP)0$O>V(9YP+>w%BPuoqpk!-(@G4?Oidd=SG6Vo?v0@ce{@+8(#Wt%z$BI|9tp= z?|&pX>;VRV@i}vMEP9}2%E(dI_P@NM-Ae?AebfyAdGXTts&416r5=0fR>#k-P9`{P zlcxZ%wQc);^)~a2DVrN^Yj$*qy#a@Pp%g;X=@9nLgi!u81m+n49HToVQd^5|tg@Z^ zE@l4xEeH<#GYihsH#S~N&D(m%`FXK__hhblj^MEF+3eePk7<0_UTv9Co!j}2IV)#H zbJ*veh49+*5Z3+?!o&ptJav85>Zy-)BCuGkMpDOW)F)8_i|qwg!9QF91A!-$QffeX?))gMS?XzT8uO%fw-Sd#r(w z_BsIb9=QC?Z+aYI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AnDsm^%d-Ng8C0`J?cvGP#xn zEX_x0C8mIgvVtMt5oR@}fN+Y*zF+sTqg@6cRT;`BvHd(dhHzNPuVZZ9$<4SzHyaU- zvFU+V#u=c70Y&P`%M*bUe_6p}CHO0JsgO!#Nv#^6Y!*2}qD9p$RT;JT6SfsOkT@<^RD`TOcDyo&PXyyX zzROrz;8DP$VdFzg6SZD;Xr<88LYvN^Tdu2Ph*cv}f52L2OFpA$S172-XA!3+;as>Y z=o)C0?$VQTuZZ9>!l7Mw*GrK@xLCK6#mK9MoEmcK_wY3;*R4cw^F^z}P&Cc@Mh?ETo(~`edZ6#^*eREbEE2uEL2ll}y5Wv~s9!M+ zk-fm+(*^Zp{(4m=(o-fRuk+9@^b^#}S&*z48iB&+q7}TR@oU+QFGFAhA+Tyj8qixy z43^_!xom*MDH%}L|MhQp#r6a?OXc4VtUr+<6}v(z2I-knf9Y^CLJ7x0;W9114UyML z;wB0$Z@>tehFj27Za0mXhBei+z*>~+VCtt6NB!Th9q+wXtnZbY#(1jIDKK^az3T|- zDuN?l22qR3jIzZ#)J75T)&S@j_^Y%HF$p~}DOcrYDLd_`VjtGa4rzUZr8)Sw^(_kv zhG?|=s|yaDP7*!mMpH#BeUe>HH*K!d@m`$S;6H$>+^gaD78_aQs#~P-P_k}=`WF@n my^;61yAg7wMpH$DOEDGL3Is8Q-xyBymH!{VsFF!0JOKb+7@Vj8 diff --git a/test/snapshots/format.js.md b/test/snapshots/format.js.md index a5dc13f..0675466 100644 --- a/test/snapshots/format.js.md +++ b/test/snapshots/format.js.md @@ -904,3 +904,21 @@ Generated by [AVA](https://avajs.dev). `Error {␊ message: 'error',␊ }` + +## formats sparse arrays + +> Snapshot 1 + + `%list.openBracket#[%␊ + %empty.open%%empty.close%%item.after#,%␊ + %empty.open%%empty.close%%item.after#,%␊ + %empty.open%%empty.close%%item.after#,%␊ + %list.closeBracket#]%` + +> Snapshot 2 + + `%list.openBracket#[%␊ + %empty.open%%empty.close%%item.after#,%␊ + %undefined.open%undefined%undefined.close%%item.after#,%␊ + %empty.open%%empty.close%%item.after#,%␊ + %list.closeBracket#]%` diff --git a/test/snapshots/format.js.snap b/test/snapshots/format.js.snap index 41ff492056c066aa92ffe204567e41f042716d4d..67f811e610bdea185a1dcfaccffb9cba32e15941 100644 GIT binary patch literal 4721 zcmV-%5{~UbRzVvYhMG(OTN`MPSLjp-yim;;C8&(jpJ{ztp;#&Do z_p`10RIqmibf@h4Aa zq-Fj->D_y~S53Si5dUX`sDM!G;!#Alf?(TU*_p%`7a1e*&O&bKc>c-#fP%-NEexYxw|Qh|z+k0JQNc(HWPPJ3HmhF(U7c$1I3ZPICa- zS-HIXOY6fXi)&By!#k9wLX5sf)P6~ybeDEh%O|8v`iHTwbT-7OhYkQ87k#$xB5(^a zIF}n|FmSCF#OQlOhHYFAy-YQqd%DBTx0_6_{s}SKrX>JIeGg7QY~y#>F6TM>VcIQY zh*7&%0I=fqj~iuk$67lY_0Br5<`u-~(AFsAv&-c!+Gg{&&&gTCFXlFd7)?cF;W)CH z{=qvLABRUI9p1fmFvMt%IAs3C7WNhlvtw|_l&#sLht@DxV<=fdMX8lZv(QAlYr>}pxeOFP70}me!3S6K20b=w&rU1A# zn^5R{fy>!jGE`uA^mqWoXtWuU(7JBp7YsadH|g`IwDPy-%^^nJ%~8nHRnIOSoH?QW z*>=X?G$*TFBgqxLUG1=axg z44SvT?FZLCuD;*AZrc=t%@Cs{sFRO6*41}pSFL>;TmrbaOf6?XjGEY@Ua!Y*Ga_c= zx|G?u#eI9`H-{Ltb^svIu2y2_9a6Q9KmG8VsElGX#0h}OH*auLii`u?c0958RCd1?#OM=5QP+Kg9sKVl z&K0@}4S|V0#OS*|0Pu7tEbKC0E8At@+{EynIt~z{=6wN3N*a8pNorhM-x6c3QEv^( zAx66oKy5G}xM$-Tdduz+9oMZo#Xw~fqsPP{6a1Dm%^3S^Kwytg7BBu91~KaF0>I3J zxw&&vT4heWWm(D`zVsNxC?O8H6qhh7!*~9x5z{V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Q@5SNvx9q{JS;kHQlOkk}*AiWEB=bD7Pul5C*aQ?U(vF7ofubq`IFFzP83G=_C)D z0#V6Tx$^aNL#&jQ(bIIgXap1dFTW*1MQUoP&@bM|?(W(3ipH2+qlnxXTdcA%_Eo7=Z851< zWsoc#Yqgi`=oBre>!m*ADqBf57nRJ8u#o($P1)T^Y(qO_;^4VUfqe)_j&waaJeII` zPpvN3C_43*AO&6C1=&0t$siK_CjOIT+$sgOrp7z zJ!@#7GnabatF7tap|-kIwSE64%uuHEYn4#(Yn4zbu@+KYlK*1|Kwq;cI2d&srn&M9 zb7(BJbEx2I32hjO!R!$i8L4>pT>km5?0X;O&VSWkv2RPiN9YJ0HGPTFOVM$xIi1Su?oQps+H*7`s#lEo3I zbfPw;4sOuY+g_5Q%XbZOX-Cez1m!Q=m@2+FDV26ejZLD^9tC&i6>9I>sy|?6^990s z+3FK7g;dP?o7wBF#lAxQ>~+$vY8SCuI_-?F-Umo4<$0GG%wa`WHBoDmYYLtEOR%wx zP?#t?Kx=yuTa|m*WbQDuJ6;+{r~VRbY$}50M7CrZZ}YXeR~`~A&h^%f2w$1qIIUEfpqFGK??eMgsfK-k>3JJ z4pBs26co8ak-z^UcB7*DbNWW%Q-$n~oz`2b=FzFY1S#klGS|W0T7f4k0LqzXgl&c$Q%NxBP9o4p+zPNDvdYv{3VnytL9HTt=rzl2d0Z!vMO z-WQ%I5f|CHm)`VuNdn?#{MO?h|Ev=fnr(W$=#DX9J~a$j(g!}a%`w;sL2k#Rxk z_m3Y)^u`dDkQKxx;wUPX*f(>)v^{pCM g<~2LwqIOK8{UnKo(W$=#8-oS)|LYRcQj(Ye0LNt?GXMYp From 6c4cea10aeeab92072b7c01a2eea1427340f667b Mon Sep 17 00:00:00 2001 From: ninevra Date: Mon, 19 Jul 2021 13:45:32 -0700 Subject: [PATCH 05/11] Adjust theming --- lib/primitiveValues/empty.js | 2 +- lib/themeUtils.js | 2 +- test/snapshots/diff.js.md | 10 +++++----- test/snapshots/diff.js.snap | Bin 5591 -> 5593 bytes test/snapshots/format.js.md | 10 +++++----- test/snapshots/format.js.snap | Bin 4721 -> 4726 bytes 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/primitiveValues/empty.js b/lib/primitiveValues/empty.js index 5bb9d48..ee08bc3 100644 --- a/lib/primitiveValues/empty.js +++ b/lib/primitiveValues/empty.js @@ -25,7 +25,7 @@ class EmptyValue { } formatDeep (theme) { - return lineBuilder.single(formatUtils.wrap(theme.empty, '')) + return lineBuilder.single(formatUtils.wrap(theme.item.empty, 'empty item')) } } Object.defineProperty(EmptyValue.prototype, 'isPrimitive', { value: true }) diff --git a/lib/themeUtils.js b/lib/themeUtils.js index 46c7e6d..70c8a66 100644 --- a/lib/themeUtils.js +++ b/lib/themeUtils.js @@ -35,7 +35,6 @@ const defaultTheme = freezeTheme({ expected: '+ ', padding: ' ', }, - empty: { open: '', close: '' }, error: { ctor: { open: '(', close: ')' }, name: { open: '', close: '' }, @@ -48,6 +47,7 @@ const defaultTheme = freezeTheme({ item: { after: ',', customFormat: null, + empty: { open: '<', close: '>' }, increaseValueIndent: false, }, list: { openBracket: '[', closeBracket: ']' }, diff --git a/test/snapshots/diff.js.md b/test/snapshots/diff.js.md index 0e6cf7f..2d3424a 100644 --- a/test/snapshots/diff.js.md +++ b/test/snapshots/diff.js.md @@ -1259,9 +1259,9 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `%diffGutters.padding# %%list.openBracket#[%␊ - %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ - %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ - %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ + %diffGutters.actual#- % %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ + %diffGutters.actual#- % %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ + %diffGutters.actual#- % %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ @@ -1270,9 +1270,9 @@ Generated by [AVA](https://avajs.dev). > Snapshot 2 `%diffGutters.padding# %%list.openBracket#[%␊ - %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ + %diffGutters.actual#- % %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ %diffGutters.padding# % %undefined.open%undefined%undefined.close%%item.after#,%␊ - %diffGutters.actual#- % %empty.open%%empty.close%%item.after#,%␊ + %diffGutters.actual#- % %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ %diffGutters.padding# %%list.closeBracket#]%` diff --git a/test/snapshots/diff.js.snap b/test/snapshots/diff.js.snap index ccf00017f56f54ae108a4313a6498d8b98df24bc..2fa0c3c7e54e6da40bcd9de1bc54978c12dc0165 100644 GIT binary patch delta 5564 zcmV;t6+`ORE7>c5K~_N^Q*L2!b7*gLAa*he0swbcW`OT-wK#iIo<;`ZQ86Ej2mk;8 z00003?L7&26h+q6lf;N}tANN#Fb)fmgpfc&0FfjdhC>txE@VMElTH|zBkAeEgiDFK zunNdZT)6^^D6o(P*uQ?uC$8cu#KBSSlj}_?t9rg zhnydpu>R+N&p%l7^?_eqd@_gNuzT+VpwZt>=hPftME=ijK>oZH1M042nT_OCK4B=V%(mdJom+6zK|<)aWvGXZEzwEW$Ycfae~uWG`b z$(pxt>3GN!!aaKAZgD+L%!XW)mECGYegs zwSWJAFK={zFRSuKzYCvr>_~9f!9xK^{nISR*%dW|2TsaaGR`&oLNte+H4MThPe9oI z6a-5y+v4J}>^rwFy*2+Yl~c`EqXrQi_G=b;jr#e~m{Dgp{$W?tq$!8!X(kS9e;PuQ zF#z=bVEwwy<2&4&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#^nx^jwJD8#6tVTTMmgvkymuU=x< zprF_wT(MA7FbZbMxr+6&BjqUie^$gWgN7MYW(NH_0%4fKz?wq5!Gh%opQ^!DeZnwV zhRHHKx1jS!PoA3sQ}ry0sp3XsSS!O?>B(9d_DOg4NtH!PkX=ox-);Bfp6gBU>9zRmlhRbCdDapn1$J{B%NYWr{ z%pZkUmC3arU}-)|D=`H`lobpCk1(q-1%y*f_8o3pt-#d$f`7^xQK7?SUPsG#l2IAT zC$arJJBDyr$**H<-pS3lLN~8}Asl1V1FwuTK=lKP)RULT11GYA$4c;5=u#n-%92_& zKG`gCghY#~TdFc@@hh-8g^`!_F9J7}O3QkdyRc9?+t)?0i@5@lE`!eAC=!xAzMnbQ z>R@_g(ll8naj(QUk-z6FCy%}Zk|UM2pA>ExfesTAfyN@3d=>Fjp@oKjqVp(%%MI0A zA3jSJC94v|<0+oU4AhQS=J1JN{Kt10OAA~ISTt-*h-sqM%MPs+x;V7y9J=MY+J;y) zBJ~HXb++U)igty9ntU2@Y7)+cyMnHPM(Hj+Dff~HE+ZV;g?GIaIfRRKD_M-JGvw5e zQ@@9=QMqmoP}l$G-|&im?Qv|D%D)|0eh6k6VZ5i||ApsCz$8c~cj)imE)l;dFPrV~fq z->@C;xmK*tm72zQs?shnb^pEV20D}s&!~g&Q diff --git a/test/snapshots/format.js.md b/test/snapshots/format.js.md index 0675466..f3fadf2 100644 --- a/test/snapshots/format.js.md +++ b/test/snapshots/format.js.md @@ -910,15 +910,15 @@ Generated by [AVA](https://avajs.dev). > Snapshot 1 `%list.openBracket#[%␊ - %empty.open%%empty.close%%item.after#,%␊ - %empty.open%%empty.close%%item.after#,%␊ - %empty.open%%empty.close%%item.after#,%␊ + %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ + %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ + %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ %list.closeBracket#]%` > Snapshot 2 `%list.openBracket#[%␊ - %empty.open%%empty.close%%item.after#,%␊ + %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ %undefined.open%undefined%undefined.close%%item.after#,%␊ - %empty.open%%empty.close%%item.after#,%␊ + %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ %list.closeBracket#]%` diff --git a/test/snapshots/format.js.snap b/test/snapshots/format.js.snap index 67f811e610bdea185a1dcfaccffb9cba32e15941..6280e0549a2282b3011c12ee5ba054c44713357d 100644 GIT binary patch literal 4726 zcmV-+5{d0WRzVp zL*37|?o+|u6_ls01?$JEPes4UBq%ZWhMNG3g!ua%f&a{za?X@9?cDp?07Lik z?(KPSk^wRLvIz?LXkx#v|LZPg6|8oR$D| zuyTF(r`Cr}7T2EYM|3JngBX2{sN<4;8Ll0sRZL8s{5NA^*&K*bPaOa{FZyiXP2e7C za4s+2V9;7Eh|%|m4BNRKdYNWE?{ue|Z#S7<{R3jOU26c0`X8Ke*v9{`UG8)C!}MFm z5TkZ&0AMBPA2-V3jYIIF%`1q}VQo>!XV=T!w9V#kpPRdeU&3t;F`9MF5Qx!Samf6Ot@bZX&P~B2KBX=n*eRlZhmMSb{+VYlP40Eb2V(TT0RVji z?z;E~kM-2wI{93`xewk!j1KPtfHQbE_rE8+J=*_4%s4)+{0YQpsyO6G`_yGdnQ1Q> zmnPm@x?B%p^sFHO{VlF;d8V^W+bLt;`?B$|{t%<1jQ|+1ZL#jz6>khWKiXqx@<%#q zv0`+K2>=8A&aO=uqw|sL?bp>ccKs}f(QAm@W~_g?eOGa-0}uZi9JD^~1H|ZmOaX9j zF|o+`0++M5beO>K=;hbEEsg;Zt~|(=@oC!n?sCxn4^%VtDapvIBR0Z zvmK@fOltoZ1EXb9n#@AAo(HE-2sd^)7fxm2fKl9Ax5u@Lw@~l#)^a`t78jOUWdHcj@rK%6<7n{ zJNW1I?LWBve)aw4b=#&IY=#&uMV)-~vF?7Ox@+y*;2OxiWokJSV${SI^?E&iyOFUQ z*QL(ME9u|6pe4kpwF3Y_c72NG#!t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JH From 5b2aa7a5f2d8f96d49e1a270cc0426d9f2cb9274 Mon Sep 17 00:00:00 2001 From: ninevra Date: Mon, 19 Jul 2021 13:52:13 -0700 Subject: [PATCH 06/11] Test serializing sparse arrays --- test/serialize-and-encode.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/serialize-and-encode.js b/test/serialize-and-encode.js index 5078d25..58b9a45 100644 --- a/test/serialize-and-encode.js +++ b/test/serialize-and-encode.js @@ -119,6 +119,7 @@ test('symbol properties are reordered despite serialization', t => { // Arrays test('array with primitive item', useDeserialized, ['bar']) test('array with complex item', useDeserialized, [{}]) +test('array with empty item', useDeserialized, new Array(1)) // Iterators test('iterator with primitive item', useDeserialized, From 2ad6803d57051602c403c93091562ab3fc407a9f Mon Sep 17 00:00:00 2001 From: ninevra Date: Mon, 19 Jul 2021 13:52:20 -0700 Subject: [PATCH 07/11] Serialize sparse arrays --- lib/serialize.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/serialize.js b/lib/serialize.js index 4a7e7c5..63c99a1 100644 --- a/lib/serialize.js +++ b/lib/serialize.js @@ -29,6 +29,7 @@ const pluginRegistry = require('./pluginRegistry') const bigIntValue = require('./primitiveValues/bigInt') const booleanValue = require('./primitiveValues/boolean') +const emptyValue = require('./primitiveValues/empty') const nullValue = require('./primitiveValues/null') const numberValue = require('./primitiveValues/number') const stringValue = require('./primitiveValues/string') @@ -82,6 +83,8 @@ const mappings = [ [0x1D, setValue.tag, setValue.deserialize], [0x1E, typedArrayValue.tag, typedArrayValue.deserialize], [0x1F, typedArrayValue.bytesTag, typedArrayValue.deserializeBytes], + + [0x20, emptyValue.tag, emptyValue.deserialize], ] const tag2id = new Map(mappings.map(mapping => [mapping[1], mapping[0]])) const id2deserialize = new Map(mappings.map(mapping => [mapping[0], mapping[2]])) From c44c99319c3c22f1e62b8fb56918f684e1dcbb91 Mon Sep 17 00:00:00 2001 From: ninevra Date: Tue, 20 Jul 2021 12:59:47 -0700 Subject: [PATCH 08/11] Use EmptyItem rather than empty primitive Having an EmptyList descriptor type seems like a clearer description of the underlying data model than having an Empty primitive that can by construction only occur in PrimitiveItems. --- lib/complexValues/object.js | 3 +- lib/describe.js | 10 ++--- lib/metaDescriptors/item.js | 85 ++++++++++++++++++++++++++++++++++++ lib/primitiveValues/empty.js | 32 -------------- lib/serialize.js | 3 +- 5 files changed, 91 insertions(+), 42 deletions(-) delete mode 100644 lib/primitiveValues/empty.js diff --git a/lib/complexValues/object.js b/lib/complexValues/object.js index dfb7558..8730bfd 100644 --- a/lib/complexValues/object.js +++ b/lib/complexValues/object.js @@ -76,7 +76,6 @@ function DescribedMixin (base) { this.value = props.value this.describeAny = props.describeAny - this.describeEmpty = props.describeEmpty this.describeItem = props.describeItem this.describeMapEntry = props.describeMapEntry this.describeProperty = props.describeProperty @@ -124,7 +123,7 @@ function DescribedMixin (base) { if (current in this.value) { return this.describeItem(current, this.describeAny(this.value[current])) } else { - return this.describeItem(current, this.describeEmpty()) + return this.describeItem(current) } } diff --git a/lib/describe.js b/lib/describe.js index 71c68ca..6beb9d1 100644 --- a/lib/describe.js +++ b/lib/describe.js @@ -25,7 +25,6 @@ const propertyDescriptor = require('./metaDescriptors/property') const pluginRegistry = require('./pluginRegistry') const bigIntValue = require('./primitiveValues/bigInt') const booleanValue = require('./primitiveValues/boolean') -const emptyValue = require('./primitiveValues/empty') const nullValue = require('./primitiveValues/null') const numberValue = require('./primitiveValues/number') const stringValue = require('./primitiveValues/string') @@ -56,10 +55,6 @@ const SpecializedComplexes = new Map([ ['Uint8ClampedArray', typedArrayValue.describe], ]) -function describeEmpty () { - return emptyValue.describe() -} - function describePrimitive (value) { if (value === null) return nullValue.describe() if (value === undefined) return undefinedValue.describe() @@ -125,7 +120,6 @@ function describeComplex (value, registry, tryPlugins, describeAny, describeItem const descriptor = describeValue({ ctor, describeAny, - describeEmpty, describeItem, describeMapEntry, describeProperty, @@ -139,6 +133,10 @@ function describeComplex (value, registry, tryPlugins, describeAny, describeItem } const describeItem = (index, valueDescriptor) => { + if (valueDescriptor === undefined) { + return itemDescriptor.describeEmpty(index) + } + return valueDescriptor.isPrimitive === true ? itemDescriptor.describePrimitive(index, valueDescriptor) : itemDescriptor.describeComplex(index, valueDescriptor) diff --git a/lib/metaDescriptors/item.js b/lib/metaDescriptors/item.js index 529e95b..156ed95 100644 --- a/lib/metaDescriptors/item.js +++ b/lib/metaDescriptors/item.js @@ -2,6 +2,7 @@ const constants = require('../constants') const formatUtils = require('../formatUtils') +const lineBuilder = require('../lineBuilder') const recursorUtils = require('../recursorUtils') const DEEP_EQUAL = constants.DEEP_EQUAL @@ -30,12 +31,25 @@ function deserializePrimitive (state) { } exports.deserializePrimitive = deserializePrimitive +function describeEmpty (index) { + return new EmptyItem(index) +} +exports.describeEmpty = describeEmpty + +function deserializeEmpty (index) { + return new EmptyItem(index) +} +exports.deserializeEmpty = deserializeEmpty + const complexTag = Symbol('ComplexItem') exports.complexTag = complexTag const primitiveTag = Symbol('PrimitiveItem') exports.primitiveTag = primitiveTag +const emptyTag = Symbol('EmptyItem') +exports.emptyTag = emptyTag + class ComplexItem { constructor (index, value) { this.index = index @@ -252,3 +266,74 @@ class PrimitiveItem { } Object.defineProperty(PrimitiveItem.prototype, 'isItem', { value: true }) Object.defineProperty(PrimitiveItem.prototype, 'tag', { value: primitiveTag }) + +class EmptyItem { + constructor (index) { + this.index = index + } + + compare (expected) { + return expected.tag === emptyTag && this.index === expected.index + ? DEEP_EQUAL + : UNEQUAL + } + + formatDeep (theme, indent) { + const formatted = lineBuilder.single(formatUtils.wrap(theme.item.empty, 'empty item')) + + if (typeof theme.item.customFormat === 'function') { + return theme.item.customFormat(theme, indent, formatted) + } + + return formatted.withLastPostfixed(theme.item.after) + } + + prepareDiff (expected, lhsRecursor, rhsRecursor, compareComplexShape, isCircular) { + const compareResult = this.compare(expected) + // Short-circuit when both are empty items. + if (compareResult === DEEP_EQUAL) return { compareResult } + + // Try to line up this or remaining items with the expected items. + const rhsFork = recursorUtils.fork(rhsRecursor) + const initialExpected = expected + + do { + if (expected === null || expected.isItem !== true) { + return { + actualIsExtraneous: true, + rhsRecursor: recursorUtils.map( + recursorUtils.unshift(rhsFork.recursor, initialExpected), + next => { + if (next.isItem !== true) return next + + next.index++ + return next + }), + } + } + + if (this.compare(expected) === DEEP_EQUAL) { + return { + expectedIsMissing: true, + lhsRecursor: recursorUtils.map( + recursorUtils.unshift(lhsRecursor, this), + next => { + if (next.isItem !== true) return next + + next.index++ + return next + }), + rhsRecursor: rhsFork.recursor, + } + } + + expected = rhsFork.shared() + } while (true) + } + + serialize () { + return this.index + } +} +Object.defineProperty(EmptyItem.prototype, 'isItem', { value: true }) +Object.defineProperty(EmptyItem.prototype, 'tag', { value: emptyTag }) diff --git a/lib/primitiveValues/empty.js b/lib/primitiveValues/empty.js deleted file mode 100644 index ee08bc3..0000000 --- a/lib/primitiveValues/empty.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict' - -const constants = require('../constants') -const formatUtils = require('../formatUtils') -const lineBuilder = require('../lineBuilder') - -const DEEP_EQUAL = constants.DEEP_EQUAL -const UNEQUAL = constants.UNEQUAL - -function describe () { - return new EmptyValue() -} -exports.describe = describe - -exports.deserialize = describe - -const tag = Symbol('EmptyValue') -exports.tag = tag - -class EmptyValue { - compare (expected) { - return expected.tag === tag - ? DEEP_EQUAL - : UNEQUAL - } - - formatDeep (theme) { - return lineBuilder.single(formatUtils.wrap(theme.item.empty, 'empty item')) - } -} -Object.defineProperty(EmptyValue.prototype, 'isPrimitive', { value: true }) -Object.defineProperty(EmptyValue.prototype, 'tag', { value: tag }) diff --git a/lib/serialize.js b/lib/serialize.js index 63c99a1..1db65bb 100644 --- a/lib/serialize.js +++ b/lib/serialize.js @@ -29,7 +29,6 @@ const pluginRegistry = require('./pluginRegistry') const bigIntValue = require('./primitiveValues/bigInt') const booleanValue = require('./primitiveValues/boolean') -const emptyValue = require('./primitiveValues/empty') const nullValue = require('./primitiveValues/null') const numberValue = require('./primitiveValues/number') const stringValue = require('./primitiveValues/string') @@ -84,7 +83,7 @@ const mappings = [ [0x1E, typedArrayValue.tag, typedArrayValue.deserialize], [0x1F, typedArrayValue.bytesTag, typedArrayValue.deserializeBytes], - [0x20, emptyValue.tag, emptyValue.deserialize], + [0x20, itemDescriptor.emptyTag, itemDescriptor.deserializeEmpty], ] const tag2id = new Map(mappings.map(mapping => [mapping[1], mapping[0]])) const id2deserialize = new Map(mappings.map(mapping => [mapping[0], mapping[2]])) From 7e4c74cb623df06f9031b42576496f490bae92bc Mon Sep 17 00:00:00 2001 From: ninevra Date: Tue, 20 Jul 2021 13:36:10 -0700 Subject: [PATCH 09/11] Bump format version --- lib/serialize.js | 2 +- test/fixtures/pointerSerialization.bin | Bin 200 -> 200 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/serialize.js b/lib/serialize.js index 1db65bb..5608492 100644 --- a/lib/serialize.js +++ b/lib/serialize.js @@ -41,7 +41,7 @@ const recursorUtils = require('./recursorUtils') // Concordance versions will not be able to decode buffers generated by a newer // version, so changing this value will require a major version bump of // Concordance itself. The version is encoded as an unsigned 16 bit integer. -const VERSION = 3 +const VERSION = 4 // Adding or removing mappings or changing an index requires the version in // encoder.js to be bumped, which necessitates a major version bump of diff --git a/test/fixtures/pointerSerialization.bin b/test/fixtures/pointerSerialization.bin index dec00cd6b413b4b94eb42c40fd72228dbe1a0038..93b95a476d96b5bb34996c94a5eb79a7d7c8fbde 100644 GIT binary patch delta 9 QcmX@Xc!H6UWg_Eo01qev@c;k- delta 9 QcmX@Xc!H6Uc_QO+01qSr@Bjb+ From e06936008c0d54f1d0353ec506cc07eb59fdb6a0 Mon Sep 17 00:00:00 2001 From: ninevra Date: Tue, 20 Jul 2021 13:56:39 -0700 Subject: [PATCH 10/11] Test formatting sparse arraylike objects --- test/format.js | 4 ++++ test/snapshots/format.js.md | 13 +++++++++++++ test/snapshots/format.js.snap | Bin 4726 -> 4780 bytes 3 files changed, 17 insertions(+) diff --git a/test/format.js b/test/format.js index 0e40791..6885dcd 100644 --- a/test/format.js +++ b/test/format.js @@ -476,3 +476,7 @@ test('formats sparse arrays', t => { array2[1] = undefined t.snapshot(format(array2)) }) + +test('formats sparse arraylike objects', t => { + t.snapshot(format({ length: 4, 0: 'foo', 2: 'bar' })) +}) diff --git a/test/snapshots/format.js.md b/test/snapshots/format.js.md index f3fadf2..4350562 100644 --- a/test/snapshots/format.js.md +++ b/test/snapshots/format.js.md @@ -922,3 +922,16 @@ Generated by [AVA](https://avajs.dev). %undefined.open%undefined%undefined.close%%item.after#,%␊ %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ %list.closeBracket#]%` + +## formats sparse arraylike objects + +> Snapshot 1 + + `%list.openBracket#[%␊ + %string.line.open#'%%string.open%foo%string.close%%string.line.close#'%%item.after#,%␊ + %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ + %string.line.open#'%%string.open%bar%string.close%%string.line.close#'%%item.after#,%␊ + %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ + %stats.separator#---%␊ + length%property.separator#: %%number.open%4%number.close%%property.after#,%␊ + %list.closeBracket#]%` diff --git a/test/snapshots/format.js.snap b/test/snapshots/format.js.snap index 6280e0549a2282b3011c12ee5ba054c44713357d..aaed43db6f29e095b0ed3a19bc19d4cf69ef5a02 100644 GIT binary patch literal 4780 zcmV;d5>xF#RzVTqobyO?ULl)a~95J>;oA!;f)UGVZ!=GLO2H@7c)ze~Wt=m0qdNn>1RzDjf(%q@H< zy1(baDF(#o%X%o}qlM$zzOOr!l+9$0+nvRS80}ae07K!^qKQM_TP!@_`!d%kE0BTF zl?`N+_X7Yeng|Z>{HDEE(fayR4)519QPl(TBme}82#UN0Cb;XZ1_W4Mqb~HbC;ug9P))2{nG@1 z-hubr0z$?NG2Rk=zR&Cj?;u8pbpXH>yqo>slRjRpekZ1#m{R%#Vl-76a->!2QnQS- zmyF93?k`!^8e;UEDFA(~uWf#2xYVFm`o8xi<6;9KMn{wgUJZvBU5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p0gTXxoR3$2U6(3kD2!eBVQ?rdQh1vP_|wNPM8QL)s|&KHwOAyE|# z5`BhzD;U96aw$V^zlhTIuJipO3TszxzbKj=GZf`jRhi6zE=&>ziVZOe>!^+^NZFXE zE2xxVHeSAo_zC#Y93lByM`Z)Tf+b9h4&zI$lK}j?6>2rzDshrNJ&1k$+O{PYB;y|zo&*u_so|0Sd5++FsB0(JS1yN#d zI0a}LW0Xb_xiPj#Wn=7{TvKOP|r7&nmW_d*N1y-mY!90|y zqV1_q-Ar8M%}_YpAC)mpb07t?uBVrempU`~FQVLoH=rtAt8k ztAxs^wUF+T{2x02`c_22!Km3-nkv6AhlVmchYGHiFuX_%X7{+rNX5J7)aSqQ?|qaz z|5g7HN8S0uFyTy_xak~vzDqZ`)mMEOZrPOrxJ>zPVLG$}TBG2svEKq(4pGEj6co8aq27OyxKUC4IemlhsX}(gPU9`L z@$sp@25F2lWUhm~d76{f#>S`q8f<7wHfS|CPAK9><2jk>D)})Dl{TCoLG)u<`V9~C z^!By1)=rT%a}Vq890;aE*4OTTKh8XU~Dv0++@|D(7dPrcpMOmmW` z;cHamef3se*J}M-&~iDiS+F%SKK0jNgEN*W9`9lk(%(Wi|&;1{y*jTvaXa$(uT!+=C{cW#$sP{*b>0$_5#17&R@tV1!vGA$C25EGKo0LO99Zd;!Ga*!8 z(F-JAIF$aXO?|EQX!(~=_^DgjHHc-frL3pF=AoAIj{fG8?C)rX$;QT~{u*p>dpo1$ zAD4Xl5nWnehOHkbC=KF~NinD$5jTj+&LEi^Yy2fJ@~fboy&71i)%#zgcRHr|5=|rHQ-2LM1Pki_0qBH(*Q=TU E0F{y;O#lD@ From 608fe62784608c6e57eb4f9267db3901cf261b3f Mon Sep 17 00:00:00 2001 From: ninevra Date: Tue, 20 Jul 2021 13:56:46 -0700 Subject: [PATCH 11/11] Test diffing sparse arraylike objects --- test/diff.js | 7 +++++++ test/snapshots/diff.js.md | 13 +++++++++++++ test/snapshots/diff.js.snap | Bin 5593 -> 5689 bytes 3 files changed, 20 insertions(+) diff --git a/test/diff.js b/test/diff.js index 67e77cf..eb07e70 100644 --- a/test/diff.js +++ b/test/diff.js @@ -574,3 +574,10 @@ test('diffs sparse arrays', t => { array[1] = undefined t.snapshot(diff(array, Array.from({ length: 3 }))) }) + +test('diffs sparse arraylike objects', t => { + t.snapshot(diff( + { length: 3, 0: 'a', 2: 'c' }, + { length: 3, 0: 'a', 1: undefined, 2: 'c' }, + )) +}) diff --git a/test/snapshots/diff.js.md b/test/snapshots/diff.js.md index 2d3424a..c0fa87a 100644 --- a/test/snapshots/diff.js.md +++ b/test/snapshots/diff.js.md @@ -1276,3 +1276,16 @@ Generated by [AVA](https://avajs.dev). %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ %diffGutters.padding# %%list.closeBracket#]%` + +## diffs sparse arraylike objects + +> Snapshot 1 + + `%diffGutters.padding# %%list.openBracket#[%␊ + %diffGutters.padding# % %string.line.open#'%%string.open%a%string.close%%string.line.close#'%%item.after#,%␊ + %diffGutters.actual#- % %item.empty.open#<%empty item%item.empty.close#>%%item.after#,%␊ + %diffGutters.expected#+ % %undefined.open%undefined%undefined.close%%item.after#,%␊ + %diffGutters.padding# % %string.line.open#'%%string.open%c%string.close%%string.line.close#'%%item.after#,%␊ + %diffGutters.padding# % %stats.separator#---%␊ + %diffGutters.padding# % length%property.separator#: %%number.open%3%number.close%%property.after#,%␊ + %diffGutters.padding# %%list.closeBracket#]%` diff --git a/test/snapshots/diff.js.snap b/test/snapshots/diff.js.snap index 2fa0c3c7e54e6da40bcd9de1bc54978c12dc0165..abeaac260252978fa0828d83cd64ae7a4b31d221 100644 GIT binary patch literal 5689 zcmV-97RKp8RzVh^z$TunB;ha|qCjvV3(}eC2?KK^Jw2FkDNz?z0a=MF zS6~qp7P27gvM8`|6%hqi5dmfSkxM~-Kn@XCSY$h0N$8&GtEOvadS=?s_mO$sRsH&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