UNPKG

@tempots/dom

Version:

Fully-typed frontend framework alternative to React and Angular

57 lines (56 loc) 1.57 kB
import { Signal } from './signal'; /** * Represents the position of an element in a collection. * * @public */ export declare class ElementPosition { #private; /** * The index of the element. */ readonly index: number; /** * The total number of elements in the collection. */ readonly total: Signal<number>; /** * The counter of the element starting from 1. */ readonly counter: number; /** * Checks if the element is the first element in the collection. * @returns `true` if the element is the first element, `false` otherwise. */ readonly isFirst: boolean; /** * Checks if the counter of the element is even. * @returns `true` if the counter is even, `false` otherwise. */ readonly isEven: boolean; /** * Checks if the counter of the element is odd. * @returns `true` if the counter is odd, `false` otherwise. */ readonly isOdd: boolean; /** * Creates a new instance of `ElementPosition`. * @param index - The index of the element. * @param total - The total number of elements in the collection. */ constructor( /** * The index of the element. */ index: number, /** * The total number of elements in the collection. */ total: Signal<number>); /** * Checks if the element is the last element in the collection. * @returns `true` if the element is the last element, `false` otherwise. */ get isLast(): Signal<boolean>; readonly dispose: () => void; }