is-new-expression.js 322 B

12345678910111213141516171819202122
  1. 'use strict';
  2. function isNewExpression(node, options) {
  3. if (node?.type !== 'NewExpression') {
  4. return false;
  5. }
  6. const {
  7. name,
  8. } = {
  9. ...options,
  10. };
  11. if (name) {
  12. return node.callee.type === 'Identifier' && node.callee.name === name;
  13. }
  14. /* c8 ignore next */
  15. return true;
  16. }
  17. module.exports = isNewExpression;