From ac49a6eb20fc1050df5d3818affcd81f7436ce91 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Thu, 7 Dec 2023 16:44:57 -0500 Subject: [PATCH] FIX: Shadow size property of columns object, so it acts as a column --- bids-validator/src/types/columns.test.ts | 13 +++++++++++++ bids-validator/src/types/columns.ts | 2 ++ 2 files changed, 15 insertions(+) diff --git a/bids-validator/src/types/columns.test.ts b/bids-validator/src/types/columns.test.ts index 0b99e007e..780394ab4 100644 --- a/bids-validator/src/types/columns.test.ts +++ b/bids-validator/src/types/columns.test.ts @@ -30,4 +30,17 @@ Deno.test('ColumnsMap', async (t) => { assertEquals(Object.keys(columns), ['a', 'b', '0']) assertEquals(Object.getOwnPropertyNames(columns), ['a', 'b', '0']) }) + await t.step('size columns are permissible', () => { + const columns = new ColumnsMap() + // @ts-expect-error + columns['size'] = ['0'] + // @ts-expect-error + assertEquals(columns.size, ['0']) + }) + await t.step('missing columns are undefined', () => { + const columns = new ColumnsMap() + columns['a'] = ['0'] + assertEquals(columns.b, undefined) + assertEquals(columns.size, undefined) + }) }) diff --git a/bids-validator/src/types/columns.ts b/bids-validator/src/types/columns.ts index 6227b5cf9..8053f770d 100644 --- a/bids-validator/src/types/columns.ts +++ b/bids-validator/src/types/columns.ts @@ -15,6 +15,8 @@ export const columnMapAccessorProxy = { prop: symbol | string, receiver: ColumnsMap, ) { + // Map.size exists, so we need to shadow it with the column contents + if (prop === 'size') return target.get('size') const value = Reflect.get(target, prop, receiver) if (typeof value === 'function') return value.bind(target) if (prop === Symbol.iterator) return target[Symbol.iterator].bind(target)