From 37bd67d860b10df89631ff5923d8f165525d1298 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Sun, 20 Apr 2025 23:51:30 +0530 Subject: [PATCH 1/3] feat: add `object/any-own-by` Ref: https://github.com/stdlib-js/stdlib/issues/6756 --- .../@stdlib/object/any-own-by/README.md | 221 ++++++++++++++++++ .../@stdlib/object/any-own-by/docs/repl.txt | 43 ++++ .../object/any-own-by/docs/types/index.d.ts | 101 ++++++++ .../object/any-own-by/docs/types/test.ts | 63 +++++ .../object/any-own-by/examples/index.js | 37 +++ .../@stdlib/object/any-own-by/lib/index.js | 46 ++++ .../@stdlib/object/any-own-by/lib/main.js | 77 ++++++ .../@stdlib/object/any-own-by/package.json | 70 ++++++ .../@stdlib/object/any-own-by/test/test.js | 179 ++++++++++++++ 9 files changed, 837 insertions(+) create mode 100644 lib/node_modules/@stdlib/object/any-own-by/README.md create mode 100644 lib/node_modules/@stdlib/object/any-own-by/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/object/any-own-by/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/object/any-own-by/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/object/any-own-by/examples/index.js create mode 100644 lib/node_modules/@stdlib/object/any-own-by/lib/index.js create mode 100644 lib/node_modules/@stdlib/object/any-own-by/lib/main.js create mode 100644 lib/node_modules/@stdlib/object/any-own-by/package.json create mode 100644 lib/node_modules/@stdlib/object/any-own-by/test/test.js diff --git a/lib/node_modules/@stdlib/object/any-own-by/README.md b/lib/node_modules/@stdlib/object/any-own-by/README.md new file mode 100644 index 000000000000..0f7d0e22cf2a --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/README.md @@ -0,0 +1,221 @@ + + +# anyOwnBy + +> Test whether at least one own property of a provided object passes a test implemented by a predicate function. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var anyOwnBy = require( '@stdlib/object/any-own-by' ); +``` + +#### anyBy( collection, predicate\[, thisArg ] ) + +Tests whether at least one own property of a provided [`object`][mdn-object] passes a test implemented by a `predicate` function. + +```javascript +function isNegative( value ) { + return ( value < 0 ); +} + +var obj = { + 'a': 1, + 'b': 2, + 'c': 3, + 'd': -24, + 'e': 12 +}; + +var bool = anyOwnBy( obj, isNegative ); +// returns true +``` + +If a `predicate` function returns a truthy value, the function **immediately** returns `true`. + +```javascript +function isPositive( value ) { + if ( value < 0 ) { + throw new Error( 'should never reach this line' ); + } + return ( value > 0 ); +} + +var obj = { + 'a': 1, + 'b': 2, + 'c': 3, + 'd': -24, + 'e': 12 +}; + +var bool = anyOwnBy( obj, isPositive ); +// returns true +``` + +The invoked `function` is provided three arguments: + +- **value**: property value. +- **key**: property key. +- **obj**: input object. + +To set the function execution context, provide a `thisArg`. + +```javascript +function verify( value ) { + this.sum += value; + this.count += 1; + return ( value > 0 ); +} + +var obj = { + 'a': -1, + 'b': -2, + 'c': 3, + 'd': -14 +}; + +var context = { + 'sum': 0, + 'count': 0 +}; + +var bool = anyOwnBy( obj, verify, context ); +// returns true + +var mean = context.sum / context.count; +// returns 0 +``` + +
+ + + + + +
+ +## Notes + +- If provided an empty object, the function returns `false`. + + ```javascript + function verify() { + return true; + } + var bool = anyOwnBy( {}, verify ); + // returns false + ``` + +
+ + + + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var anyOwnBy = require( '@stdlib/object/any-own-by' ); + +function threshold( value ) { + return ( value > 0.94 ); +} + +var bool; +var obj = {}; +var keys = [ 'a', 'b', 'c', 'd', 'e' ]; +var i; +for ( i = 0; i < keys.length; i++ ) { + obj[ keys[ i ] ] = randu(); +} + +bool = anyOwnBy( obj, threshold ); +// returns +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/object/any-own-by/docs/repl.txt b/lib/node_modules/@stdlib/object/any-own-by/docs/repl.txt new file mode 100644 index 000000000000..6afea6f65102 --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/docs/repl.txt @@ -0,0 +1,43 @@ + +{{alias}}( object, predicate[, thisArg ] ) + Tests whether at least one own property of an object passes a + test implemented by a predicate function. + + The predicate function is provided three arguments: + + - value: property value. + - index: property key. + - object: the input object. + + The function immediately returns upon encountering a truthy return + value. + + If provided an empty object, the function returns `false`. + + Parameters + ---------- + object: Object + Input object. + + predicate: Function + Test function. + + thisArg: any (optional) + Execution context. + + Returns + ------- + bool: boolean + The function returns `true` if the predicate function returns a truthy + value for one own property; otherwise, the function returns `false`. + + Examples + -------- + > function positive( v ) { return ( v > 0 ); }; + > var obj = { 'a': -1, 'b': 2, 'c': -3 }; + > var bool = {{alias}}( obj, positive ) + true + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/object/any-own-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/object/any-own-by/docs/types/index.d.ts new file mode 100644 index 000000000000..fe0dac85b4e0 --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/docs/types/index.d.ts @@ -0,0 +1,101 @@ +/* +* @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 of the object passes the test. +* +* @returns boolean indicating whether an own property of the object passes the test +*/ +type Nullary = ( this: U ) => boolean; + +/** +* Checks whether an own property of the object passes the test. +* +* @param value - collection value +* @returns boolean indicating whether an own property of the object passes the test +*/ +type Unary = ( this: U, value: T ) => boolean; + +/** +* Checks whether an own property of the object passes the test. +* +* @param value - property value +* @param key - property key +* @returns boolean indicating whether an own property of the object passes the test +*/ +type Binary = ( this: U, value: T, key: number ) => boolean; + +/** +* Checks whether an own property of the object passes the test. +* +* @param value - property value +* @param key - property key +* @param object - input object +* @returns boolean indicating whether an own property of the object passes the test +*/ +type Ternary = ( this: U, value: T, key: number, object: Object ) => boolean; + +/** +* Checks whether an own property of the object passes the test. +* +* @param value - property value +* @param key - property key +* @param object - input object +* @returns boolean indicating whether an own property of the object passes the tests +*/ +type Predicate = Nullary | Unary | Binary | Ternary; + +/** +* Tests whether any property of an object passes a test implemented by a predicate function. +* +* ## Notes +* +* - The predicate function is provided three arguments: +* +* - `value`: property value +* - `key`: property key +* - `object`: the input object +* +* - The function immediately returns upon encountering a truthy return value. +* - If provided an empty object, the function returns `false`. +* +* @param object - input object +* @param predicate - test function +* @param thisArg - execution context +* @returns boolean indicating whether any own property pass a test +* +* @example +* function isPositive( v ) { +* return ( v > 0 ); +* } +* +* var obj = { 'a': -1, 'b': 2, 'c': -3 }; +* +* var bool = anyOwnBy( obj, isPositive ); +* // returns true +*/ +declare function anyOwnBy( object: Record, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; + + +// EXPORTS // + +export = anyOwnBy; diff --git a/lib/node_modules/@stdlib/object/any-own-by/docs/types/test.ts b/lib/node_modules/@stdlib/object/any-own-by/docs/types/test.ts new file mode 100644 index 000000000000..bb87632c542b --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/docs/types/test.ts @@ -0,0 +1,63 @@ +/* +* @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. +*/ + +import anyOwnBy = require( './index' ); + +const isPositive = ( v: number ): boolean => { + return ( v > 0 ); +}; + +const obj = { + 'a':-1, + 'b':2, + 'c':-3 +}; + +// TESTS // + +// The function returns a boolean... +{ + anyOwnBy( obj, isPositive ); // $ExpectType boolean + anyOwnBy( obj, isPositive ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a first argument which is not an object... +{ + anyOwnBy( 2, isPositive ); // $ExpectError + anyOwnBy( false, isPositive ); // $ExpectError + anyOwnBy( true, isPositive ); // $ExpectError + anyOwnBy( [ 1, 2 ], isPositive ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a function... +{ + anyOwnBy( obj , 2 ); // $ExpectError + anyOwnBy( obj , false ); // $ExpectError + anyOwnBy( obj , true ); // $ExpectError + anyOwnBy( obj , 'abc' ); // $ExpectError + anyOwnBy( obj , {} ); // $ExpectError + anyOwnBy( obj , [] ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid number of arguments... +{ + anyOwnBy(); // $ExpectError + anyOwnBy( [ 1, 2, 3 ] ); // $ExpectError + anyOwnBy( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError +} + diff --git a/lib/node_modules/@stdlib/object/any-own-by/examples/index.js b/lib/node_modules/@stdlib/object/any-own-by/examples/index.js new file mode 100644 index 000000000000..d95d8d725a94 --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/examples/index.js @@ -0,0 +1,37 @@ +/** +* @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. +*/ + +'use strict'; + +var randu = require( '@stdlib/random/base/randu' ); +var anyOwnBy = require( './../lib' ); + +function threshold( value ) { + return ( value > 0.94 ); +} + +var bool; +var obj = {}; +var keys = [ 'a', 'b', 'c', 'd', 'e' ]; +var i; +for ( i = 0; i < keys.length; i++ ) { + obj[ keys[ i ] ] = randu(); +} + +bool = anyOwnBy( obj, threshold ); +console.log( bool ); diff --git a/lib/node_modules/@stdlib/object/any-own-by/lib/index.js b/lib/node_modules/@stdlib/object/any-own-by/lib/index.js new file mode 100644 index 000000000000..100a04a935b7 --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/lib/index.js @@ -0,0 +1,46 @@ +/** +* @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. +*/ + +'use strict'; + +/** +* Test whether any 'own' property of a provided object satisfies a predicate function. +* +* @module @stdlib/object/any-own-by +* +* @example +* var anyOwnBy = require( '@stdlib/object/any-own-by' ); +* +* function isPositive( v ) { +* return ( v > 0 ); +* } +* +* var obj = { 'a': -1, 'b': 2, 'c': -3 }; +* +* var bool = anyOwnBy( obj, isPositive ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/object/any-own-by/lib/main.js b/lib/node_modules/@stdlib/object/any-own-by/lib/main.js new file mode 100644 index 000000000000..1c3b30a1cb6e --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/lib/main.js @@ -0,0 +1,77 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var isObject = require( '@stdlib/assert/is-object' ); +var isFunction = require( '@stdlib/assert/is-function' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Tests whether any 'own' property of a provided object satisfies a predicate function. +* +* @param {Object} obj - input object +* @param {Function} predicate - test function +* @param {*} [thisArg] - execution context +* @throws {TypeError} first argument must be an object +* @throws {TypeError} second argument must be a function +* @returns {boolean} boolean returned indicating whether any own property of an object pass a test +* +* @example +* var anyOwnBy = require( '@stdlib/utils/any-own-by' ); +* +* function isPositive( v ) { +* return ( v > 0 ); +* } +* +* var obj = { 'a': -1, 'b': 2, 'c': -3 }; +* +* var bool = anyOwnBy( obj, isPositive ); +* // returns true +*/ +function anyOwnBy( obj, predicate, thisArg ) { + var result; + var key; + if ( !isObject( obj ) ) { + throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); + } + if ( !isFunction( predicate ) ) { + throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); + } + + for ( key in obj ) { + if ( hasOwnProp( obj, key ) ) { + result = predicate.call( thisArg, obj[ key ], key, obj ); + if ( result ) { + return true; + } + } + } + return false; +} + + +// EXPORTS // + +module.exports = anyOwnBy; diff --git a/lib/node_modules/@stdlib/object/any-own-by/package.json b/lib/node_modules/@stdlib/object/any-own-by/package.json new file mode 100644 index 000000000000..3559f0c9d3f3 --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/object/any-own-by", + "version": "0.0.0", + "description": "Test whether whether any 'own' property of a provided object satisfies a predicate function.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdutils", + "stdutil", + "utilities", + "utility", + "utils", + "util", + "test", + "predicate", + "any", + "iterate", + "object", + "property", + "properties", + "props", + "keys", + "obj", + "validate" + ] +} diff --git a/lib/node_modules/@stdlib/object/any-own-by/test/test.js b/lib/node_modules/@stdlib/object/any-own-by/test/test.js new file mode 100644 index 000000000000..9723e4577a40 --- /dev/null +++ b/lib/node_modules/@stdlib/object/any-own-by/test/test.js @@ -0,0 +1,179 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var noop = require( '@stdlib/utils/noop' ); +var anyOwnBy = require( './../lib' ); + + +// FUNCTIONS // + +function isPositive( v ) { + return ( v > 0 ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof anyOwnBy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided a first argument which is not an object', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + function noop() {}, + /.*/, + new Date() + ]; + for ( i =0; i < values.length; i++ ) { + t.throws( badValue( values ), TypeError, 'throws a type error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + anyOwnBy( value, noop ); + }; + } +}); + +tape( 'the function throws an error if provided a second argument which is not a predicate function', function test( t ) { + var values; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + {}, + [], + /.*/, + new Date() + ]; + + for ( i = 0; i < values.length; i++ ) { + t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); + } + t.end(); + + function badValue( value ) { + return function badValue() { + anyOwnBy( {}, value ); + }; + } +}); + +tape( 'if provided an empty object, the function returns `false`', function test( t ) { + var bool; + var obj; + + function foo() { + t.fail( 'should not be invoked' ); + } + obj = {}; + bool = anyOwnBy( obj, foo ); + + t.strictEqual( bool, false, 'returns false' ); + t.end(); +}); + +tape( 'the function returns `true` if any one property pass a test', function test( t ) { + var bool; + var obj; + + obj = { + 'a': -1, + 'b': 2, + 'c': -3 + }; + + bool = anyOwnBy( obj, isPositive ); + + t.strictEqual( bool, true, 'returns true' ); + t.end(); +}); + +tape( 'the function returns `false` if no properties pass a test', function test( t ) { + var bool; + var obj; + + obj = { + 'a': -1, + 'b': -2, + 'c': -3, + 'd': -34 + }; + + bool = anyOwnBy( obj, isPositive ); + + t.strictEqual( bool, false, 'returns false' ); + t.end(); +}); + +tape( 'the function supports providing an execution context', function test( t ) { + var bool; + var ctx; + var obj; + + function verify( value ) { + /* eslint-disable no-invalid-this */ + this.sum += value; + this.count += 1; + return ( value > 0 ); + } + + ctx = { + 'sum': 0, + 'count': 0 + }; + + obj = { + 'a': -1, + 'b': -2, + 'c': 3, + 'd': -14 + }; + + bool = anyOwnBy( obj, verify, ctx ); + + t.strictEqual( bool, true, 'returns true' ); + t.strictEqual( ctx.sum/ctx.count, 0, 'expected result' ); + + t.end(); +}); From 222f9e91a4531cb4915425d647c7b8ea18a40db1 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Mon, 21 Apr 2025 00:01:27 +0530 Subject: [PATCH 2/3] refactor: update paths Ref: https://github.com/stdlib-js/stdlib/issues/6756 --- lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv | 2 +- .../@stdlib/namespace/alias2standalone/data/data.csv | 2 +- lib/node_modules/@stdlib/namespace/lib/namespace/a.js | 6 +++--- lib/node_modules/@stdlib/namespace/lib/namespace/e.js | 2 +- lib/node_modules/@stdlib/namespace/lib/namespace/n.js | 2 +- lib/node_modules/@stdlib/namespace/lib/namespace/s.js | 2 +- lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv | 2 +- .../@stdlib/namespace/pkg2related/data/data.csv | 4 ++-- .../@stdlib/namespace/pkg2standalone/data/data.csv | 2 +- .../@stdlib/namespace/standalone2pkg/data/data.csv | 2 +- lib/node_modules/@stdlib/utils/every-own-by/README.md | 4 ++-- lib/node_modules/@stdlib/utils/none-own-by/README.md | 4 ++-- lib/node_modules/@stdlib/utils/some-own-by/README.md | 4 ++-- 13 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv index ba91e8f82c6d..7a727735e330 100644 --- a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv @@ -27,7 +27,7 @@ anyByAsync,"@stdlib/utils/async/any-by" anyByRight,"@stdlib/utils/any-by-right" anyByRightAsync,"@stdlib/utils/async/any-by-right" anyInBy,"@stdlib/utils/any-in-by" -anyOwnBy,"@stdlib/utils/any-own-by" +anyOwnBy,"@stdlib/object/any-own-by" aones,"@stdlib/array/ones" aonesLike,"@stdlib/array/ones-like" aoneTo,"@stdlib/array/one-to" diff --git a/lib/node_modules/@stdlib/namespace/alias2standalone/data/data.csv b/lib/node_modules/@stdlib/namespace/alias2standalone/data/data.csv index 1823ae842e33..8698f7ede67a 100644 --- a/lib/node_modules/@stdlib/namespace/alias2standalone/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/alias2standalone/data/data.csv @@ -27,7 +27,7 @@ anyByAsync,"@stdlib/utils-async-any-by" anyByRight,"@stdlib/utils-any-by-right" anyByRightAsync,"@stdlib/utils-async-any-by-right" anyInBy,"@stdlib/utils-any-in-by" -anyOwnBy,"@stdlib/utils-any-own-by" +anyOwnBy,"@stdlib/object-any-own-by" aones,"@stdlib/array-ones" aonesLike,"@stdlib/array-ones-like" aoneTo,"@stdlib/array-one-to" diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/a.js b/lib/node_modules/@stdlib/namespace/lib/namespace/a.js index 97f3c466e0b0..5801aec8a68e 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/a.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/a.js @@ -379,7 +379,7 @@ ns.push({ 'type': 'Function', 'related': [ '@stdlib/utils/any-by', - '@stdlib/utils/any-own-by', + '@stdlib/object/any-own-by', '@stdlib/object/every-in-by', '@stdlib/utils/some-in-by' ] @@ -387,8 +387,8 @@ ns.push({ ns.push({ 'alias': 'anyOwnBy', - 'path': '@stdlib/utils/any-own-by', - 'value': require( '@stdlib/utils/any-own-by' ), + 'path': '@stdlib/object/any-own-by', + 'value': require( '@stdlib/object/any-own-by' ), 'type': 'Function', 'related': [ '@stdlib/utils/any-by', diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/e.js b/lib/node_modules/@stdlib/namespace/lib/namespace/e.js index 0770f5245b28..795fac94cf57 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/e.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/e.js @@ -276,7 +276,7 @@ ns.push({ 'value': require( '@stdlib/utils/every-own-by' ), 'type': 'Function', 'related': [ - '@stdlib/utils/any-own-by', + '@stdlib/object/any-own-by', '@stdlib/object/every-in-by', '@stdlib/utils/none-own-by', '@stdlib/utils/some-own-by', diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/n.js b/lib/node_modules/@stdlib/namespace/lib/namespace/n.js index 0a6ab4647b39..c48085f74953 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/n.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/n.js @@ -1061,7 +1061,7 @@ ns.push({ 'value': require( '@stdlib/utils/none-own-by' ), 'type': 'Function', 'related': [ - '@stdlib/utils/any-own-by', + '@stdlib/object/any-own-by', '@stdlib/utils/every-own-by', '@stdlib/utils/for-own', '@stdlib/utils/none-by', diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/s.js b/lib/node_modules/@stdlib/namespace/lib/namespace/s.js index 6acba8fdbab8..77d9bb8d5e15 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/s.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/s.js @@ -597,7 +597,7 @@ ns.push({ 'value': require( '@stdlib/utils/some-own-by' ), 'type': 'Function', 'related': [ - '@stdlib/utils/any-own-by', + '@stdlib/object/any-own-by', '@stdlib/utils/every-own-by', '@stdlib/utils/some-by', '@stdlib/utils/some-in-by' diff --git a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv index efd3cd8b0a4b..7bf159c5df69 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv @@ -27,7 +27,7 @@ "@stdlib/utils/any-by-right",anyByRight "@stdlib/utils/async/any-by-right",anyByRightAsync "@stdlib/utils/any-in-by",anyInBy -"@stdlib/utils/any-own-by",anyOwnBy +"@stdlib/object/any-own-by",anyOwnBy "@stdlib/array/ones",aones "@stdlib/array/ones-like",aonesLike "@stdlib/array/one-to",aoneTo diff --git a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv index a81675e56ed2..61eecb0b71c9 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv @@ -26,8 +26,8 @@ "@stdlib/utils/async/any-by","@stdlib/utils/any-by,@stdlib/utils/async/any-by-right,@stdlib/utils/async/every-by,@stdlib/utils/async/for-each,@stdlib/utils/async/none-by,@stdlib/utils/async/some-by" "@stdlib/utils/any-by-right","@stdlib/utils/any-by,@stdlib/utils/async/any-by-right,@stdlib/utils/every-by-right,@stdlib/utils/for-each-right,@stdlib/utils/none-by-right,@stdlib/utils/some-by-right" "@stdlib/utils/async/any-by-right","@stdlib/utils/async/any-by,@stdlib/utils/any-by-right,@stdlib/utils/async/every-by-right,@stdlib/utils/async/for-each-right,@stdlib/utils/async/none-by-right,@stdlib/utils/async/some-by-right" -"@stdlib/utils/any-in-by","@stdlib/utils/any-by,@stdlib/utils/any-own-by,@stdlib/object/every-in-by,@stdlib/utils/some-in-by" -"@stdlib/utils/any-own-by","@stdlib/utils/any-by,@stdlib/utils/any-in-by,@stdlib/utils/every-own-by,@stdlib/utils/some-own-by" +"@stdlib/utils/any-in-by","@stdlib/utils/any-by,@stdlib/object/any-own-by,@stdlib/object/every-in-by,@stdlib/utils/some-in-by" +"@stdlib/object/any-own-by","@stdlib/utils/any-by,@stdlib/utils/any-in-by,@stdlib/utils/every-own-by,@stdlib/utils/some-own-by" "@stdlib/array/ones","@stdlib/array/full,@stdlib/array/nans,@stdlib/array/ones-like,@stdlib/array/zeros" "@stdlib/array/ones-like","@stdlib/array/full-like,@stdlib/array/nans-like,@stdlib/array/ones,@stdlib/array/zeros-like" "@stdlib/array/one-to","@stdlib/array/full,@stdlib/array/ones,@stdlib/array/one-to-like,@stdlib/array/zero-to" diff --git a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv index a006ae007f15..86031ee894f6 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv @@ -27,7 +27,7 @@ "@stdlib/utils/any-by-right","@stdlib/utils-any-by-right" "@stdlib/utils/async/any-by-right","@stdlib/utils-async-any-by-right" "@stdlib/utils/any-in-by","@stdlib/utils-any-in-by" -"@stdlib/utils/any-own-by","@stdlib/utils-any-own-by" +"@stdlib/object/any-own-by","@stdlib/object-any-own-by" "@stdlib/array/ones","@stdlib/array-ones" "@stdlib/array/ones-like","@stdlib/array-ones-like" "@stdlib/array/one-to","@stdlib/array-one-to" diff --git a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv index 271a3a296207..90f6747eea6e 100644 --- a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv @@ -27,7 +27,7 @@ "@stdlib/utils-any-by-right","@stdlib/utils/any-by-right" "@stdlib/utils-async-any-by-right","@stdlib/utils/async/any-by-right" "@stdlib/utils-any-in-by","@stdlib/utils/any-in-by" -"@stdlib/utils-any-own-by","@stdlib/utils/any-own-by" +"@stdlib/object-any-own-by","@stdlib/object/any-own-by" "@stdlib/array-ones","@stdlib/array/ones" "@stdlib/array-ones-like","@stdlib/array/ones-like" "@stdlib/array-one-to","@stdlib/array/one-to" diff --git a/lib/node_modules/@stdlib/utils/every-own-by/README.md b/lib/node_modules/@stdlib/utils/every-own-by/README.md index c9bf66eff053..31c885b6e247 100644 --- a/lib/node_modules/@stdlib/utils/every-own-by/README.md +++ b/lib/node_modules/@stdlib/utils/every-own-by/README.md @@ -189,7 +189,7 @@ var bool = everyOwnBy( obj, isPositive ); ## See Also -- [`@stdlib/utils/any-own-by`][@stdlib/utils/any-own-by]: test whether whether any 'own' property of a provided object satisfies a predicate function. +- [`@stdlib/object/any-own-by`][@stdlib/object/any-own-by]: test whether whether any 'own' property of a provided object satisfies a predicate function. - [`@stdlib/object/every-in-by`][@stdlib/object/every-in-by]: test whether all properties (own and inherited) of an object pass a test implemented by a predicate function. - [`@stdlib/utils/none-own-by`][@stdlib/utils/none-own-by]: tests whether every own property of an object fails a test implemented by a predicate function. - [`@stdlib/utils/some-own-by`][@stdlib/utils/some-own-by]: test whether some `own` properties of a provided object satisfy a predicate function for at least `n` properties. @@ -207,7 +207,7 @@ var bool = everyOwnBy( obj, isPositive ); -[@stdlib/utils/any-own-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/any-own-by +[@stdlib/object/any-own-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/object/any-own-by [@stdlib/object/every-in-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/object/every-in-by diff --git a/lib/node_modules/@stdlib/utils/none-own-by/README.md b/lib/node_modules/@stdlib/utils/none-own-by/README.md index bec03b9b204d..a8cad0906fb5 100644 --- a/lib/node_modules/@stdlib/utils/none-own-by/README.md +++ b/lib/node_modules/@stdlib/utils/none-own-by/README.md @@ -147,7 +147,7 @@ var bool = noneOwnBy( obj, isUnderage ); ## See Also -- [`@stdlib/utils/any-own-by`][@stdlib/utils/any-own-by]: test whether whether any 'own' property of a provided object satisfies a predicate function. +- [`@stdlib/object/any-own-by`][@stdlib/object/any-own-by]: test whether whether any 'own' property of a provided object satisfies a predicate function. - [`@stdlib/utils/every-own-by`][@stdlib/utils/every-own-by]: test whether all own properties of an object pass a test implemented by a predicate function. - [`@stdlib/utils/for-own`][@stdlib/utils/for-own]: invoke a function for each own enumerable property of an object. - [`@stdlib/utils/none-by`][@stdlib/utils/none-by]: test whether all elements in a collection fail a test implemented by a predicate function. @@ -163,7 +163,7 @@ var bool = noneOwnBy( obj, isUnderage ); -[@stdlib/utils/any-own-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/any-own-by +[@stdlib/object/any-own-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/object/any-own-by [@stdlib/utils/every-own-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/every-own-by diff --git a/lib/node_modules/@stdlib/utils/some-own-by/README.md b/lib/node_modules/@stdlib/utils/some-own-by/README.md index 165225506522..a91be8a142ec 100644 --- a/lib/node_modules/@stdlib/utils/some-own-by/README.md +++ b/lib/node_modules/@stdlib/utils/some-own-by/README.md @@ -219,7 +219,7 @@ bool = someOwnBy( obj, 5, threshold ); ## See Also -- [`@stdlib/utils/any-own-by`][@stdlib/utils/any-own-by]: test whether whether any 'own' property of a provided object satisfies a predicate function. +- [`@stdlib/object/any-own-by`][@stdlib/object/any-own-by]: test whether whether any 'own' property of a provided object satisfies a predicate function. - [`@stdlib/utils/every-own-by`][@stdlib/utils/every-own-by]: test whether all own properties of an object pass a test implemented by a predicate function. - [`@stdlib/utils/some-by`][@stdlib/utils/some-by]: test whether a collection contains at least `n` elements which pass a test implemented by a predicate function. - [`@stdlib/utils/some-in-by`][@stdlib/utils/some-in-by]: test whether an object contains at least n properties (own and inherited) which pass a test implemented by a predicate function. @@ -236,7 +236,7 @@ bool = someOwnBy( obj, 5, threshold ); -[@stdlib/utils/any-own-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/any-own-by +[@stdlib/object/any-own-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/object/any-own-by [@stdlib/utils/every-own-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/every-own-by From 252c91de32aeb4ade72b58d10300c8c21e4cbf92 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Mon, 21 Apr 2025 00:02:32 +0530 Subject: [PATCH 3/3] remove: remove `utils/any-own-by` This commit removes `@stdlib/utils/any-own-by` in favor of `@stdlib/object/any-own-by`. BREAKING CHANGE: remove `utils/any-own-by` To migrate, users should update their require/import paths to use `@stdlib/object/any-own-by` which provides the same API and implementation. Ref: https://github.com/stdlib-js/stdlib/issues/6756 --- .../@stdlib/utils/any-own-by/README.md | 221 ------------------ .../@stdlib/utils/any-own-by/docs/repl.txt | 43 ---- .../utils/any-own-by/docs/types/index.d.ts | 101 -------- .../utils/any-own-by/docs/types/test.ts | 63 ----- .../utils/any-own-by/examples/index.js | 37 --- .../@stdlib/utils/any-own-by/lib/index.js | 46 ---- .../@stdlib/utils/any-own-by/lib/main.js | 77 ------ .../@stdlib/utils/any-own-by/package.json | 70 ------ .../@stdlib/utils/any-own-by/test/test.js | 179 -------------- 9 files changed, 837 deletions(-) delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/README.md delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/docs/repl.txt delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/docs/types/index.d.ts delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/docs/types/test.ts delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/examples/index.js delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/lib/index.js delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/lib/main.js delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/package.json delete mode 100644 lib/node_modules/@stdlib/utils/any-own-by/test/test.js diff --git a/lib/node_modules/@stdlib/utils/any-own-by/README.md b/lib/node_modules/@stdlib/utils/any-own-by/README.md deleted file mode 100644 index 32785b274d7a..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/README.md +++ /dev/null @@ -1,221 +0,0 @@ - - -# anyOwnBy - -> Test whether at least one own property of a provided object passes a test implemented by a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var anyOwnBy = require( '@stdlib/utils/any-own-by' ); -``` - -#### anyBy( collection, predicate\[, thisArg ] ) - -Tests whether at least one own property of a provided [`object`][mdn-object] passes a test implemented by a `predicate` function. - -```javascript -function isNegative( value ) { - return ( value < 0 ); -} - -var obj = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': -24, - 'e': 12 -}; - -var bool = anyOwnBy( obj, isNegative ); -// returns true -``` - -If a `predicate` function returns a truthy value, the function **immediately** returns `true`. - -```javascript -function isPositive( value ) { - if ( value < 0 ) { - throw new Error( 'should never reach this line' ); - } - return ( value > 0 ); -} - -var obj = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': -24, - 'e': 12 -}; - -var bool = anyOwnBy( obj, isPositive ); -// returns true -``` - -The invoked `function` is provided three arguments: - -- **value**: property value. -- **key**: property key. -- **obj**: input object. - -To set the function execution context, provide a `thisArg`. - -```javascript -function verify( value ) { - this.sum += value; - this.count += 1; - return ( value > 0 ); -} - -var obj = { - 'a': -1, - 'b': -2, - 'c': 3, - 'd': -14 -}; - -var context = { - 'sum': 0, - 'count': 0 -}; - -var bool = anyOwnBy( obj, verify, context ); -// returns true - -var mean = context.sum / context.count; -// returns 0 -``` - -
- - - - - -
- -## Notes - -- If provided an empty object, the function returns `false`. - - ```javascript - function verify() { - return true; - } - var bool = anyOwnBy( {}, verify ); - // returns false - ``` - -
- - - - - -
- -## Examples - - - -```javascript -var randu = require( '@stdlib/random/base/randu' ); -var anyOwnBy = require( '@stdlib/utils/any-own-by' ); - -function threshold( value ) { - return ( value > 0.94 ); -} - -var bool; -var obj = {}; -var keys = [ 'a', 'b', 'c', 'd', 'e' ]; -var i; -for ( i = 0; i < keys.length; i++ ) { - obj[ keys[ i ] ] = randu(); -} - -bool = anyOwnBy( obj, threshold ); -// returns -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/lib/node_modules/@stdlib/utils/any-own-by/docs/repl.txt b/lib/node_modules/@stdlib/utils/any-own-by/docs/repl.txt deleted file mode 100644 index 6afea6f65102..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/docs/repl.txt +++ /dev/null @@ -1,43 +0,0 @@ - -{{alias}}( object, predicate[, thisArg ] ) - Tests whether at least one own property of an object passes a - test implemented by a predicate function. - - The predicate function is provided three arguments: - - - value: property value. - - index: property key. - - object: the input object. - - The function immediately returns upon encountering a truthy return - value. - - If provided an empty object, the function returns `false`. - - Parameters - ---------- - object: Object - Input object. - - predicate: Function - Test function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - bool: boolean - The function returns `true` if the predicate function returns a truthy - value for one own property; otherwise, the function returns `false`. - - Examples - -------- - > function positive( v ) { return ( v > 0 ); }; - > var obj = { 'a': -1, 'b': 2, 'c': -3 }; - > var bool = {{alias}}( obj, positive ) - true - - See Also - -------- - diff --git a/lib/node_modules/@stdlib/utils/any-own-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/any-own-by/docs/types/index.d.ts deleted file mode 100644 index fe0dac85b4e0..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/docs/types/index.d.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* -* @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 of the object passes the test. -* -* @returns boolean indicating whether an own property of the object passes the test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether an own property of the object passes the test. -* -* @param value - collection value -* @returns boolean indicating whether an own property of the object passes the test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether an own property of the object passes the test. -* -* @param value - property value -* @param key - property key -* @returns boolean indicating whether an own property of the object passes the test -*/ -type Binary = ( this: U, value: T, key: number ) => boolean; - -/** -* Checks whether an own property of the object passes the test. -* -* @param value - property value -* @param key - property key -* @param object - input object -* @returns boolean indicating whether an own property of the object passes the test -*/ -type Ternary = ( this: U, value: T, key: number, object: Object ) => boolean; - -/** -* Checks whether an own property of the object passes the test. -* -* @param value - property value -* @param key - property key -* @param object - input object -* @returns boolean indicating whether an own property of the object passes the tests -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Tests whether any property of an object passes a test implemented by a predicate function. -* -* ## Notes -* -* - The predicate function is provided three arguments: -* -* - `value`: property value -* - `key`: property key -* - `object`: the input object -* -* - The function immediately returns upon encountering a truthy return value. -* - If provided an empty object, the function returns `false`. -* -* @param object - input object -* @param predicate - test function -* @param thisArg - execution context -* @returns boolean indicating whether any own property pass a test -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* } -* -* var obj = { 'a': -1, 'b': 2, 'c': -3 }; -* -* var bool = anyOwnBy( obj, isPositive ); -* // returns true -*/ -declare function anyOwnBy( object: Record, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - -// EXPORTS // - -export = anyOwnBy; diff --git a/lib/node_modules/@stdlib/utils/any-own-by/docs/types/test.ts b/lib/node_modules/@stdlib/utils/any-own-by/docs/types/test.ts deleted file mode 100644 index bb87632c542b..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/docs/types/test.ts +++ /dev/null @@ -1,63 +0,0 @@ -/* -* @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. -*/ - -import anyOwnBy = require( './index' ); - -const isPositive = ( v: number ): boolean => { - return ( v > 0 ); -}; - -const obj = { - 'a':-1, - 'b':2, - 'c':-3 -}; - -// TESTS // - -// The function returns a boolean... -{ - anyOwnBy( obj, isPositive ); // $ExpectType boolean - anyOwnBy( obj, isPositive ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not an object... -{ - anyOwnBy( 2, isPositive ); // $ExpectError - anyOwnBy( false, isPositive ); // $ExpectError - anyOwnBy( true, isPositive ); // $ExpectError - anyOwnBy( [ 1, 2 ], isPositive ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - anyOwnBy( obj , 2 ); // $ExpectError - anyOwnBy( obj , false ); // $ExpectError - anyOwnBy( obj , true ); // $ExpectError - anyOwnBy( obj , 'abc' ); // $ExpectError - anyOwnBy( obj , {} ); // $ExpectError - anyOwnBy( obj , [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - anyOwnBy(); // $ExpectError - anyOwnBy( [ 1, 2, 3 ] ); // $ExpectError - anyOwnBy( [ 1, 2, 3 ], isPositive, {}, 3 ); // $ExpectError -} - diff --git a/lib/node_modules/@stdlib/utils/any-own-by/examples/index.js b/lib/node_modules/@stdlib/utils/any-own-by/examples/index.js deleted file mode 100644 index d95d8d725a94..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/examples/index.js +++ /dev/null @@ -1,37 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -var randu = require( '@stdlib/random/base/randu' ); -var anyOwnBy = require( './../lib' ); - -function threshold( value ) { - return ( value > 0.94 ); -} - -var bool; -var obj = {}; -var keys = [ 'a', 'b', 'c', 'd', 'e' ]; -var i; -for ( i = 0; i < keys.length; i++ ) { - obj[ keys[ i ] ] = randu(); -} - -bool = anyOwnBy( obj, threshold ); -console.log( bool ); diff --git a/lib/node_modules/@stdlib/utils/any-own-by/lib/index.js b/lib/node_modules/@stdlib/utils/any-own-by/lib/index.js deleted file mode 100644 index 9da6bcd2dca5..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/lib/index.js +++ /dev/null @@ -1,46 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -/** -* Test whether any 'own' property of a provided object satisfies a predicate function. -* -* @module @stdlib/utils/any-own-by -* -* @example -* var anyOwnBy = require( '@stdlib/utils/any-own-by' ); -* -* function isPositive( v ) { -* return ( v > 0 ); -* } -* -* var obj = { 'a': -1, 'b': 2, 'c': -3 }; -* -* var bool = anyOwnBy( obj, isPositive ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/node_modules/@stdlib/utils/any-own-by/lib/main.js b/lib/node_modules/@stdlib/utils/any-own-by/lib/main.js deleted file mode 100644 index 1c3b30a1cb6e..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/lib/main.js +++ /dev/null @@ -1,77 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var isObject = require( '@stdlib/assert/is-object' ); -var isFunction = require( '@stdlib/assert/is-function' ); -var hasOwnProp = require( '@stdlib/assert/has-own-property' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Tests whether any 'own' property of a provided object satisfies a predicate function. -* -* @param {Object} obj - input object -* @param {Function} predicate - test function -* @param {*} [thisArg] - execution context -* @throws {TypeError} first argument must be an object -* @throws {TypeError} second argument must be a function -* @returns {boolean} boolean returned indicating whether any own property of an object pass a test -* -* @example -* var anyOwnBy = require( '@stdlib/utils/any-own-by' ); -* -* function isPositive( v ) { -* return ( v > 0 ); -* } -* -* var obj = { 'a': -1, 'b': 2, 'c': -3 }; -* -* var bool = anyOwnBy( obj, isPositive ); -* // returns true -*/ -function anyOwnBy( obj, predicate, thisArg ) { - var result; - var key; - if ( !isObject( obj ) ) { - throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) ); - } - if ( !isFunction( predicate ) ) { - throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) ); - } - - for ( key in obj ) { - if ( hasOwnProp( obj, key ) ) { - result = predicate.call( thisArg, obj[ key ], key, obj ); - if ( result ) { - return true; - } - } - } - return false; -} - - -// EXPORTS // - -module.exports = anyOwnBy; diff --git a/lib/node_modules/@stdlib/utils/any-own-by/package.json b/lib/node_modules/@stdlib/utils/any-own-by/package.json deleted file mode 100644 index a007e3b22ed7..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/package.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "name": "@stdlib/utils/any-own-by", - "version": "0.0.0", - "description": "Test whether whether any 'own' property of a provided object satisfies a predicate function.", - "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": {}, - "homepage": "https://github.com/stdlib-js/stdlib", - "repository": { - "type": "git", - "url": "git://github.com/stdlib-js/stdlib.git" - }, - "bugs": { - "url": "https://github.com/stdlib-js/stdlib/issues" - }, - "dependencies": {}, - "devDependencies": {}, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdutils", - "stdutil", - "utilities", - "utility", - "utils", - "util", - "test", - "predicate", - "any", - "iterate", - "object", - "property", - "properties", - "props", - "keys", - "obj", - "validate" - ] -} diff --git a/lib/node_modules/@stdlib/utils/any-own-by/test/test.js b/lib/node_modules/@stdlib/utils/any-own-by/test/test.js deleted file mode 100644 index 9723e4577a40..000000000000 --- a/lib/node_modules/@stdlib/utils/any-own-by/test/test.js +++ /dev/null @@ -1,179 +0,0 @@ -/** -* @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. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var noop = require( '@stdlib/utils/noop' ); -var anyOwnBy = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( v ) { - return ( v > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof anyOwnBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a first argument which is not an object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - function noop() {}, - /.*/, - new Date() - ]; - for ( i =0; i < values.length; i++ ) { - t.throws( badValue( values ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - anyOwnBy( value, noop ); - }; - } -}); - -tape( 'the function throws an error if provided a second argument which is not a predicate function', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - {}, - [], - /.*/, - new Date() - ]; - - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[i] ), TypeError, 'throws a type error when provided '+values[i] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - anyOwnBy( {}, value ); - }; - } -}); - -tape( 'if provided an empty object, the function returns `false`', function test( t ) { - var bool; - var obj; - - function foo() { - t.fail( 'should not be invoked' ); - } - obj = {}; - bool = anyOwnBy( obj, foo ); - - t.strictEqual( bool, false, 'returns false' ); - t.end(); -}); - -tape( 'the function returns `true` if any one property pass a test', function test( t ) { - var bool; - var obj; - - obj = { - 'a': -1, - 'b': 2, - 'c': -3 - }; - - bool = anyOwnBy( obj, isPositive ); - - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if no properties pass a test', function test( t ) { - var bool; - var obj; - - obj = { - 'a': -1, - 'b': -2, - 'c': -3, - 'd': -34 - }; - - bool = anyOwnBy( obj, isPositive ); - - t.strictEqual( bool, false, 'returns false' ); - t.end(); -}); - -tape( 'the function supports providing an execution context', function test( t ) { - var bool; - var ctx; - var obj; - - function verify( value ) { - /* eslint-disable no-invalid-this */ - this.sum += value; - this.count += 1; - return ( value > 0 ); - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - - obj = { - 'a': -1, - 'b': -2, - 'c': 3, - 'd': -14 - }; - - bool = anyOwnBy( obj, verify, ctx ); - - t.strictEqual( bool, true, 'returns true' ); - t.strictEqual( ctx.sum/ctx.count, 0, 'expected result' ); - - t.end(); -});