utils.js 398 B

123456789101112131415161718192021
  1. var utils = module.exports;
  2. /**
  3. * Invoke callback with check
  4. */
  5. utils.invokeCallback = function (cb) {
  6. if (!!cb && typeof cb === 'function') {
  7. cb.apply(null, Array.prototype.slice.call(arguments, 1));
  8. }
  9. };
  10. utils.size = function (obj) {
  11. var count = 0;
  12. for (var i in obj) {
  13. if (obj.hasOwnProperty(i) && typeof obj[i] !== 'function') {
  14. count++;
  15. }
  16. }
  17. return count;
  18. };