You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
456 B
17 lines
456 B
'use strict'; |
|
|
|
module.exports = stringify; |
|
function stringify(obj) { |
|
if (obj instanceof Date) { |
|
return 'new Date(' + stringify(obj.toISOString()) + ')'; |
|
} |
|
if (obj === undefined) { |
|
return 'undefined'; |
|
} |
|
return JSON.stringify(obj) |
|
.replace(/\u2028/g, '\\u2028') |
|
.replace(/\u2029/g, '\\u2029') |
|
.replace(/</g, '\\u003C') |
|
.replace(/>/g, '\\u003E') |
|
.replace(/\//g, '\\u002F'); |
|
}
|
|
|