Skip to content
Advertisement

Tag: node.js

convert CSV lines into Javascript objects

I have a simple csv file people.csv: What I want to do it get each line of the CSV, convert it to a JavaScript object, store them into an array, and then convert the array into a JSON object. server.js: My question is if I am actually converting that CSV lines into Javascript objects when I call the .split(‘n’) method

adjust console.log behaviour of custom object

is there any way to influence what console.log gives out custom objects? I tried to overwrite the customObject.prototype.toString method, that did not work though. Any ideas? Answer In node.js, console.log calls util.inspect on each argument without a formatting placeholder. So if you define an inspect(depth, opts) method on your object it will be called to get your custom string representation

How to decode nock recorded response

How to ad-hoc decode/uncompress the output produced by the nock recorder so we can see the response as text? I guess we do not understand if the response is gzipped and/or encoded The object works find when we load it into nock, and our tests are behaving as we expect. To see what the API produced, we are having to

console.log to stdout on gulp events

I want to log to stdout (the config environment) when a gulp task is running or has run. Something like this: I am not sure what event I should be responding to or where to find a list of these. Any pointers? Many thanks. Answer (In December 2017, the gulp-util module, which provided logging, was deprecated. The Gulp team recommended

Advertisement