Skip to content

Instantly share code, notes, and snippets.

@KnightYoshi
KnightYoshi / oneliners.js
Created March 20, 2023 04:47 — forked from mikowl/oneliners.js
👑 Awesome one-liners you might find useful while coding.
// Inspired by https://twitter.com/coderitual/status/1112297299307384833 and https://tapajyoti-bose.medium.com/7-killer-one-liners-in-javascript-33db6798f5bf
// Remove any duplicates from an array of primitives.
const unique = [...new Set(arr)]
// Sleep in async functions. Use: await sleep(2000).
const sleep = (ms) => (new Promise(resolve => setTimeout(resolve, ms)));
// or
const sleep = util.promisify(setTimeout);

Keybase proof

I hereby claim:

  • I am knightyoshi on github.
  • I am knightyoshi (https://keybase.io/knightyoshi) on keybase.
  • I have a public key ASAkE5ENgx4yBFK_OCDrIib-uaNdfoHYvJKHiL9pqWM3oAo

To claim this, I am signing this object:

# ----------------------------------------------
#
# Specific - CSS property order
#
# Making a description of the object specs,
# from the structural to the cosmetic.
#
# ----------------------------------------------