lib/common.js
function serializeInternal(obj, refs, stack) {
  var type = typeof obj, sign = '', className, value, ref;

  // Return up front on
  if (1 / obj === -Infinity) {
    sign = '-';
  }

  // Return quickly for primitives to save cycles
  if (isPrimitive(obj, type) && !isRealNaN(obj)) {
    return type + sign + obj;
  }

  className = classToString(obj);

  if (!isSerializable(obj, className)) {
    ref = indexOf(refs, obj);
    if (ref === -1) {
      ref = refs.length;
      refs.push(obj);
    }
    return ref;
  } else if (isObjectType(obj)) {
    value = serializeDeep(obj, refs, stack) + obj.toString();
  } else if (obj.valueOf) {
    value = obj.valueOf();
  }
  return type + className + sign + value;
}
function serializeInternal(obj, refs, stack) {
  var type = typeof obj, sign = '', className, value, ref;

  // Return up front on
  if (1 / obj === -Infinity) {
    sign = '-';
  }

  // Return quickly for primitives to save cycles
  if (isPrimitive(obj, type) && !isRealNaN(obj)) {
    return type + sign + obj;
  }

  className = classToString(obj);

  if (!isSerializable(obj, className)) {
    ref = indexOf(refs, obj);
    if (ref === -1) {
      ref = refs.length;
      refs.push(obj);
    }
    return ref;
  } else if (isObjectType(obj)) {
    value = serializeDeep(obj, refs, stack) + obj.toString();
  } else if (obj.valueOf) {
    value = obj.valueOf();
  }
  return type + className + sign + value;
}
function serializeInternal ( obj , refs , stack ) { var type = typeof obj , sign = '' , className , value , ref ; // Return up front on if ( 1 / obj === - Infinity ) { sign = '-' ; } // Return quickly for primitives to save cycles if ( isPrimitive ( obj , type ) && ! isRealNaN ( obj ) ) { return type + sign + obj ; } className = classToString ( obj ) ; if ( ! isSerializable ( obj , className ) ) { ref = indexOf ( refs , obj ) ; if ( ref === - 1 ) { ref = refs . length ; refs . push ( obj ) ; } return ref ; } else if ( isObjectType ( obj ) ) { value = serializeDeep ( obj , refs , stack ) + obj . toString ( ) ; } else if ( obj . valueOf ) { value = obj . valueOf ( ) ; } return type + className + sign + value ; }
Serializes an object in a way that will provide a token unique to the type, class, and value of an object. Host objects, class instances etc, are not serializable, and are held in an array of references that will return the index as a unique identifier for the object. This array is passed from outside so that the calling function can decide when to dispose of this array.
Serializes an object in a way that will provide a token unique to the type class and value of an object . Host objects class instances etc are not serializable and are held in an array of references that will return the index as a unique identifier for the object . This array is passed from outside so that the calling function can decide when to dispose of this array .