@techmely/utils
Version:
Collection of helpful JavaScript / TypeScript utils
24 lines (20 loc) • 513 B
JavaScript
/*!
* @techmely/utils
* Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
* MIT Licensed
*/
// src/firstUniqueArray.ts
function firstUniqueArr(array) {
if (!array || array?.length === 0)
return void 0;
const arrLength = array.length;
if (array.length === 1)
return array[0];
for (let i = 0; i < arrLength; i++) {
const element = array[i];
if (array.indexOf(element) === array.lastIndexOf(element))
return element;
}
return void 0;
}
export { firstUniqueArr };