Skip to content

Conversation

@jimmywarting
Copy link

optional changing came in node v14

optional changing came in node v14
module.exports = function isBuffer (obj) {
return obj != null && obj.constructor != null &&
typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
/** @returns {boolean} true if obj is a Buffer */
Copy link

@ChristianMurphy ChristianMurphy Jan 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a related potential improvement

Suggested change
/** @returns {boolean} true if obj is a Buffer */
/**
* Determine if an object is a Buffer
* @param {unknown} obj
* @returns {obj is Buffer} true if obj is a Buffer
*/

could be used with https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
along side a tsconfig like

{
  "include": ["*.js"],
  "compilerOptions": {
    "target": "ES2020",
    "lib": ["ES2020"],
    "module": "ES2020",
    "moduleResolution": "node",
    "allowJs": true,
    "checkJs": true,
    "declaration": true,
    "emitDeclarationOnly": true
  }
}

to automatically generate the index.d.ts file, rather than having it hand-coded

which would also be related to #42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants