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

Function parseParams

lib/encoder.js:2103–2125  ·  view source on GitHub ↗

* @param {String} value * @param {Number} startIndex * @param {Number} length * @param {String} [open] * @param {String} [close] * @returns {Array } * @private

(value, startIndex, length, open, close)

Source from the content-addressed store, hash-verified

2101 * @private
2102 */
2103function parseParams(value, startIndex, length, open, close) {
2104 open = open || '(';
2105 close = close || ')';
2106 const types = [];
2107 let paramStart = startIndex;
2108 let level = 0;
2109 for (let i = startIndex; i < startIndex + length; i++) {
2110 const c = value[i];
2111 if (c === open) {
2112 level++;
2113 }
2114 if (c === close) {
2115 level--;
2116 }
2117 if (level === 0 && c === ',') {
2118 types.push(value.substr(paramStart, i - paramStart));
2119 paramStart = i + 1;
2120 }
2121 }
2122 //Add the last one
2123 types.push(value.substr(paramStart, length - (paramStart - startIndex)));
2124 return types;
2125}
2126
2127/**
2128 * @param {Array.<Buffer>} parts

Callers 1

defineInstanceMembersFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected