Advertisement
KoctrX

Untitled

Oct 28th, 2022
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. function pasteObjectByUUID(data, object, uuid) {
  2. if(Array.isArray(data)) {
  3. return data.reduce((res, item) => {
  4. if(item.data) {
  5. for(const key in item.data) {
  6. item.data[key] = pasteObjectByUUID(item.data[key], object, uuid);
  7. }
  8. }
  9.  
  10. res.push(item);
  11. if(item.uuid == uuid) res.push(object);
  12.  
  13. return res;
  14. }, []).filter(q => q);
  15. } else {
  16. return data;
  17. }
  18.  
  19. return data;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement