Skip to content

Commit

Permalink
Handle global correctly in Ringo
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Oct 14, 2011
1 parent e00a687 commit 11d8ffd
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions json-ext.js
Expand Up @@ -106,13 +106,12 @@ replace(/(?:^|:|,|&&)(?:\s*\[)+/g, ''))) {

var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;


var nativeConstructors = {"String":String, "Object":Object, "Number":Number, "Boolean":Boolean, "Array":Array, "Date":Date};
exports.stringify = ({}).toSource ?
// we will use toSource if it is available
(function(){
Object.keys(nativeConstructors).forEach(function(name){
global[name].toSource = function(){
(global[name] || global()[name]).toSource = function(){ // you have to call global() in Rhino. Why?!?
return name;
};
});
Expand Down

0 comments on commit 11d8ffd

Please sign in to comment.