This file contains 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 characters
function declOfNum(number, titles) { | |
const cases = [2, 0, 1, 1, 1, 2]; | |
return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; | |
} | |
// example | |
declOfNum(1, ['день', 'дня', 'дней']); // 1 день | |
declOfNum(2, ['день', 'дня', 'дней']); // 2 дня | |
declOfNum(5, ['день', 'дня', 'дней']); // 5 дней |
This file contains 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 characters
const browsers = ['Chrome', 'Firefox', 'Edge', 'Safari', 'Opera']; | |
// for in | |
for (const browser in browsers) { | |
console.log(browser, '---', browsers[browser]); | |
} | |
// output | |
// "0" "---" "Chrome" | |
// "1" "---" "Firefox" | |
// "2" "---" "Edge" |
This file contains 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 characters
react-native link <lib name> | |
// this command has done the unlinking of the library from both platforms. | |
react-native unlink <lib name> | |
// this has uninstalled the library from the node modules and its dependencies | |
react-native uninstall <lib name> |
This file contains 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 characters
import { resolve, extname, basename } from 'path'; | |
import fsPromises from 'fs/promises'; | |
// @ts-ignore | |
async function* getFiles(dir: string) { | |
const dirents = await fsPromises.readdir(dir, { withFileTypes: true }); | |
for (const dirent of dirents) { | |
const res = resolve(dir, dirent.name); | |
if (dirent.isDirectory()) { | |
yield* getFiles(res); |