Last active
September 19, 2024 20:49
-
-
Save getify/9d583553d5ada22917f488f01dbc78c2 to your computer and use it in GitHub Desktop.
Revisions
-
getify revised this gist
Sep 19, 2024 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ const buckets = [ const specialValue = 42; let count = 0; for (const [ userID, bucket ] of Object.entries(buckets)) { if (isEligible(specialValue,userID)) { count++; bucket.add(specialValue); -
getify revised this gist
Sep 19, 2024 . 2 changed files with 6 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,16 +2,16 @@ function isEligible(value,userID) { // .. whatever arbitrary logic .. } const buckets = [ user1: new Set(), user2: new Set(), user3: new Set(), user4: new Set() } const specialValue = 42; let count = 0; for (let [ userID, bucket ] of Object.entries(buckets)) { if (isEligible(specialValue,userID)) { count++; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,16 +2,16 @@ function isEligible(value,userID) { // .. whatever arbitrary logic .. } const buckets = [ user1: new Set(), user2: new Set(), user3: new Set(), user4: new Set() } const specialValue = 42; const count = ( Object.entries(buckets) .filter(([userID,bucket]) => isEligible(specialValue,userID)) .reduce((counter,[userID,bucket]) => (bucket.add(specialValue),counter+1),0) -
getify revised this gist
Sep 19, 2024 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -20,5 +20,5 @@ for (let [ userID, bucket ] of Object.entries(buckets)) { } if (count >= 2) { console.log("at least 2 users were eligible for the special value!"); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,5 +18,5 @@ var count = ( ); if (count >= 2) { console.log("at least 2 users were eligible for the special value!"); } -
getify revised this gist
Sep 19, 2024 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,6 +10,7 @@ var buckets = [ } var specialValue = 42; var count = 0; for (let [ userID, bucket ] of Object.entries(buckets)) { if (isEligible(specialValue,userID)) { -
getify created this gist
Sep 19, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ function isEligible(value,userID) { // .. whatever arbitrary logic .. } var buckets = [ user1: new Set(), user2: new Set(), user3: new Set(), user4: new Set() } var specialValue = 42; var count = 0; for (let [ userID, bucket ] of Object.entries(buckets)) { if (isEligible(specialValue,userID)) { count++; bucket.add(specialValue); } } if (count >= 2) { console.log("at least 2 users were eligible for the magic value!"); } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ function isEligible(value,userID) { // .. whatever arbitrary logic .. } var buckets = [ user1: new Set(), user2: new Set(), user3: new Set(), user4: new Set() } var specialValue = 42; var count = ( Object.entries(buckets) .filter(([userID,bucket]) => isEligible(specialValue,userID)) .reduce((counter,[userID,bucket]) => (bucket.add(specialValue),counter+1),0) ); if (count >= 2) { console.log("at least 2 users were eligible for the magic value!"); }