purityselect_admin/resources/js/plugins/fake-api/utils/genId.js
2024-10-25 19:58:19 +05:00

9 lines
183 B
JavaScript

export const genId = array => {
const { length } = array
let lastIndex = 0
if (length)
lastIndex = Number(array[length - 1]?.id) + 1
return lastIndex || (length + 1)
}