Skip to content

Instantly share code, notes, and snippets.

View littledian's full-sized avatar
🤒
Out sick

littledian

🤒
Out sick
View GitHub Profile
const getUserInfo = (function() {
let userInfo = null
let promise = null
return function(cb) {
if (!userInfo && !promise) {
promise = new Promise(resolve => {
setTimeout(() => {
userInfo = {username: 'littledian'}
resolve()
cb && cb(userInfo)
function generateRandomPassword() {
const randomChar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
const randomNum = '0123456789'
const randomSymbol = '!@#$%^&*()'
const getRandomChar = () => randomChar[Math.floor(Math.random() * randomChar.length)]
const getRandomNum = () => randomNum[Math.floor(Math.random() * randomNum.length)]
const getRandomSymbol = () => randomSymbol[Math.floor(Math.random() * randomSymbol.length)]
const passwordLength = 8