Guest User

Untitled

a guest
Feb 17th, 2021
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2. const gay = [
  3.     {
  4.         position: 1, attributes: {}
  5.     },
  6.     {
  7.         position: 2,
  8.         attributes: {
  9.             'section-item': { depth: '1', id: '6be8bd63-6488-4276-8efb-e991888e9ff5' }
  10.         },
  11.     },
  12.     {
  13.         position: 3,
  14.         attributes: {
  15.             list: {
  16.                 depth: '1',
  17.                 sectionId: '6be8bd63-6488-4276-8efb-e991888e9ff5',
  18.             }
  19.         },
  20.     },
  21.     {
  22.         position: 4,
  23.         attributes: {
  24.             'section-item': { depth: '2', id: 'e7b8c86c-b4d5-4873-a20c-446ef95224b2' }
  25.         },
  26.     },
  27.     {
  28.         position: 5,
  29.         attributes: {
  30.             list: {
  31.                 depth: '2',
  32.                 sectionId: 'e7b8c86c-b4d5-4873-a20c-446ef95224b2',
  33.             }
  34.         },
  35.     },
  36. ];
  37. let sex = (hmm) => {
  38.     const piss = hmm.sort((dick, cock) => dick.position - cock.position)
  39.         .map(kek => ({ ...kek, children: [] }))
  40.         .map((kek) => [kek, false]);
  41.     return piss.map(kek => ass(piss, kek[0]))
  42.         .filter(kek => (piss.find(anal => anal[0].position === kek.position)?.[1] ?? true) === false);
  43. };
  44. let ass = (hmm, fuck) => {
  45.     let dick = {
  46.         ...fuck,
  47.         children: fuck.attributes["section-item"] === undefined ? [] :
  48.             hmm.filter(kek => kek[0].position > fuck.position).map(kek => {
  49.                 if (kek[1])
  50.                     return null;
  51.                 kek[1] = true;
  52.                 return ass(hmm, kek[0]);
  53.             }),
  54.     };
  55.     return {
  56.         ...dick,
  57.         children: dick.children.filter(kek => kek !== null),
  58.     };
  59. };
  60. // Let's On Gay Party!
  61. console.log(sex(gay));
Add Comment
Please, Sign In to add comment