From 6d7e97215e8894076071269f2d2f44769ac61dbf Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 7 Feb 2025 16:58:10 -0500 Subject: [PATCH 1/2] test: Ensure columns named set are permitted --- src/types/columns.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/types/columns.test.ts b/src/types/columns.test.ts index e7f0cc570..5623b7b18 100644 --- a/src/types/columns.test.ts +++ b/src/types/columns.test.ts @@ -37,6 +37,13 @@ Deno.test('ColumnsMap', async (t) => { // @ts-expect-error ibid assertEquals(columns.size, ['0']) }) + await t.step('set columns are permissible', () => { + const columns = new ColumnsMap() + // @ts-expect-error ts thinks size is protected property + columns['set'] = ['0'] + // @ts-expect-error ibid + assertEquals(columns.set, ['0']) + }) await t.step('missing columns are undefined', () => { const columns = new ColumnsMap() columns['a'] = ['0'] From 6b522ff5b0012f42298373384016957ec1b2574f Mon Sep 17 00:00:00 2001 From: "Christopher J. Markiewicz" Date: Fri, 7 Feb 2025 16:59:05 -0500 Subject: [PATCH 2/2] fix: Allow TSV files to have column names matching Map instance methods get, has and entries are excluded, since HED calls them --- src/types/columns.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/types/columns.ts b/src/types/columns.ts index eb5ca0deb..db7a5d01a 100644 --- a/src/types/columns.ts +++ b/src/types/columns.ts @@ -15,8 +15,14 @@ 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') + // Map instance methods/properties that could plasubily be column names: + if ( + ['clear', 'delete', 'keys', 'set', 'values', 'size'].includes( + prop as string, + ) + ) { + return target.get(prop as string) + } 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)