moll / json-stringify-safe

Like JSON.stringify, but doesn't throw on circular references
ISC License
550 stars 51 forks source link

Array replacer raises an error #14

Open gergoerdosi opened 9 years ago

gergoerdosi commented 9 years ago

The documentations says:

The first three arguments are the same as to JSON.stringify.

But when I try to pass an array of strings as the second parameter, the module raises an error:

> var object = { a: 'b', c: 'd' }
undefined
> stringify(object, ['a'])
TypeError: undefined is not a function
    at Object.<anonymous> (/node_modules/json-stringify-safe/stringify.js:25:48)
    at Object.stringify (native)
    at stringify (/node_modules/json-stringify-safe/stringify.js:5:15)
    at repl:1:11
    at REPLServer.defaultEval (repl.js:132:27)
    at bound (domain.js:254:14)
    at REPLServer.runBound [as eval] (domain.js:267:12)
    at REPLServer.<anonymous> (repl.js:279:12)
    at REPLServer.emit (events.js:107:17)
    at REPLServer.Interface._onLine (readline.js:214:10)

The same argument works with JSON.stringify:

> JSON.stringify(object, ['a'])
'{"a":"b"}'
moll commented 9 years ago

Hey! Thanks for the report. You're right. That slipped through. Will fix it. ;-)