MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / series

Function series

lib/utils.js:867–893  ·  view source on GitHub ↗

* Similar to async.series(), but instead accumulating the result in an Array, it callbacks with the result of the last * function in the array. * @param {Array. } arr * @param {Function} [callback]

(arr, callback)

Source from the content-addressed store, hash-verified

865 * @param {Function} [callback]
866 */
867function series(arr, callback) {
868 if (!Array.isArray(arr)) {
869 throw new TypeError('First parameter must be an Array');
870 }
871 callback = callback || noop;
872 let index = 0;
873 let sync;
874 next();
875 function next(err, result) {
876 if (err) {
877 return callback(err);
878 }
879 if (index === arr.length) {
880 return callback(null, result);
881 }
882 if (sync) {
883 return process.nextTick(function () {
884 sync = true;
885 arr[index++](next);
886 sync = false;
887 });
888 }
889 sync = true;
890 arr[index++](next);
891 sync = false;
892 }
893}
894
895/**
896 * @param {Number} count

Callers

nothing calls this directly

Calls 1

nextFunction · 0.70

Tested by

no test coverage detected