Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*!
  2. * depd
  3. * Copyright(c) 2014-2015 Douglas Christopher Wilson
  4. * MIT Licensed
  5. */
  6. 'use strict'
  7. /**
  8. * Module dependencies.
  9. * @private
  10. */
  11. var EventEmitter = require('events').EventEmitter
  12. /**
  13. * Module exports.
  14. * @public
  15. */
  16. lazyProperty(module.exports, 'callSiteToString', function callSiteToString () {
  17. var limit = Error.stackTraceLimit
  18. var obj = {}
  19. var prep = Error.prepareStackTrace
  20. function prepareObjectStackTrace (obj, stack) {
  21. return stack
  22. }
  23. Error.prepareStackTrace = prepareObjectStackTrace
  24. Error.stackTraceLimit = 2
  25. // capture the stack
  26. Error.captureStackTrace(obj)
  27. // slice the stack
  28. var stack = obj.stack.slice()
  29. Error.prepareStackTrace = prep
  30. Error.stackTraceLimit = limit
  31. return stack[0].toString ? toString : require('./callsite-tostring')
  32. })
  33. lazyProperty(module.exports, 'eventListenerCount', function eventListenerCount () {
  34. return EventEmitter.listenerCount || require('./event-listener-count')
  35. })
  36. /**
  37. * Define a lazy property.
  38. */
  39. function lazyProperty (obj, prop, getter) {
  40. function get () {
  41. var val = getter()
  42. Object.defineProperty(obj, prop, {
  43. configurable: true,
  44. enumerable: true,
  45. value: val
  46. })
  47. return val
  48. }
  49. Object.defineProperty(obj, prop, {
  50. configurable: true,
  51. enumerable: true,
  52. get: get
  53. })
  54. }
  55. /**
  56. * Call toString() on the obj
  57. */
  58. function toString (obj) {
  59. return obj.toString()
  60. }