Serialization functions for the Number datatype - Node.js Number

Node.js examples for Number:Format

Description

Serialization functions for the Number datatype

Demo Code


/**//from  w  ww .j av  a 2s  . c  o  m
 *  Serialization functions for the Number datatype.
 */
Number.prototype.serialize = function()
{
    if ( this % 1 != 0 ) // Very crude way of determining type. May be mismatch at server.
    {
        return '<double>' + this + '</double>';
    }
    else
    {
        return '<i4>' + this + '</i4>';
    }
}

Related Tutorials