examples/HTML StarterKit/lib/durandal/js/plugins/serializer.js
function(key, value, getTypeId, getConstructor) {
            var typeId = getTypeId(value);
            if (typeId) {
                var ctor = getConstructor(typeId);
                if (ctor) {
                    if (ctor.fromJSON) {
                        return ctor.fromJSON(value);
                    }

                    return new ctor(value);
                }
            }

            return value;
        }
function(key, value, getTypeId, getConstructor) {
            var typeId = getTypeId(value);
            if (typeId) {
                var ctor = getConstructor(typeId);
                if (ctor) {
                    if (ctor.fromJSON) {
                        return ctor.fromJSON(value);
                    }

                    return new ctor(value);
                }
            }

            return value;
        }
function ( key , value , getTypeId , getConstructor ) { var typeId = getTypeId ( value ) ; if ( typeId ) { var ctor = getConstructor ( typeId ) ; if ( ctor ) { if ( ctor . fromJSON ) { return ctor . fromJSON ( value ) ; } return new ctor ( value ) ; } } return value ; }
The default reviver function used during deserialization. By default is detects type properties on objects and uses them to re-construct the correct object using the provided constructor mapping.
@method reviver
@param {string} key The attribute key.
@param {object} value The object value associated with the key.
@param {function} getTypeId A custom function used to get the type id from a value.
@param {object} getConstructor A custom function used to get the constructor function associated with a type id.
@return {object} The value.
The default reviver function used during deserialization . By default is detects type properties on objects and uses them to re - construct the correct object using the provided constructor mapping .