Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ClientSession.prototype.write = function (nodesToWrite, callback) {
const self = this;
const isArray = _.isArray(nodesToWrite);
if (!isArray) {
nodesToWrite = [nodesToWrite];
}
assert(_.isFunction(callback));
assert(_.isArray(nodesToWrite), "nodesToWrite must be an array");
const request = new write_service.WriteRequest({nodesToWrite: nodesToWrite});
self.performMessageTransaction(request, function (err, response) {
/* istanbul ignore next */
if (err) {
return callback(err, response);
}
if (response.responseHeader.serviceResult.isNot(StatusCodes.Good)) {
return callback(new Error(response.responseHeader.serviceResult.toString()));
}
assert(response instanceof write_service.WriteResponse);
assert(nodesToWrite.length === response.results.length);
callback(null, isArray ? response.results : response.results[0]);
});
};