UNPKG

@web3r/flowerkit

Version:

Tree-shakable JavaScript and TypeScript utility library for frontend/browser apps: DOM, events, arrays, objects, strings, date, JSON, and network helpers (ESM/CJS, SSR-friendly).

1 lines 933 B
{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["export type TIsItemsEqualArgs = Parameters<typeof isItemsEqual>;\r\n\r\nexport type TIsItemsEqualReturn = ReturnType<typeof isItemsEqual>;\r\n\r\n/**\r\n * Checks if items of given Array is same\r\n * @template T\r\n * @param {Array<T>} arr source Array\r\n * @returns {boolean}\r\n * @example\r\n * // How to check if all records are equal in an array?\r\n * const arr = [ 1, 1, 1 ];\r\n * const isSame = isItemsEqual(arr);\r\n * console.log(isSame); // => true\r\n */\r\nexport const isItemsEqual = <T>(arr: T[]): boolean => {\r\n if (arr.length === 0) {\r\n return true;\r\n }\r\n const first = arr[0];\r\n return arr.every((val) => val === first);\r\n};\r\n"],"names":["isItemsEqual","arr","length","first","every","val"],"mappings":";;;;;;;;;;;AAeO,MAAMA,aAAmBC,MAC9B,GAAIA,IAAIC,SAAW,EACjB,OAAO,KAET,MAAMC,MAAQF,IAAI,GAClB,OAAOA,IAAIG,MAAOC,KAAQA,MAAQF"}