(object: object)
| 582 | } |
| 583 | |
| 584 | export function roughSizeOfObject(object: object): number { |
| 585 | /** Gets the rough memory size of the object in bytes. **/ |
| 586 | let objectList: object[] = []; |
| 587 | |
| 588 | function recurse(value: any): number { |
| 589 | let bytes = 0; |
| 590 | |
| 591 | if (typeof value === "boolean") { |
| 592 | return 4; |
| 593 | } else if (typeof value === "string") { |
| 594 | return value.length * 2; |
| 595 | } else if (typeof value === "number") { |
| 596 | return 8; |
| 597 | } else if (typeof value === "object" && objectList.indexOf(value) === -1) { |
| 598 | objectList[objectList.length] = value; |
| 599 | |
| 600 | for (const i in value) { |
| 601 | bytes += 8; // an assumed existence overhead |
| 602 | bytes += recurse(value[i]); |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | return bytes; |
| 607 | } |
| 608 | |
| 609 | return recurse(object); |
| 610 | } |
| 611 | |
| 612 | export function capitaliseFirstLetter(text: string): string { |
| 613 | return text.replace(/(^\w|\s\w)/g, function (m: string) { |
no test coverage detected