{"ScriptPreparationCode":"var clientsSeed = [{\r\n __typename: \u0022Client\u0022,\r\n id: 14048,\r\n prefix: null,\r\n firstName: \u0022Adams, Haag and Murray\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: \u0022damiang@pulse360.com\u0022,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Adams, Haag and Murray\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022other\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14049,\r\n prefix: null,\r\n firstName: \u0022Association test\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: \u0022avenida siempre viva 123\u0022,\r\n address2: \u0022\u0022,\r\n city: \u0022Los Angeles\u0022,\r\n state: \u0022CA\u0022,\r\n zip: \u002290016\u0022,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: \u0022damian.galetto@gmail.com\u0022,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Association test\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022other\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14050,\r\n prefix: null,\r\n firstName: \u0022Tilt Digital\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: \u0022103 Burnt\u0022,\r\n address2: \u0022Lower Bourne\u0022,\r\n city: \u0022Farnham\u0022,\r\n state: \u0022SRY\u0022,\r\n zip: \u002200GU1-03lh\u0022,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: \u0022jamie@tiltdigital.com\u0022,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Tilt Digital\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14051,\r\n prefix: null,\r\n firstName: \u0022Osinski, Goodwin and Bogan\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Osinski, Goodwin and Bogan\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14052,\r\n prefix: null,\r\n firstName: \u0022Rice and Sons\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Rice and Sons\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14053,\r\n prefix: null,\r\n firstName: \u0022Kihn Inc\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Kihn Inc\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14054,\r\n prefix: null,\r\n firstName: \u0022Marks Group\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Marks Group\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022NON_EXISTENT\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14055,\r\n prefix: null,\r\n firstName: \u0022Grant-Kilback\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Grant-Kilback\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14056,\r\n prefix: null,\r\n firstName: \u0022Leannon and Sons\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Leannon and Sons\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14057,\r\n prefix: null,\r\n firstName: \u0022Langosh-Wilkinson\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Langosh-Wilkinson\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14058,\r\n prefix: null,\r\n firstName: \u0022Wolf and Sons\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Wolf and Sons\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n {\r\n __typename: \u0022Client\u0022,\r\n id: 14059,\r\n prefix: null,\r\n firstName: \u0022Homenick-MacGyver\u0022,\r\n middle: null,\r\n lastName: null,\r\n suffix: null,\r\n address1: null,\r\n address2: null,\r\n city: null,\r\n state: null,\r\n zip: null,\r\n businessPhone: null,\r\n homePhone: null,\r\n email: null,\r\n dob: null,\r\n gender: null,\r\n salutation: null,\r\n company: \u0022Homenick-MacGyver\u0022,\r\n greeting: null,\r\n spouse: null,\r\n aliases: null,\r\n goals: [],\r\n type: \u0022company\u0022,\r\n existsInCrm: \u0022EXISTS\u0022,\r\n checklist: null,\r\n external_assets: [],\r\n future_strategies: [],\r\n social_media: null,\r\n },\r\n];\r\n\r\nvar clients = Array.from({length: 10000}, () =\u003E clientsSeed[Math.floor(Math.random()*clientsSeed.length)]);\r\n\r\nfunction getAliases(aliases = \u0027\u0027){\r\n return (aliases || \u0027\u0027).split(\u0027||\u0027).filter(Boolean).map((value, index) =\u003E ({\r\n crmOrFirst: !index,\r\n value: value.replaceAll(\u0027__default\u0027, \u0027\u0027),\r\n isDefault: value.includes(\u0027__default\u0027),\r\n rawValue: value,\r\n }))\r\n }\r\n\r\nfunction getAlias(client){\r\n const { aliases } = client\r\n const alias = getAliases(aliases)\r\n if (alias.length === 0) {\r\n return null\r\n }\r\n return alias[0].value\r\n}\r\n\r\n\r\nfunction getClientNameWithAlias(client) {\r\n if (!client) {\r\n return \u0027None Selected\u0027\r\n }\r\n const { firstName, lastName, salutation, greeting, suffix, middle } = client\r\n const alias = getAlias(client)\r\n const formatedAlias = alias ? \u0060 \u0022${alias}\u0022\u0060 : \u0027\u0027\r\n\r\n if (lastName) {\r\n let name = lastName\r\n\r\n if (firstName) {\r\n name = \u0060${name}, ${firstName}\u0060\r\n name = \u0060${name} ${formatedAlias}\u0060\r\n if (middle) {\r\n name = \u0060${name}, ${middle}\u0060\r\n }\r\n\r\n if (suffix) {\r\n name = \u0060${name}, ${suffix}\u0060\r\n }\r\n }\r\n\r\n return name\r\n }\r\n\r\n if (greeting) {\r\n return greeting\r\n }\r\n if (salutation) {\r\n return salutation\r\n }\r\n return firstName\r\n }\r\n\r\nfunction getFullName(client, isFormal = false) {\r\n if (!client) {\r\n return \u0027None Selected\u0027\r\n }\r\n const { firstName, lastName, suffix, prefix, middle } = client\r\n\r\n if (_.isEmpty(firstName) \u0026\u0026 !_.isEmpty(lastName)) {\r\n return lastName\r\n }\r\n if (!_.isEmpty(firstName) \u0026\u0026 _.isEmpty(lastName)) {\r\n return firstName\r\n }\r\n const suf = suffix ? \u0060, ${suffix}\u0060 : \u0027\u0027\r\n const mid = middle ? \u0060 ${middle}\u0060 : \u0027\u0027\r\n\r\n if (isFormal) {\r\n const pre = prefix ? \u0060${prefix} \u0060 : \u0027\u0027\r\n return \u0060${pre}${firstName}${mid} ${lastName}${suf}\u0060\r\n }\r\n const alias = getAlias(client)\r\n const formatedAlias = alias ? \u0060 \u0022${alias}\u0022\u0060 : \u0027\u0027\r\n\r\n return \u0060${firstName}${formatedAlias}${mid} ${lastName}${suf}\u0060\r\n }\r\n\r\n","TestCases":[{"Name":"map","Code":"clients.map((client) =\u003E ({\r\n ...client,\r\n fullName: getClientNameWithAlias(client),\r\n \t label: getFullName(client)\r\n }))","IsDeferred":false},{"Name":"reduce","Code":"clients.reduce((a, client) =\u003E {\r\n a.push(\r\n {\r\n ...client,\r\n fullName: getClientNameWithAlias(client),\r\n label: getFullName(client)\r\n }\r\n );\r\n \r\n return a\r\n}, [])","IsDeferred":false},{"Name":"for of","Code":"const a = []\r\nfor (const client of clients) {\r\n\ta.push(\r\n {\r\n ...client,\r\n fullName: getClientNameWithAlias(client),\r\n label: getFullName(client)\r\n }\r\n );\r\n};","IsDeferred":false},{"Name":"map less data","Code":"clients.map((client) =\u003E ({\r\n id: client.id,\r\n fullName: getClientNameWithAlias(client),\r\n label: getFullName(client),\r\n existsInCrm: client.existsInCrm,\r\n type: client.type\r\n }))","IsDeferred":false},{"Name":"reduce less data","Code":"clients.reduce((a, client) =\u003E {\r\n a.push(\r\n {\r\n id: client.id,\r\n fullName: getClientNameWithAlias(client),\r\n label: getFullName(client),\r\n existsInCrm: client.existsInCrm,\r\n type: client.type\r\n }\r\n );\r\n \r\n return a\r\n}, [])","IsDeferred":false},{"Name":"for of less data","Code":"const a = []\r\nfor (const client of clients) {\r\n\ta.push(\r\n {\r\n id: client.id,\r\n fullName: getClientNameWithAlias(client),\r\n label: getFullName(client),\r\n existsInCrm: client.existsInCrm,\r\n type: client.type\r\n }\r\n );\r\n};","IsDeferred":false}]}