UNPKG

@techmely/utils

Version:

Collection of helpful JavaScript / TypeScript utils

39 lines (35 loc) 832 B
/*! * @techmely/utils * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com> * MIT Licensed */ import "./chunk-NYLAFCGV.mjs"; // src/unique.ts function firstUniqueChar(value) { if (!value) return void 0; const charLength = value.length; for (let i = 0; i < charLength; i++) { const letter = value[i]; if (value.indexOf(letter) === value.lastIndexOf(letter)) return letter; } return void 0; } 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, firstUniqueChar };