MCPcopy Create free account
hub / github.com/breck7/scroll / joinArraysOn

Method joinArraysOn

external/.scrollLibs.js:14239–14253  ·  view source on GitHub ↗
(joinOn, arrays, columns)

Source from the content-addressed store, hash-verified

14237 return this.removeFileExtension(this.getFileName(filepath))
14238 }
14239 static joinArraysOn(joinOn, arrays, columns) {
14240 const rows = {}
14241 let index = 0
14242 if (!columns) columns = arrays.map(arr => Object.keys(arr[0]))
14243 arrays.forEach((arr, index) => {
14244 const cols = columns[index]
14245 arr.forEach(row => {
14246 const key = joinOn ? row[joinOn] : index++
14247 if (!rows[key]) rows[key] = {}
14248 const obj = rows[key]
14249 cols.forEach(col => (obj[col] = row[col]))
14250 })
14251 })
14252 return Object.values(rows)
14253 }
14254 static getParentFolder(path) {
14255 if (path.endsWith("/")) path = this._removeLastSlash(path)
14256 return path.replace(/\/[^\/]*$/, "") + "/"

Callers

nothing calls this directly

Calls 2

mapMethod · 0.80
forEachMethod · 0.80

Tested by

no test coverage detected