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 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. self.Flatted = (function (exports) {
  2. 'use strict';
  3. /*! (c) 2020 Andrea Giammarchi */
  4. var $parse = JSON.parse,
  5. $stringify = JSON.stringify;
  6. var keys = Object.keys;
  7. var Primitive = String; // it could be Number
  8. var primitive = 'string'; // it could be 'number'
  9. var ignore = {};
  10. var object = 'object';
  11. var noop = function noop(_, value) {
  12. return value;
  13. };
  14. var primitives = function primitives(value) {
  15. return value instanceof Primitive ? Primitive(value) : value;
  16. };
  17. var Primitives = function Primitives(_, value) {
  18. return typeof(value) === primitive ? new Primitive(value) : value;
  19. };
  20. var revive = function revive(input, parsed, output, $) {
  21. var lazy = [];
  22. for (var ke = keys(output), length = ke.length, y = 0; y < length; y++) {
  23. var k = ke[y];
  24. var value = output[k];
  25. if (value instanceof Primitive) {
  26. var tmp = input[value];
  27. if (typeof(tmp) === object && !parsed.has(tmp)) {
  28. parsed.add(tmp);
  29. output[k] = ignore;
  30. lazy.push({
  31. k: k,
  32. a: [input, parsed, tmp, $]
  33. });
  34. } else output[k] = $.call(output, k, tmp);
  35. } else if (output[k] !== ignore) output[k] = $.call(output, k, value);
  36. }
  37. for (var _length = lazy.length, i = 0; i < _length; i++) {
  38. var _lazy$i = lazy[i],
  39. _k = _lazy$i.k,
  40. a = _lazy$i.a;
  41. output[_k] = $.call(output, _k, revive.apply(null, a));
  42. }
  43. return output;
  44. };
  45. var set = function set(known, input, value) {
  46. var index = Primitive(input.push(value) - 1);
  47. known.set(value, index);
  48. return index;
  49. };
  50. var parse = function parse(text, reviver) {
  51. var input = $parse(text, Primitives).map(primitives);
  52. var value = input[0];
  53. var $ = reviver || noop;
  54. var tmp = typeof(value) === object && value ? revive(input, new Set(), value, $) : value;
  55. return $.call({
  56. '': tmp
  57. }, '', tmp);
  58. };
  59. var stringify = function stringify(value, replacer, space) {
  60. var $ = replacer && typeof(replacer) === object ? function (k, v) {
  61. return k === '' || -1 < replacer.indexOf(k) ? v : void 0;
  62. } : replacer || noop;
  63. var known = new Map();
  64. var input = [];
  65. var output = [];
  66. var i = +set(known, input, $.call({
  67. '': value
  68. }, '', value));
  69. var firstRun = !i;
  70. while (i < input.length) {
  71. firstRun = true;
  72. output[i] = $stringify(input[i++], replace, space);
  73. }
  74. return '[' + output.join(',') + ']';
  75. function replace(key, value) {
  76. if (firstRun) {
  77. firstRun = !firstRun;
  78. return value;
  79. }
  80. var after = $.call(this, key, value);
  81. switch (typeof(after)) {
  82. case object:
  83. if (after === null) return after;
  84. case primitive:
  85. return known.get(after) || set(known, input, after);
  86. }
  87. return after;
  88. }
  89. };
  90. var toJSON = function toJSON(any) {
  91. return $parse(stringify(any));
  92. };
  93. var fromJSON = function fromJSON(any) {
  94. return parse($stringify(any));
  95. };
  96. exports.fromJSON = fromJSON;
  97. exports.parse = parse;
  98. exports.stringify = stringify;
  99. exports.toJSON = toJSON;
  100. return exports;
  101. }({}));