UNPKG

@ngxs-labs/entity-state

Version:

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.0.5.

51 lines (50 loc) 1.88 kB
import { EntityState } from './entity-state'; import { Type } from '@angular/core'; import { EntityStateModel } from './models'; /** * type alias for javascript object literal */ export interface HashMap<T> { [id: string]: T; } export declare const NGXS_META_KEY = "NGXS_META"; /** * This function generates a new object for the ngxs Action with the given fn name * @param fn The name of the Action to simulate, e.g. "Remove" or "Update" * @param store The class of the targeted entity state, e.g. ZooState * @param payload The payload for the created action object */ export declare function generateActionObject<T>(fn: string, store: Type<EntityState<T>>, payload?: any): any; /** * Utility function that returns the active entity of the given state * @param state the state of an entity state */ export declare function getActive<T>(state: EntityStateModel<T>): T; /** * Returns the active entity. If none is present an error will be thrown. * @param state The state to act on */ export declare function mustGetActive<T>(state: EntityStateModel<T>): { id: string; active: T; }; /** * Undefined-safe function to access the property given by path parameter * @param object The object to read from * @param path The path to the property */ export declare function elvis(object: any, path: string): any | undefined; /** * Returns input as an array if it isn't one already * @param input The input to make an array if necessary */ export declare function asArray<T>(input: T | T[]): T[]; /** * Uses the clamp function is wrap is false. * Else it wrap to the max or min value respectively. * @param wrap Flag to indicate if value should be wrapped * @param value The input value * @param min The minimum value * @param max The maximum value */ export declare function wrapOrClamp(wrap: boolean, value: number, min: number, max: number): number;