@ts-common/azure-js-dev-tools
Version:
Developer dependencies for TypeScript related projects
73 lines • 3.77 kB
TypeScript
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
/**
* Get whether or not the provided array contains any values.
* @param values The array to check.
* @returns Whether or not the provided array contains any values.
*/
export declare function any<T>(values: T[] | undefined): values is T[];
/**
* Get the first value in the provided array of values that matches the provided condition.
* @param values The array of values to search through.
* @param condition The condition to use when looking through the array of values.
*/
export declare function first<T>(values: T[] | undefined, condition?: T | ((value: T) => boolean)): T | undefined;
/**
* Get the last value in the provided array of values that matches the provided condition.
* @param values The array of values to search through.
* @param condition The condition to use when looking through the array of values.
*/
export declare function last<T>(values: T[] | undefined, condition?: T | ((value: T) => boolean)): T | undefined;
/**
* Get whether or not the provided array of values contains a value that matches the provided
* condition.
* @param values The array of values to search through.
* @param condition The condition to look for within the array of values.
* @returns Whether or not the provided array of values contains a value that matches the provided
* condition.
*/
export declare function contains<T>(values: T[] | undefined, condition: T | ((value: T) => boolean)): boolean;
/**
* Get all of the values within the provided array of values that match the provided condition.
* @param values The array of values to filter.
* @param condition The condition to look for within the array of values.
* @returns The array of values from the original values that match the provided condition.
*/
export declare function where<T>(values: T[], condition: (value: T) => boolean): T[];
/**
* Map the values in the provided array to a new array of values.
* @param values The values to map to a new array of values.
* @param conversion The function that will be used to convert the original values into the new
* ones.
* @returns The array with converted values.
*/
export declare function map<T, U>(values: T[] | undefined, conversion: (value: T) => U): U[];
/**
* Ensure that a value that is either a single value or an array is an array by wrapping single
* values in an array.
* @param value The value to ensure is an array.
* @param conversion The function that will be used to convert the non-array value to an array. This
* defaults to just creating a new array with the single value.
* @returns The array value.
*/
export declare function toArray<T>(value: T | T[], conversion?: (valueToConvert: T) => T[]): T[];
/**
* Get the index of the first value that matches the provided condition. -1 will be returned if no
* matching index is found.
* @param values The values to look through.
* @param condition The condition to check against each of the elements.
* @returns The first index that matches the provided condition or -1 if the condition is never
* satisfied.
*/
export declare function indexOf<T>(values: T[] | undefined, condition: (value: T, index: number) => boolean): number;
/**
* Remove and return the first element in the provided values that matches the provided condition.
* Undefined will be returned if no matching element is found.
* @param values The values to look through.
* @param condition The condition to check against each of the elements.
*/
export declare function removeFirst<T>(values: T[] | undefined, condition: (value: T, index: number) => boolean): T | undefined;
//# sourceMappingURL=arrays.d.ts.map