/* * @license Apache-2.0 * * Copyright (c) 2024 The Stdlib Authors. * * 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. */ // TypeScript Version: 4.1 /// /** * Checks whether an own property in an object passes a test. * * @returns boolean indicating whether an own property in an object passes a test */ type Nullary = () => boolean; /** * Checks whether an own property in an object passes a test. * * @param value - object value * @returns boolean indicating whether an own property in an object passes a test */ type Unary = ( value: T ) => boolean; /** * Checks whether an own property in an object passes a test. * * @param value - object value * @param key - object key * @returns boolean indicating whether an own property in an object passes a test */ type Binary = ( value: T, key: keyof any ) => boolean; /** * Checks whether an own property in an object passes a test. * * @param value - object value * @param key - object key * @param obj - input object * @returns boolean indicating whether an own property in an object passes a test */ type Ternary = ( value: T, key: keyof any, obj: Record ) => boolean; /** * Checks whether an own property in an object passes a test. * * @param value - object value * @param key - object key * @param obj - input object * @returns boolean indicating whether an own property in an object passes a test */ type Predicate = Nullary | Unary | Binary | Ternary; /** * Tests whether an object contains at least `n` own properties which pass a test implemented by a predicate function. * * ## Notes * * - The predicate function is provided three arguments: * * - `value`: object value * - `key`: object key * - `obj`: the input object * * - The function immediately returns upon finding `n` successful properties. * * - If provided an empty object, the function returns `false`. * * @param obj - input object * @param n - number of properties * @param predicate - test function * @returns boolean indicating whether an object contains at least `n` own properties which pass a test * * @example * function isNegative( v ) { * return ( v < 0 ); * } * * var obj = { a: 1, b: 2, c: -3, d: 4, e: -1 }; * * var bool = someOwnBy( obj, 2, isNegative ); * // returns true */ declare function someOwnBy( obj: Record, n: number, predicate: Predicate ): boolean; // EXPORTS // export = someOwnBy;