Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Shadow size property of columns object, so it acts as a column #1855

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions bids-validator/src/types/columns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
2 changes: 2 additions & 0 deletions bids-validator/src/types/columns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading