MCPcopy Create free account
hub / github.com/OpenWebCAD/node-occ / replaceObjectsByGUUID

Function replaceObjectsByGUUID

lib/fastbuilder.js:201–227  ·  view source on GitHub ↗

*

(arg)

Source from the content-addressed store, hash-verified

199 *
200 */
201function replaceObjectsByGUUID(arg) {
202
203 const toUUID = el => el.uuid;
204
205 if (!arg) {
206 return null;
207 }
208 if (arg.hasOwnProperty("uuid")) {
209 return toUUID(arg);
210 } else if ((arg.length > 0 && typeof arg[0] === "number") || (typeof arg === "number")) {
211 return arg;
212 } else if (arg.length > 0 && (arg[0] instanceof Object) && arg[0].hasOwnProperty("uuid")) {
213 debugLog(" Found an array of object with guiid", (`arg ${arg.map(el => el.uuid)}`));
214 return arg.map(replaceObjectsByGUUID);
215
216 } else {
217 if (arg.hashCode) {
218 return hash(`---${arg.hashCode}`);
219 }
220 // we can"t use cache yet
221 const tmp = arg;
222 // .map(toUUID);
223 debugLog(" ERROR : Cannot use cache with object ", typeof arg, JSON.stringify(tmp));
224
225 return tmp;
226 }
227}
228
229function calculateOperationHash(methodName, theArguments) {
230

Callers 1

calculateOperationHashFunction · 0.85

Calls 3

toUUIDFunction · 0.85
hashFunction · 0.85
debugLogFunction · 0.70

Tested by

no test coverage detected