Airbreaks-Low-Power/Programming/Javascript/node_modules/@serialport/bindings/lib/legacy.js
2023-12-19 18:30:36 -06:00

27 lines
653 B
JavaScript

let warningSent = false
const wrapWithHiddenComName = async portsPromise => {
const ports = await portsPromise
return ports.map(port => {
const newPort = { ...port }
return Object.defineProperties(newPort, {
comName: {
get() {
if (!warningSent) {
warningSent = true
console.warn(
`"PortInfo.comName" has been deprecated. You should now use "PortInfo.path". The property will be removed in the next major release.`
)
}
return newPort.path
},
enumerable: false,
},
})
})
}
module.exports = {
wrapWithHiddenComName,
}