12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- 'use strict'
- var EventEmitter = require('events').EventEmitter
- lazyProperty(module.exports, 'callSiteToString', function callSiteToString () {
- var limit = Error.stackTraceLimit
- var obj = {}
- var prep = Error.prepareStackTrace
- function prepareObjectStackTrace (obj, stack) {
- return stack
- }
- Error.prepareStackTrace = prepareObjectStackTrace
- Error.stackTraceLimit = 2
-
- Error.captureStackTrace(obj)
-
- var stack = obj.stack.slice()
- Error.prepareStackTrace = prep
- Error.stackTraceLimit = limit
- return stack[0].toString ? toString : require('./callsite-tostring')
- })
- lazyProperty(module.exports, 'eventListenerCount', function eventListenerCount () {
- return EventEmitter.listenerCount || require('./event-listener-count')
- })
- function lazyProperty (obj, prop, getter) {
- function get () {
- var val = getter()
- Object.defineProperty(obj, prop, {
- configurable: true,
- enumerable: true,
- value: val
- })
- return val
- }
- Object.defineProperty(obj, prop, {
- configurable: true,
- enumerable: true,
- get: get
- })
- }
- function toString (obj) {
- return obj.toString()
- }
|