source: trip-planner-front/node_modules/depd/lib/compat/index.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[6a3a178]1/*!
2 * depd
3 * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 * MIT Licensed
5 */
6
7'use strict'
8
9/**
10 * Module dependencies.
11 * @private
12 */
13
14var EventEmitter = require('events').EventEmitter
15
16/**
17 * Module exports.
18 * @public
19 */
20
21lazyProperty(module.exports, 'callSiteToString', function callSiteToString () {
22 var limit = Error.stackTraceLimit
23 var obj = {}
24 var prep = Error.prepareStackTrace
25
26 function prepareObjectStackTrace (obj, stack) {
27 return stack
28 }
29
30 Error.prepareStackTrace = prepareObjectStackTrace
31 Error.stackTraceLimit = 2
32
33 // capture the stack
34 Error.captureStackTrace(obj)
35
36 // slice the stack
37 var stack = obj.stack.slice()
38
39 Error.prepareStackTrace = prep
40 Error.stackTraceLimit = limit
41
42 return stack[0].toString ? toString : require('./callsite-tostring')
43})
44
45lazyProperty(module.exports, 'eventListenerCount', function eventListenerCount () {
46 return EventEmitter.listenerCount || require('./event-listener-count')
47})
48
49/**
50 * Define a lazy property.
51 */
52
53function lazyProperty (obj, prop, getter) {
54 function get () {
55 var val = getter()
56
57 Object.defineProperty(obj, prop, {
58 configurable: true,
59 enumerable: true,
60 value: val
61 })
62
63 return val
64 }
65
66 Object.defineProperty(obj, prop, {
67 configurable: true,
68 enumerable: true,
69 get: get
70 })
71}
72
73/**
74 * Call toString() on the obj
75 */
76
77function toString (obj) {
78 return obj.toString()
79}
Note: See TracBrowser for help on using the repository browser.