houser-js-utils
Version:
A comprehensive collection of TypeScript utility functions for common development tasks including array manipulation, string processing, date handling, random number generation, validation, and much more.
80 lines (78 loc) • 2.73 kB
TypeScript
import { ValueSetterParams } from '@ag-grid-community/core';
/**
* Collection of utility functions for AG Grid integration
*/
export declare const AGGridUtils: {
/**
* Collection of value parsers for AG Grid
*/
parsers: {
/**
* Parses a string value to a number
* @param params - Object containing the new value to parse
* @returns Parsed number or null if invalid
* @example
* ```typescript
* const value = AGGridUtils.parsers.number({ newValue: '123.45' });
* // Returns: 123.45
* ```
*/
number: (params: {
newValue: string;
}) => number | null;
/**
* Trims a string value
* @param params - Object containing the new value to trim
* @returns Trimmed string or null if empty
* @example
* ```typescript
* const value = AGGridUtils.parsers.string({ newValue: ' hello ' });
* // Returns: 'hello'
* ```
*/
string: (params: {
newValue: string;
}) => string | null;
};
/**
* Collection of value setters for AG Grid
*/
setters: {
/**
* Creates a setter that rounds numbers up to the nearest integer
* @param field - The field name to set the value on
* @returns A value setter function
* @example
* ```typescript
* const setter = AGGridUtils.setters.numberCeil('price');
* setter({ data: {}, newValue: 123.45 });
* // Sets data.price to 124
* ```
*/
numberCeil: (field: string) => (params: ValueSetterParams) => boolean;
/**
* Creates a setter that rounds numbers down to the nearest integer
* @param field - The field name to set the value on
* @returns A value setter function
* @example
* ```typescript
* const setter = AGGridUtils.setters.numberFloor('price');
* setter({ data: {}, newValue: 123.45 });
* // Sets data.price to 123
* ```
*/
numberFloor: (field: string) => (params: ValueSetterParams) => boolean;
/**
* Creates a setter that formats numbers to one decimal place if they're integers
* @param field - The field name to set the value on
* @returns A value setter function
* @example
* ```typescript
* const setter = AGGridUtils.setters.numberFloat('price');
* setter({ data: {}, newValue: 123 });
* // Sets data.price to '123.0'
* ```
*/
numberFloat: (field: string) => (params: ValueSetterParams) => boolean;
};
};