-
-
Save MRezaSafari/c5198e258885687522a8f2222f232dcd to your computer and use it in GitHub Desktop.
function serverObjectsSanitizer<T>(input: T, ignoreList: string[]): T { | |
if (Array.isArray(input)) | |
return input.map((i) => | |
serverObjectsSanitizer(i, ignoreList) | |
) as unknown as T; | |
if (typeof input == 'object' && input != null) | |
return Object.keys(input).reduce((t, c) => { | |
const before = input[c]; | |
if (ignoreList.indexOf(c) > -1) { | |
delete t[c]; | |
} else { | |
t[c] = serverObjectsSanitizer(before, ignoreList); | |
} | |
return t; | |
}, {}) as unknown as T; | |
return input as unknown as T; | |
} | |
export default serverObjectsSanitizer; |
it's a simple function that accepts a generic type and returns it as it should ...
I think its because you don't understand it. that's why you hate it.
hate TypeScript, makes the code look dump
maybe report abuse cause its really abusing my mind
it's a simple function that accepts a generic type and returns it as it should ...
I think its because you don't understand it. that's why you hate it.
hate TypeScript, makes the code look dump
maybe report abuse cause its really abusing my mind
There is a piece of statically typed wrapper to a dynamic type system that is a syntax sugar to a strongly typed language itself btw 🤷
it's a simple function that accepts a generic type and returns it as it should ...
I think its because you don't understand it. that's why you hate it.hate TypeScript, makes the code look dump
maybe report abuse cause its really abusing my mindThere is a piece of statically typed wrapper to a dynamic type system that is a syntax sugar to a strongly typed language itself btw 🤷
That's why I hate it. Otherwise, there is NOTHING difficult in this code that makes it hard to understand :)
hate TypeScript, makes the code look dump
maybe report abuse cause its really abusing my mind