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 890B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict'
  2. var own = {}.hasOwnProperty
  3. module.exports = stringify
  4. function stringify(value) {
  5. // Nothing.
  6. if (!value || typeof value !== 'object') {
  7. return ''
  8. }
  9. // Node.
  10. if (own.call(value, 'position') || own.call(value, 'type')) {
  11. return position(value.position)
  12. }
  13. // Position.
  14. if (own.call(value, 'start') || own.call(value, 'end')) {
  15. return position(value)
  16. }
  17. // Point.
  18. if (own.call(value, 'line') || own.call(value, 'column')) {
  19. return point(value)
  20. }
  21. // ?
  22. return ''
  23. }
  24. function point(point) {
  25. if (!point || typeof point !== 'object') {
  26. point = {}
  27. }
  28. return index(point.line) + ':' + index(point.column)
  29. }
  30. function position(pos) {
  31. if (!pos || typeof pos !== 'object') {
  32. pos = {}
  33. }
  34. return point(pos.start) + '-' + point(pos.end)
  35. }
  36. function index(value) {
  37. return value && typeof value === 'number' ? value : 1
  38. }