UNPKG

maths.ts

Version:

Math utilities library for TypeScript, JavaScript and Node.js

48 lines (47 loc) 1.93 kB
/** * @author Hector J. Vasquez <ipi.vasquez@gmail.com> * * @licence * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ export declare type criterion = (x: any, y: any) => number; /** * Checks if an array is in ascending order. * @param a The array to be checked. * @param compare An optional function to sent in case the commonly used a > * b does not fit the description of the array elements. * @return true if the array is sorted upwardly, false otherwise. */ export declare function isAscendingArray(a: any[], compare?: criterion): boolean; /** * Checks if an array is in descending order. * @param a The array to be checked. * @param compare An optional function to sent in case the commonly used * a > b does not fit the description of the array elements. * @return true if the array is sorted backwardly, false otherwise. */ export declare function isDescendingArray(a: any[], compare?: criterion): boolean; /** * The standard function checking relationship between a and b. * @param a a > b. * @param b a > b. * @return 0 if a equals b, 1 if a > b, -1 if b < a of a or b are undefined. */ export declare function ascending(a: any, b: any): number; /** * The standard function checking relationship between a and b. * @param a a < b. * @param b a < b. * @return 0 if a equals b, 1 if a < b, -1 if b > a of a or b are undefined. */ export declare function descending(a: any, b: any): number;