Skip to content

Instantly share code, notes, and snippets.

View mityaua's full-sized avatar
🍀

Dmytro Shukaliuk mityaua

🍀
View GitHub Profile
@mityaua
mityaua / Promise.js
Created February 1, 2025 16:02
Implementing Promise.all and Promise.allSettled
const promiseAll = (promises) => {
return new Promise((resolve, reject) => {
let results = [];
let completed = 0;
promises.forEach((promise, index) => {
promise
.then((value) => {
completed += 1;
results[index] = { status: "fulfilled", value };
@mityaua
mityaua / regExp.ts
Created October 19, 2022 14:16
Regular expression of Ukrainian mobile number +38 (0##) ###-##-##
const validatePhoneNumber = (phone: string): boolean => {
const regExp = /\+38\s\(0(39|50|63|66|67|68|70|73|90|91|92|93|94|95|96|97|98|99)\)\s[\d]{3}-[\d]{2}-[\d]{2}/g;
return regExp.test(phone);
};
@mityaua
mityaua / luhn-algorithm.js
Last active June 19, 2025 08:52
Luhn Algorithm - Credit Card Number Checker
const checkByLuhn = (card: string): boolean => {
if (!card) {
return false;
}
let checksum: number = 0;
const digits: number[] = card.split("").map(Number);
for (let i = 0; i < digits.length; i += 1) {
@mityaua
mityaua / _for-size.scss
Created August 12, 2022 11:50
SCSS breakpoints mixin
@mixin for-size($range) {
$mobile: 480px;
$tablet: 768px;
$desktop: 1280px;
@if $range == mobile-only {
@media screen and (max-width: #{$mobile - 1}) { @content; }
} @else if $range == mobile {
@media screen and (min-width: $mobile) { @content; }
} @else if $range == tablet {