MCPcopy Create free account
hub / github.com/ThatGuySam/doesitarm / sizeof

Function sizeof

helpers/macho/memory.js:18–45  ·  view source on GitHub ↗
(object)

Source from the content-addressed store, hash-verified

16}
17
18export function sizeof(object) {
19
20 var objectList = [];
21 var stack = [object];
22 var bytes = 0;
23
24 while (stack.length) {
25 var value = stack.pop();
26
27 if (typeof value === 'boolean') {
28 bytes += 4;
29 } else if (typeof value === 'string') {
30 bytes += value.length * 2;
31 } else if (typeof value === 'number') {
32 bytes += 8;
33 } else if (
34 typeof value === 'object' &&
35 objectList.indexOf(value) === -1
36 ) {
37 objectList.push(value);
38
39 for (var i in value) {
40 stack.push(value[i]);
41 }
42 }
43 }
44 return bytes;
45}
46
47/*
48 Functions for swapping the endianness of an integer

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected