has-listeners.js 433 B

12345678910111213141516
  1. 'use strict';
  2. var isEmpty = require('es5-ext/object/is-empty')
  3. , value = require('es5-ext/object/valid-value')
  4. , hasOwnProperty = Object.prototype.hasOwnProperty;
  5. module.exports = function (obj/*, type*/) {
  6. var type;
  7. value(obj);
  8. type = arguments[1];
  9. if (arguments.length > 1) {
  10. return hasOwnProperty.call(obj, '__ee__') && Boolean(obj.__ee__[type]);
  11. }
  12. return obj.hasOwnProperty('__ee__') && !isEmpty(obj.__ee__);
  13. };