Type duplicates
This commit is contained in:
parent
b3d18b16cf
commit
8f282d54d2
|
@ -10,13 +10,13 @@
|
||||||
*
|
*
|
||||||
* Repl
|
* Repl
|
||||||
*/
|
*/
|
||||||
export const duplicateName = (name, allNames) => {
|
export const duplicateName = (name: string, allNames: string[]) => {
|
||||||
const duplicatePattern = new RegExp(`\\s(\\d+)$`)
|
const duplicatePattern = new RegExp(`\\s(\\d+)$`)
|
||||||
const baseName = name.split(duplicatePattern)[0]
|
const baseName = name.split(duplicatePattern)[0]
|
||||||
const isDuplicate = new RegExp(`${baseName}\\s(\\d+)$`)
|
const isDuplicate = new RegExp(`${baseName}\\s(\\d+)$`)
|
||||||
|
|
||||||
// get the sequence from matched names
|
// get the sequence from matched names
|
||||||
const sequence = []
|
const sequence: number[] = []
|
||||||
allNames.filter(n => {
|
allNames.filter(n => {
|
||||||
if (n === baseName) {
|
if (n === baseName) {
|
||||||
return true
|
return true
|
||||||
|
@ -71,9 +71,9 @@ export const duplicateName = (name, allNames) => {
|
||||||
* flat array of strings
|
* flat array of strings
|
||||||
*/
|
*/
|
||||||
export const getSequentialName = (
|
export const getSequentialName = (
|
||||||
items,
|
items: string[],
|
||||||
prefix,
|
prefix: string,
|
||||||
{ getName = x => x, numberFirstItem = false } = {}
|
{ getName = (x: string) => x, numberFirstItem = false } = {}
|
||||||
) => {
|
) => {
|
||||||
if (!prefix?.length || !getName) {
|
if (!prefix?.length || !getName) {
|
||||||
return null
|
return null
|
Loading…
Reference in New Issue