0

I want to gauge how large my Parse Objects are ahead of time. I have an app that will do lots of addUnique and I'd like to have an idea of how much capacity this is to addUnique to a single Parse Object. I'd like to make sure that I don't bump into or exceed that limit.

rashadb
  • 2,515
  • 4
  • 32
  • 57

1 Answers1

1

This might be of help. It is an answer from another stack overflow question and appears to address your question. There are a lot of comments and info that may help in the post as well.

function roughSizeOfObject( object ) {

    var objectList = [];
    var stack = [ object ];
    var bytes = 0;

    while ( stack.length ) {
        var value = stack.pop();

        if ( typeof value === 'boolean' ) {
            bytes += 4;
        }
        else if ( typeof value === 'string' ) {
            bytes += value.length * 2;
        }
        else if ( typeof value === 'number' ) {
            bytes += 8;
        }
        else if
        (
            typeof value === 'object'
            && objectList.indexOf( value ) === -1
        )
        {
            objectList.push( value );

            for( var i in value ) {
                stack.push( value[ i ] );
            }
        }
    }
    return bytes;
}
Community
  • 1
  • 1
jimrice
  • 452
  • 5
  • 17