Guest User

Untitled

a guest
Nov 16th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. sum = Neos.Fusion:Reduce {
  2. items = ${ __array_of_products__ }
  3. initialValue = 0
  4. itemReducer = ${carry + item.price}
  5. }
  6.  
  7. cheapest = Neos.Fusion:Reduce {
  8. items = ${ __array_of_products__ }
  9. initialValue = null
  10. itemReducer = ${(!carry || carry.price > item.price) ? item : carry}
  11. }
  12.  
  13. filtered = Neos.Fusion:Reduce {
  14. items = ${ __array_of_products__ }
  15. initialValue = ${[]}
  16. itemReducer = ${(item.price > 99) ? Array.push(carry, item) : carry}
  17. }
  18.  
  19. #
  20. # This requires new Array.set methods
  21. #
  22. grouped = Neos.Fusion:Reduce {
  23. items = ${ __array_of_products__ }
  24. initialValue = ${[]}
  25. itemReducer = News.Fusion:Value {
  26. groupName = ${item.group}
  27. groupCarry = ${carry[ this.groupName ] || []}
  28. groupValue = ${Array.push(this.groupCarry, item)}
  29. value = ${ Array.set(carry, this.groupName, this.groupValue) }
  30. }
  31. }
Add Comment
Please, Sign In to add comment