Skip to content

Instantly share code, notes, and snippets.

$supports-first-class-calc: calc(1) == 1;
@function divide-portable($number1, $number2) {
@if $supports-first-class-calc {
@return calc($number1 / $number2);
} @else {
@return $number1 / $number2;
}
}
@strogonoff
strogonoff / flatten.ts
Last active June 19, 2025 05:54
Object (un)flattening in TypeScript
// Based on original implementation from Tofandel’s answer: https://stackoverflow.com/a/59787588/247441
/* Aggregates parts (mapped to slash-separated paths) into a nested object.
E.g.:
{ /some/path: A, /foo: B, /some/other/path: C }
gets turned into:
{ foo: B, some: { path: A, other: { path: C } } }
*/