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

12345678910111213141516171819202122232425262728293031
  1. 'use strict'
  2. const get = require('lodash.get')
  3. const data = require('./simple')
  4. const filterById = (id) => (data) =>
  5. !!(data && ('object' === typeof data) && data.id === id)
  6. const filterByKeys = (pattern) => (data) => {
  7. if (!data || 'object' !== typeof data) return false
  8. for (let key in pattern) {
  9. if (get(data, key) !== pattern[key]) return false
  10. }
  11. return true
  12. }
  13. const stations = (pattern) => {
  14. let matcher
  15. if (pattern === 'all' || pattern === undefined) matcher = () => true
  16. else if ('object' === typeof pattern) matcher = filterByKeys(pattern)
  17. else matcher = filterById(pattern) // todo: make this more efficient
  18. return data.filter(matcher)
  19. }
  20. module.exports = Object.assign(stations, {filterById, filterByKeys})