MCPcopy Create free account
hub / github.com/handsontable/handsontable / recursiveDuckColumns

Method recursiveDuckColumns

handsontable/src/dataMap/dataMap.ts:236–256  ·  view source on GitHub ↗

* Generates columns' translation cache. * * @param {object} schema An object to generate schema from. * @param {number} lastCol The column index. * @param {number} parent The property cache for recursive calls. * @returns {number}

(schema: unknown, lastCol?: number, parent?: string)

Source from the content-addressed store, hash-verified

234 * @returns {number}
235 */
236 recursiveDuckColumns(schema: unknown, lastCol?: number, parent?: string) {
237 let lastColumn: number = lastCol ?? 0;
238 const propertyParent: string = parent ?? '';
239 let prop;
240
241 if (typeof schema === 'object' && schema !== null && !Array.isArray(schema)) {
242 objectEach(schema, (value: unknown, key: string) => {
243 if (value === null) {
244 prop = propertyParent + key;
245 this.colToPropCache.push(prop);
246 this.propToColCache!.set(prop, lastColumn);
247
248 lastColumn += 1;
249 } else if (typeof value === 'object' && value !== null) {
250 lastColumn = this.recursiveDuckColumns(value, lastColumn, `${key}.`);
251 }
252 });
253 }
254
255 return lastColumn;
256 }
257
258 /**
259 * Returns property name that corresponds with the given column index.

Callers 1

createMapMethod · 0.95

Calls 3

objectEachFunction · 0.90
pushMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected