1 | import { PaginationService } from "./pagination.service";
|
2 | export declare type Collection<T> = T[] | ReadonlyArray<T>;
|
3 | export interface PaginatePipeArgs {
|
4 | id?: string;
|
5 | itemsPerPage?: string | number;
|
6 | currentPage?: string | number;
|
7 | totalItems?: string | number;
|
8 | }
|
9 | export interface PipeState {
|
10 | collection: any[];
|
11 | size: number;
|
12 | start: number;
|
13 | end: number;
|
14 | slice: any[];
|
15 | }
|
16 | export declare class PaginatePipe {
|
17 | private service;
|
18 | private state;
|
19 | constructor(service: PaginationService);
|
20 | transform<T, U extends Collection<T>>(collection: U, args: PaginatePipeArgs): U;
|
21 | /**
|
22 | * Create an PaginationInstance object, using defaults for any optional properties not supplied.
|
23 | */
|
24 | private createInstance;
|
25 | /**
|
26 | * Ensure the argument passed to the filter contains the required properties.
|
27 | */
|
28 | private checkConfig;
|
29 | /**
|
30 | * To avoid returning a brand new array each time the pipe is run, we store the state of the sliced
|
31 | * array for a given id. This means that the next time the pipe is run on this collection & id, we just
|
32 | * need to check that the collection, start and end points are all identical, and if so, return the
|
33 | * last sliced array.
|
34 | */
|
35 | private saveState;
|
36 | /**
|
37 | * For a given id, returns true if the collection, size, start and end values are identical.
|
38 | */
|
39 | private stateIsIdentical;
|
40 | }
|