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.

utils.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. "use strict";
  2. function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } it = o[Symbol.iterator](); return it.next.bind(it); }
  3. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  4. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  5. var list = require('postcss').list;
  6. module.exports = {
  7. /**
  8. * Throw special error, to tell beniary,
  9. * that this error is from Autoprefixer.
  10. */
  11. error: function error(text) {
  12. var err = new Error(text);
  13. err.autoprefixer = true;
  14. throw err;
  15. },
  16. /**
  17. * Return array, that doesn’t contain duplicates.
  18. */
  19. uniq: function uniq(array) {
  20. var filtered = [];
  21. for (var _iterator = _createForOfIteratorHelperLoose(array), _step; !(_step = _iterator()).done;) {
  22. var i = _step.value;
  23. if (!filtered.includes(i)) {
  24. filtered.push(i);
  25. }
  26. }
  27. return filtered;
  28. },
  29. /**
  30. * Return "-webkit-" on "-webkit- old"
  31. */
  32. removeNote: function removeNote(string) {
  33. if (!string.includes(' ')) {
  34. return string;
  35. }
  36. return string.split(' ')[0];
  37. },
  38. /**
  39. * Escape RegExp symbols
  40. */
  41. escapeRegexp: function escapeRegexp(string) {
  42. return string.replace(/[$()*+-.?[\\\]^{|}]/g, '\\$&');
  43. },
  44. /**
  45. * Return regexp to check, that CSS string contain word
  46. */
  47. regexp: function regexp(word, escape) {
  48. if (escape === void 0) {
  49. escape = true;
  50. }
  51. if (escape) {
  52. word = this.escapeRegexp(word);
  53. }
  54. return new RegExp("(^|[\\s,(])(" + word + "($|[\\s(,]))", 'gi');
  55. },
  56. /**
  57. * Change comma list
  58. */
  59. editList: function editList(value, callback) {
  60. var origin = list.comma(value);
  61. var changed = callback(origin, []);
  62. if (origin === changed) {
  63. return value;
  64. }
  65. var join = value.match(/,\s*/);
  66. join = join ? join[0] : ', ';
  67. return changed.join(join);
  68. },
  69. /**
  70. * Split the selector into parts.
  71. * It returns 3 level deep array because selectors can be comma
  72. * separated (1), space separated (2), and combined (3)
  73. * @param {String} selector selector string
  74. * @return {Array<Array<Array>>} 3 level deep array of split selector
  75. * @see utils.test.js for examples
  76. */
  77. splitSelector: function splitSelector(selector) {
  78. return list.comma(selector).map(function (i) {
  79. return list.space(i).map(function (k) {
  80. return k.split(/(?=\.|#)/g);
  81. });
  82. });
  83. }
  84. };