nl_tokens: Clones ( copies ) an Object using deep copying .
pl_tokens: function clone ( parent , circular , depth , prototype ) { var filter ; if ( typeof circular === 'object' ) { depth = circular . depth ; prototype = circular . prototype ; filter = circular . filter ; circular = circular . circular } // maintain two arrays for circular references, where corresponding parents // and children have the same index var allParents = [ ] ; var allChildren = [ ] ; var useBuffer = typeof Buffer != 'undefined' ; if ( typeof circular == 'undefined' ) circular = true ; if ( typeof depth == 'undefined' ) depth = Infinity ; // recurse this function so we don't reset allParents and allChildren function _clone ( parent , depth ) { // cloning null always returns null if ( parent === null ) return null ; if ( depth == 0 ) return parent ; var child ; var proto ; if ( typeof parent != 'object' ) { return parent ; } if ( clone . __isArray ( parent ) ) { child = [ ] ; } else if ( clone . __isRegExp ( parent ) ) { child = new RegExp ( parent . source , __getRegExpFlags ( <mask> ) ) ; if ( parent . lastIndex ) child . lastIndex = parent . lastIndex ; } else if ( clone . __isDate ( parent ) ) { child = new Date ( parent . getTime ( ) ) ; } else if ( useBuffer && Buffer . isBuffer ( parent ) ) { child = new Buffer ( parent . length ) ; parent . copy ( child ) ; return child ; } else { if ( typeof prototype == 'undefined' ) { proto = Object . getPrototypeOf ( parent ) ; child = Object . create ( proto ) ; } else { child = Object . create ( prototype ) ; proto = prototype ; } } if ( circular ) { var index = allParents . indexOf ( parent ) ; if ( index != - 1 ) { return allChildren [ index ] ; } allParents . push ( parent ) ; allChildren . push ( child ) ; } for ( var i in parent ) { var attrs ; if ( proto ) { attrs = Object . getOwnPropertyDescriptor ( proto , i ) ; } if ( attrs && attrs . set == null ) { continue ; } child [ i ] = _clone ( parent [ i ] , depth - 1 ) ; } return child ; } return _clone ( parent , depth ) ; }