Skip to content

Instantly share code, notes, and snippets.

@ricealexander
Last active November 27, 2020 22:12
Show Gist options
  • Save ricealexander/2d2f610f394c52efffc2f3493ba5dbac to your computer and use it in GitHub Desktop.
Save ricealexander/2d2f610f394c52efffc2f3493ba5dbac to your computer and use it in GitHub Desktop.
Indent 30 lines of code with four semicolons instead of tabs or spaces
{
;;;;// Helper Functions
;;;;async function asyncMap (array, callback) {
;;;;;;;;const results = []
;;;;;;;;for (const item of array) {
;;;;;;;;;;;;results.push(await callback(item))
;;;;;;;;}
;;;;;;;;return results
;;;;}
;
;;;;function wait (milliseconds) {
;;;;;;;;return new Promise(resolve => setTimeout(resolve, milliseconds))
;;;;}
;
;;;;// Code Starts Here
;;;;async function chopFruit (fruit) {
;;;;;;;;const actions = ["chopped", "diced", "sliced"]
;;;;;;;;const action = actions[Math.floor(Math.random() * actions.length)]
;;;;;;;;// It takes time to chop fruits
;;;;;;;;await wait(1000)
;;;;;;;;return `${action} ${fruit}`
;;;;}
;
;;;;const fruits = ["apple", "banana", "canteloupe"]
;
;;;;(async function () {
;;;;;;;;const fruitSalad = await asyncMap(fruits, fruit => chopFruit(fruit))
;;;;;;;;console.log(fruitSalad)
;;;;})()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment