UI for Zipcoin Blue

index.js 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. }