Skip to content

buffer: use private properties for brand checks in File

The current checks wouldn't work for certain values, and other places in the code have moved to this behavior as well.

import { File } from 'node:buffer'

const pd = Object.getOwnPropertyDescriptor(File.prototype, 'name')

pd.get.call(true) // Uncaught TypeError: Cannot use 'in' operator to search for '#name' in true

pd.get.call(null) // Uncaught TypeError [ERR_INVALID_THIS]: Value of "this" must be of type File

Refs: https://github.com/nodejs/node/pull/46904/

Merge request reports

Loading