wdavidw/node-csv — pull request #128 by whitlockjc (2013-09-06 04:39:18+00:00)
Title: Stringifier.write doesn't handle Number objects.

While writing a transform that would attempt to turn string versions of booleans and numbers to their real JavaScript types, I ran into a situation where if my transform updated a row value to be a `Number`, I'd get this:

```
events.js:72
throw er; // Unhandled 'error' event
^
TypeError: Object 357 has no method 'indexOf'
at Stringifier.stringify (/home/me/csv2json/node_modules/csv/lib/stringifier.js:106:35)
at Stringifier.write (/home/me/csv2json/node_modules/csv/lib/stringifier.js:41:33)
at finish (/home/me/csv2json/node_modules/csv/lib/transformer.js:171:21)
at done (/home/me/csv2json/node_modules/csv/lib/transformer.js:202:12)
at run (/home/me/csv2json/node_modules/csv/lib/transformer.js:209:16)
at Transformer.write (/home/me/csv2json/node_modules/csv/lib/transformer.js:222:3)
at null. (/home/me/csv2json/node_modules/csv/lib/index.js:192:29)
at EventEmitter.emit (events.js:95:17)
at Parser.write (/home/me/csv2json/node_modules/csv/lib/parser.js:140:14)
at CSV.write (/home/me/csv2json/node_modules/csv/lib/index.js:275:17)
```

I realize that I can just update my code to use `myNum.valueOf()` but upon looking at the code, it seems you're already trying to do some casting and such so maybe I wasn't doing anything wrong. Anyway, attached is a patch that handles the `Number` object just like the `Date` object. I tried updating the existing number support on line 75 to handle this but since it's a `Number` object and not a number literal, it seems this patch is legit.