Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. 'use strict'
  2. var stringify = require('unist-util-stringify-position')
  3. module.exports = VMessage
  4. // Inherit from `Error#`.
  5. function VMessagePrototype() {}
  6. VMessagePrototype.prototype = Error.prototype
  7. VMessage.prototype = new VMessagePrototype()
  8. // Message properties.
  9. var proto = VMessage.prototype
  10. proto.file = ''
  11. proto.name = ''
  12. proto.reason = ''
  13. proto.message = ''
  14. proto.stack = ''
  15. proto.fatal = null
  16. proto.column = null
  17. proto.line = null
  18. // Construct a new VMessage.
  19. //
  20. // Note: We cannot invoke `Error` on the created context, as that adds readonly
  21. // `line` and `column` attributes on Safari 9, thus throwing and failing the
  22. // data.
  23. function VMessage(reason, position, origin) {
  24. var parts
  25. var range
  26. var location
  27. if (typeof position === 'string') {
  28. origin = position
  29. position = null
  30. }
  31. parts = parseOrigin(origin)
  32. range = stringify(position) || '1:1'
  33. location = {
  34. start: {line: null, column: null},
  35. end: {line: null, column: null}
  36. }
  37. // Node.
  38. if (position && position.position) {
  39. position = position.position
  40. }
  41. if (position) {
  42. // Position.
  43. if (position.start) {
  44. location = position
  45. position = position.start
  46. } else {
  47. // Point.
  48. location.start = position
  49. }
  50. }
  51. if (reason.stack) {
  52. this.stack = reason.stack
  53. reason = reason.message
  54. }
  55. this.message = reason
  56. this.name = range
  57. this.reason = reason
  58. this.line = position ? position.line : null
  59. this.column = position ? position.column : null
  60. this.location = location
  61. this.source = parts[0]
  62. this.ruleId = parts[1]
  63. }
  64. function parseOrigin(origin) {
  65. var result = [null, null]
  66. var index
  67. if (typeof origin === 'string') {
  68. index = origin.indexOf(':')
  69. if (index === -1) {
  70. result[1] = origin
  71. } else {
  72. result[0] = origin.slice(0, index)
  73. result[1] = origin.slice(index + 1)
  74. }
  75. }
  76. return result
  77. }