MCPcopy
hub / github.com/bahmutov/code-snippets / stringSize

Function stringSize

keys-vs-values.js:3–6  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

1// measures how much memory object keys take vs values in collection of objects
2(function keysVsValuesInit(root) {
3 function stringSize(str) {
4 // JavaScript strings are unicode UTF-16 up to 2 bytes per character
5 return str.length * 2;
6 }
7
8 function objectSize(obj) {
9 if (typeof obj === 'string') {

Callers 2

objectSizeFunction · 0.70
keysValuesFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected