Files
guessit/services/frontend/utils/formatting.ts
2024-01-15 20:49:58 -05:00

16 lines
437 B
TypeScript

const formatDictionaryAsString = (obj: Object, indentation = 2) => {
let result: string = "{\n";
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
let value = obj[key];
let line = ' '.repeat(indentation) + `${key}: '${value}',\n`;
result += line;
}
}
result = result.slice(0, -2);
result += `\n}`;
return result;
}
export default formatDictionaryAsString;