Began work on rewriting parser without object orientation
Parsing is expensive, if the parse tree can be stored on the DB it can save a lot of compute time, but mongo can't store Classes, so we re-write without classes
This commit is contained in:
12
app/imports/api/engine/computation/utility/collate.js
Normal file
12
app/imports/api/engine/computation/utility/collate.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// Collate the array with the given value or array of values, creating the
|
||||
// array if it doesn't exist
|
||||
export default function collate(array, toAdd){
|
||||
if (Array.isArray(toAdd) && toAdd.length){
|
||||
if (!array) array = [];
|
||||
array.push(...toAdd);
|
||||
} else if (toAdd) {
|
||||
if (!array) array = [];
|
||||
array.push(toAdd);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
Reference in New Issue
Block a user