helper.ecal 588 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. copyMap copies a given map.
  3. */
  4. func copyMap(m) {
  5. let ret := {}
  6. for [k, v] in m {
  7. ret[k] := v
  8. }
  9. return ret
  10. }
  11. /*
  12. max returns the maximum of two numbers.
  13. */
  14. func max(a, b) {
  15. if a > b {
  16. return a
  17. }
  18. return b
  19. }
  20. /*
  21. allNodeKeys returns the keys of all nodes of a certain kind.
  22. */
  23. func allNodeKeys(part, kind) {
  24. let ret := []
  25. let res := db.graphQL("main", "{ {{kind}} { key } }", {"kind" : kind})
  26. if len(res.data[kind]) > 0 {
  27. for o in res.data[kind] {
  28. ret := add(ret, o.key)
  29. }
  30. }
  31. return ret
  32. }