mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
16 lines
373 B
TypeScript
16 lines
373 B
TypeScript
import { isNull, isUndefined } from 'lodash';
|
|
|
|
export function assocItemEntriesDefaultIndex<T>(
|
|
entries: Array<T & { index?: number }>,
|
|
): Array<T & { index: number }> {
|
|
return entries.map((entry, index) => {
|
|
return {
|
|
index:
|
|
isUndefined(entry.index) || isNull(entry.index)
|
|
? index + 1
|
|
: entry.index,
|
|
...entry,
|
|
};
|
|
});
|
|
}
|