Skip to content

Instantly share code, notes, and snippets.

View radandevist's full-sized avatar
I'm not drinking coffee, I drink milk instead.

Andrianarisoa Daniel radandevist

I'm not drinking coffee, I drink milk instead.
View GitHub Profile
@radandevist
radandevist / #deepFreeze.ts
Created November 30, 2023 04:13 — forked from tkrotoff/#deepFreeze.ts
Deeply freezes an object
import { ReadonlyDeep } from 'type-fest';
/**
* Deeply freezes an object by recursively freezing all of its properties.
*
* https://gist.github.com/tkrotoff/e997cd6ff8d6cf6e51e6bb6146407fc3
* https://stackoverflow.com/a/69656011
*
* FIXME Should be part of Lodash: https://github.com/Maggi64/moderndash/issues/139
*
@radandevist
radandevist / paths.ts
Created October 13, 2023 18:48 — forked from badsyntax/paths.ts
Fast & Flexible TypeScript dot notation key extraction that supports nested objects to a depth of 10
/**
* Example usage:
*
* // default depth of 3: (fastest)
* type keys = Paths<SomeNestedObject> // returns "property" | "nested.property" | "nested.nested.property"
*
* // depth of 10: (can be slow)
* type keys = Paths<SomeNestedObject, 10>
*
* // depth of 10 with keys of type string and number: (slowest)