Guest User

Untitled

a guest
Nov 19th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. export class FunctionalUtil{
  2.  
  3. static removeItem<T>(arr: T[], index: number): T[]{
  4. return [
  5. ...arr.slice(0, index),
  6. ...arr.slice(index + 1)
  7. ];
  8. }
  9.  
  10. static replaceItem<T>(arr: T[], item: T, index: number): T[]{
  11. return[
  12. ...arr.slice(0, index),
  13. item,
  14. ...arr.slice(index +1)
  15. ];
  16. }
  17.  
  18. static addItem<T>(arr: T[], item: T): T[]{
  19. return [...arr, item];
  20. }
  21. }
Add Comment
Please, Sign In to add comment