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.

globals.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. 'use strict';
  2. function _cycler(items) {
  3. var index = -1;
  4. return {
  5. current: null,
  6. reset: function reset() {
  7. index = -1;
  8. this.current = null;
  9. },
  10. next: function next() {
  11. index++;
  12. if (index >= items.length) {
  13. index = 0;
  14. }
  15. this.current = items[index];
  16. return this.current;
  17. }
  18. };
  19. }
  20. function _joiner(sep) {
  21. sep = sep || ',';
  22. var first = true;
  23. return function () {
  24. var val = first ? '' : sep;
  25. first = false;
  26. return val;
  27. };
  28. } // Making this a function instead so it returns a new object
  29. // each time it's called. That way, if something like an environment
  30. // uses it, they will each have their own copy.
  31. function globals() {
  32. return {
  33. range: function range(start, stop, step) {
  34. if (typeof stop === 'undefined') {
  35. stop = start;
  36. start = 0;
  37. step = 1;
  38. } else if (!step) {
  39. step = 1;
  40. }
  41. var arr = [];
  42. if (step > 0) {
  43. for (var i = start; i < stop; i += step) {
  44. arr.push(i);
  45. }
  46. } else {
  47. for (var _i = start; _i > stop; _i += step) {
  48. // eslint-disable-line for-direction
  49. arr.push(_i);
  50. }
  51. }
  52. return arr;
  53. },
  54. cycler: function cycler() {
  55. return _cycler(Array.prototype.slice.call(arguments));
  56. },
  57. joiner: function joiner(sep) {
  58. return _joiner(sep);
  59. }
  60. };
  61. }
  62. module.exports = globals;