Don't mutate function inputs

#1

Never mutate (e.g. update collection field) of the API input parameter and in general try to make most methods side-effect free. E.g.:

function addToFileList(job, chunk) {
   job.fileList().urls().add(chunk.url());
   return job;
}

is a very dangerous code as caller will not know that you have actually mutated fileList field in the input of this method

1 Like