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.

template.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _interpolation = require('./interpolation');
  7. /**
  8. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  9. *
  10. * This source code is licensed under the MIT license found in the
  11. * LICENSE file in the root directory of this source tree.
  12. *
  13. */
  14. var _default = (title, headings, row) => {
  15. const table = convertRowToTable(row, headings);
  16. const templates = convertTableToTemplates(table, headings);
  17. return templates.map((template, index) => ({
  18. arguments: [template],
  19. title: (0, _interpolation.interpolateVariables)(title, template, index)
  20. }));
  21. };
  22. exports.default = _default;
  23. const convertRowToTable = (row, headings) =>
  24. Array.from({
  25. length: row.length / headings.length
  26. }).map((_, index) =>
  27. row.slice(
  28. index * headings.length,
  29. index * headings.length + headings.length
  30. )
  31. );
  32. const convertTableToTemplates = (table, headings) =>
  33. table.map(row =>
  34. row.reduce(
  35. (acc, value, index) =>
  36. Object.assign(acc, {
  37. [headings[index]]: value
  38. }),
  39. {}
  40. )
  41. );