Skip to content

Instantly share code, notes, and snippets.

View asifsha's full-sized avatar

Asif Sharif asifsha

View GitHub Profile
@Atinux
Atinux / async-foreach.js
Last active October 10, 2023 03:04
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@mirontoli
mirontoli / lang.js
Last active November 3, 2023 15:15
Get Language name based on iso 639-1 code
/**
* @author Anatoly Mironov (mirontoli)
* http://sharepointkunskap.wordpress.com
* http://www.bool.se
*
* http://stackoverflow.com/questions/3605495/generate-a-list-of-localized-language-names-with-links-to-google-translate/14800384#14800384
* http://stackoverflow.com/questions/10997128/language-name-from-iso-639-1-code-in-javascript/14800499#14800499
*
* using Phil Teare's answer on stackoverflow
* http://stackoverflow.com/questions/3217492/list-of-language-codes-in-yaml-or-json/4900304#4900304