electrodb
Advanced tools
Comparing version 3.1.0 to 3.2.0
{ | ||
"name": "electrodb", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "A library to more easily create and interact with multiple entities and heretical relationships in dynamodb", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,2 +22,3 @@ const { | ||
this.refs = {}; | ||
this.formattedNameToOriginalNameMap = new Map(); | ||
} | ||
@@ -34,10 +35,24 @@ | ||
const nameWasNotANumber = isNaN(name); | ||
name = `${name}`.replaceAll(/[^\w]/g, ""); | ||
if (name.length === 0) { | ||
name = "p"; | ||
} else if (nameWasNotANumber !== isNaN(name)) { | ||
const originalName = `${name}`; | ||
let formattedName = originalName.replaceAll(/[^\w]/g, ""); | ||
if (formattedName.length === 0) { | ||
formattedName = "p"; | ||
} else if (nameWasNotANumber !== isNaN(formattedName)) { | ||
// name became number due to replace | ||
name = `p${name}`; | ||
formattedName = `p${formattedName}`; | ||
} | ||
return name; | ||
const originalFormattedName = formattedName; | ||
let nameSuffix = 1; | ||
while ( | ||
this.formattedNameToOriginalNameMap.has(formattedName) && | ||
this.formattedNameToOriginalNameMap.get(formattedName) !== originalName | ||
) { | ||
formattedName = `${originalFormattedName}_${++nameSuffix}`; | ||
} | ||
this.formattedNameToOriginalNameMap.set(formattedName, originalName); | ||
return formattedName; | ||
} | ||
@@ -44,0 +59,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
552967
17443