Skip to content

Instantly share code, notes, and snippets.

View epranka's full-sized avatar

epranka epranka

View GitHub Profile
@epranka
epranka / dotted-notation-deep-merge.ts
Created January 30, 2024 12:28
Merge Dotted Notation objects
// Type definitions
type Split<S extends string, D extends string> = string extends S
? string[]
: S extends ''
? []
: S extends `${infer T}${D}${infer U}`
? [T, ...Split<U, D>]
: [S];
@epranka
epranka / string-number-string.js
Created January 8, 2020 08:14
Fast way to change variable type between number and string.
let a = '5';
a = +a; // convert it to a number
console.log(a, typeof a); // 5 number
a = ''+a; // convert it back to a string
console.log(a, typeof a); // '5' string