From 27331acd07b701a431a5efd7ccf7104f9be8c5de Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Mon, 21 Apr 2025 00:13:39 +0530 Subject: [PATCH 1/4] feat: add `object/none-in-by` Ref: https://github.com/stdlib-js/stdlib/issues/6758 --- .../@stdlib/object/none-in-by/README.md | 244 ++++++++++++++++++ .../object/none-in-by/benchmark/benchmark.js | 95 +++++++ .../@stdlib/object/none-in-by/docs/repl.txt | 42 +++ .../object/none-in-by/docs/types/index.d.ts | 101 ++++++++ .../object/none-in-by/docs/types/test.ts | 61 +++++ .../object/none-in-by/examples/index.js | 37 +++ .../@stdlib/object/none-in-by/lib/index.js | 46 ++++ .../@stdlib/object/none-in-by/lib/main.js | 71 +++++ .../@stdlib/object/none-in-by/package.json | 68 +++++ .../@stdlib/object/none-in-by/test/test.js | 166 ++++++++++++ 10 files changed, 931 insertions(+) create mode 100644 lib/node_modules/@stdlib/object/none-in-by/README.md create mode 100644 lib/node_modules/@stdlib/object/none-in-by/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/object/none-in-by/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/object/none-in-by/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/object/none-in-by/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/object/none-in-by/examples/index.js create mode 100644 lib/node_modules/@stdlib/object/none-in-by/lib/index.js create mode 100644 lib/node_modules/@stdlib/object/none-in-by/lib/main.js create mode 100644 lib/node_modules/@stdlib/object/none-in-by/package.json create mode 100644 lib/node_modules/@stdlib/object/none-in-by/test/test.js diff --git a/lib/node_modules/@stdlib/object/none-in-by/README.md b/lib/node_modules/@stdlib/object/none-in-by/README.md new file mode 100644 index 000000000000..0cb70c9bb2d9 --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-by/README.md @@ -0,0 +1,244 @@ + + +# noneInBy + +> Test whether every property of an object fails a test implemented by a predicate function. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var noneInBy = require( '@stdlib/object/none-in-by' ); +``` + +#### noneInBy( object, predicate\[, thisArg ] ) + +Tests whether every property of an `object` fails a test implemented by a `predicate` function. + +```javascript +function isUnderage( age ) { + return ( age < 18 ); +} + +var obj = { + 'a': 28, + 'b': 22, + 'c': 25 +}; + +var bool = noneInBy( obj, isUnderage ); +// returns true +``` + +If a `predicate` function returns a truthy value, the function **immediately** returns `false`. + +```javascript +function isUnderage( age ) { + return ( age < 18 ); +} + +var obj = { + 'a': 12, + 'b': 22, + 'c': 25 +}; + +var bool = noneInBy( obj, isUnderage ); +// returns false +``` + +The invoked `function` is provided three agruments: + +- **value**: property value. +- **key**: property key. +- **object**: input object. + +To set the function execution context, provide a `thisArg`. + +```javascript +function sum( value ) { + if ( value < 0 ) { + return true; + } + this.sum += value; + this.count += 1; + return false; +} + +var obj = { + 'a': 1, + 'b': 2, + 'c': 3, + 'd': 4 +}; + +var context = { + 'sum': 0, + 'count': 0 +}; + +var bool = noneInBy( obj, sum, context ); +// returns true + +var mean = context.sum / context.count; +// returns 2.5 +``` + +
+ + + + + +
+ +## Notes + +- If the 1st argument is not an object or the second argument is not a fuction , the + function throws a Type Error. + +- If provided an empty object, the function returns `true`. + + ```javascript + function truthy() { + return true; + } + var bool = noneInBy( {}, truthy ); + // returns true + ``` + +- The function does **not** skip `undefined` elements. + + + + ```javascript + function log( value, index ) { + console.log( '%s: %s', index, value ); + return false; + } + + var obj = { + 'a': 1, + 'b': NaN, + 'c': NaN, + 'd': 4 + }; + + var bool = noneInBy( arr, log ); + /* => + 0: 1 + 1: undefined + 2: undefined + 3: 4 + */ + ``` + +
+ + + + + +
+ +## Examples + + + +```javascript +var noneInBy = require( '@stdlib/object/none-in-by' ); + +function isUnderage( age ) { + return age < 18; +} + +var obj = { + 'a': 26, + 'b': 20, + 'c': 25 +}; + +var bool = noneInBy( obj, isUnderage ); +// returns true +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/object/none-in-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/object/none-in-by/benchmark/benchmark.js new file mode 100644 index 000000000000..449b0cf13132 --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-by/benchmark/benchmark.js @@ -0,0 +1,95 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var noneInBy = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var bool; + var obj; + var i; + + function predicate( v ) { + return isnan( v ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + obj = { + 'a': i, + 'b': i + 1, + 'c': i + 2, + 'd': i + 3, + 'e': i + 4 + }; + bool = noneInBy( obj, predicate ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::for-in-loop', function benchmark( b ) { + var bool; + var obj; + var key; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + obj = { + 'a': i, + 'b': i + 1, + 'c': i + 2, + 'd': i + 3, + 'e': i + 4 + }; + bool = true; + for ( key in obj ) { + if ( isnan( obj[key] ) ) { + bool = false; + break; + } + } + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/object/none-in-by/docs/repl.txt b/lib/node_modules/@stdlib/object/none-in-by/docs/repl.txt new file mode 100644 index 000000000000..5a71d02491fe --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-by/docs/repl.txt @@ -0,0 +1,42 @@ + +{{alias}}( object, predicate[, thisArg ] ) + Tests whether every property in an object fails a test implemented by a + predicate function. + + The predicate function is provided three arguments: + + - value: object value. + - key: object key. + - object: the input object. + + The function immediately returns upon encountering a truthy return value. + + If provided an empty object, the function returns `true`. + + Parameters + ---------- + object: Object + Input object over which to iterate. + + predicate: Function + The test function. + + thisArg: any (optional) + Execution context. + + Returns + ------- + bool: boolean + The function returns `true` if the predicate function returns a falsy + value for all properties; otherwise, the function returns `false`. + + Examples + -------- + > function negative( v ) { return ( v < 0 ); }; + > var obj = { 'a': 1, 'b': 2, 'c': 4 }; + > var bool = {{alias}}( obj, negative ) + true + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/object/none-in-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/object/none-in-by/docs/types/index.d.ts new file mode 100644 index 000000000000..f0ac44d1d356 --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-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 a property in a object passes a test. +* +* @returns boolean indicating whether a property in a object passes a test +*/ +type Nullary = ( this: U ) => boolean; + +/** +* Checks whether a property in a object passes a test. +* +* @param value - property value +* @returns boolean indicating whether a property in an object passes a test +*/ +type Unary = ( this: U, value: T ) => boolean; + +/** +* Checks whether a property in a object passes a test. +* +* @param value - property value +* @param key - property key +* @returns boolean indicating whether a property in a object passes a test +*/ +type Binary = ( this: U, value: T, key: number ) => boolean; + +/** +* Checks whether a property in a object passes a test. +* +* @param value - property value +* @param key - property key +* @param object - input object +* @returns boolean indicating whether a property in a object passes a test +*/ +type Ternary = ( this: U, value: T, index: number, object: Object ) => boolean; + +/** +* Checks whether a property in a object passes a test. +* +* @param value - property value +* @param index - property index +* @param object - input object +* @returns boolean indicating whether a property in a object passes a test +*/ +type Predicate = Nullary | Unary | Binary | Ternary; + +/** +* Tests whether every property in a object fail 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 `true`. +* +* @param object - input object +* @param predicate - test function +* @param thisArg - execution context +* @returns boolean indicating whether all property fails a test +* +* @example +* function isPositive( v ) { +* return ( v > 0 ); +* } +* +* var obj = { 'a': -1, 'b': -2, 'c': -3, 'd': -4 }; +* +* var bool = noneInBy( obj, isPositive ); +* // returns true +*/ +declare function noneInBy( object: Record, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; + + +// EXPORTS // + +export = noneInBy; diff --git a/lib/node_modules/@stdlib/object/none-in-by/docs/types/test.ts b/lib/node_modules/@stdlib/object/none-in-by/docs/types/test.ts new file mode 100644 index 000000000000..ea2fc50b415c --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-by/docs/types/test.ts @@ -0,0 +1,61 @@ +/* +* @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 noneInBy = require( './index' ); + +const isPositive = ( v: number ): boolean => { + return ( v > 0 ); +}; + +// TESTS // + +const obj = { + 'a': 1, + 'b': 2, + 'c': 4 +}; + +// The function returns a boolean... +{ + noneInBy( obj, isPositive ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a first argument which is not an object... +{ + noneInBy( '2', isPositive ); // $ExpectError + noneInBy( false, isPositive ); // $ExpectError + noneInBy( true, isPositive ); // $ExpectError + noneInBy( [ 1, 2 ], isPositive ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a function... +{ + noneInBy( obj, 2 ); // $ExpectError + noneInBy( obj, false ); // $ExpectError + noneInBy( obj, true ); // $ExpectError + noneInBy( obj, 'abc' ); // $ExpectError + noneInBy( obj, {} ); // $ExpectError + noneInBy( obj, [] ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid number of arguments... +{ + noneInBy(); // $ExpectError + noneInBy( [ 1, 2, 3] ); // $ExpectError + noneInBy( [ 1, 2, 3], isPositive, {}, 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/object/none-in-by/examples/index.js b/lib/node_modules/@stdlib/object/none-in-by/examples/index.js new file mode 100644 index 000000000000..249426d76a39 --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-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 noneInBy = require( './../lib' ); + +function isNegative( value ) { + return ( value < 0 ); +} + +var bool; +var obj = {}; +var i; + +for ( i = 0; i < 100; i++ ) { + obj[ 'prop_' + i ] = randu(); +} + +bool = noneInBy( obj, isNegative ); +console.log( bool ); diff --git a/lib/node_modules/@stdlib/object/none-in-by/lib/index.js b/lib/node_modules/@stdlib/object/none-in-by/lib/index.js new file mode 100644 index 000000000000..8485ede5fe2a --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-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 every property of an object fails a test implemented by a predicate function. +* +* @module @stdlib/object/none-in-by +* +* @example +* var noneInBy = require( '@stdlib/object/none-in-by' ); +* +* function isPositive( v ) { +* return ( v > 0 ); +* } +* +* var obj = { 'a' : -1, 'b' : -2, 'c' : -3, 'd' : -4 }; +* +* var bool = noneInBy( obj, isPositive ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/object/none-in-by/lib/main.js b/lib/node_modules/@stdlib/object/none-in-by/lib/main.js new file mode 100644 index 000000000000..59de6a2fc201 --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-by/lib/main.js @@ -0,0 +1,71 @@ +/** +* @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 isFunction = require( '@stdlib/assert/is-function' ); +var isObject = require( '@stdlib/assert/is-object' ); +var format = require( '@stdlib/string/format' ); + + +// MAIN // + +/** +* Tests whether every property of a provided object does not satisfy 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 indicating whether all elements fail a test +* +* @example +* function isPositive( v ) { +* return ( v > 0 ); +* }; +* +* var obj = { 'a' : -1, 'b' : -2, 'c' : -3, 'd' : -4}; +* +* var bool = noneInBy( obj, isPositive ); +* // returns true +*/ +function noneInBy( obj, predicate, thisArg ) { + 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 ( predicate.call( thisArg, obj[key], key, obj ) ) { + return false; + } + } + return true; +} + + +// EXPORTS // + +module.exports = noneInBy; diff --git a/lib/node_modules/@stdlib/object/none-in-by/package.json b/lib/node_modules/@stdlib/object/none-in-by/package.json new file mode 100644 index 000000000000..075f0bc2cc88 --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-by/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/object/none-in-by", + "version": "0.0.0", + "description": "Test whether every property in an object fails a test implemented by 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": { + "benchmark": "./benchmark", + "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", + "none", + "all", + "every", + "iterate", + "object", + "validate" + ] +} diff --git a/lib/node_modules/@stdlib/object/none-in-by/test/test.js b/lib/node_modules/@stdlib/object/none-in-by/test/test.js new file mode 100644 index 000000000000..bda22ab0a4ea --- /dev/null +++ b/lib/node_modules/@stdlib/object/none-in-by/test/test.js @@ -0,0 +1,166 @@ +/** +* @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 noneInBy = require( './../lib' ); + + +// FUNCTIONS // + +function isPositive( value ) { + return ( value > 0 ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof noneInBy, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if not provided 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() { + noneInBy( value, noop ); + }; + } +}); + +tape( 'the function throws an error if not provided a predicate function', function test( t ) { + var values; + + values = { + 'a': 10, + 'b': 12, + 'c': 15 + }; + + t.throws( badValue( values ), TypeError, 'throws a type error when provided '+values ); + t.end(); + + function badValue( value ) { + return function badValue() { + noneInBy( value, value ); + }; + } +}); + +tape( 'if provided an empty object, the function returns `true`', function test( t ) { + var bool; + var obj = {}; + + function foo() { + t.fail( 'should not be invoked' ); + } + + bool = noneInBy( obj, foo ); + + t.strictEqual( bool, true, 'returns true' ); + t.end(); +}); + +tape('the function returns `true` if every property fails a test ', function test( t ) { + var bool; + + var obj = { + 'a': -1, + 'b': -2, + 'c': -3 + }; + + bool = noneInBy( obj, isPositive ); + + t.strictEqual( bool, true, 'returns true' ); + t.end(); +}); + +tape( 'the function returns `false` if one or more properties pass a test ', function test( t ) { + var bool; + var obj = { + '0': -1, + '1': 2, + '2': -3 + }; + + bool = noneInBy( 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 sum( value ) { + /* eslint-disable no-invalid-this */ + if ( value < 0 ) { + return false; + } + this.sum += value; + this.count += 1; + return false; + } + + ctx = { + 'sum': 0, + 'count': 0 + }; + obj = { + '0': 1.0, + '1': 2.0, + '2': 3.0 + }; + + bool = noneInBy( obj, sum, ctx ); + + t.strictEqual( bool, true, 'returns true' ); + t.strictEqual( ctx.sum / ctx.count, 2.0, 'expected result' ); + + t.end(); +}); From 47f76c450e19eb90c7fa2c932b5be286951b0965 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Mon, 21 Apr 2025 00:22:47 +0530 Subject: [PATCH 2/4] refactor: update paths Ref: https://github.com/stdlib-js/stdlib/issues/6758 --- lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv | 2 +- .../@stdlib/namespace/alias2standalone/data/data.csv | 2 +- lib/node_modules/@stdlib/namespace/lib/namespace/e.js | 2 +- lib/node_modules/@stdlib/namespace/lib/namespace/n.js | 4 ++-- lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv | 2 +- lib/node_modules/@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/object/every-in-by/README.md | 2 +- 9 files changed, 11 insertions(+), 11 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..a48ed688044c 100644 --- a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv @@ -2635,7 +2635,7 @@ noneBy,"@stdlib/utils/none-by" noneByAsync,"@stdlib/utils/async/none-by" noneByRight,"@stdlib/utils/none-by-right" noneByRightAsync,"@stdlib/utils/async/none-by-right" -noneInBy,"@stdlib/utils/none-in-by" +noneInBy,"@stdlib/object/none-in-by" nonEnumerableProperties,"@stdlib/utils/nonenumerable-properties" nonEnumerablePropertiesIn,"@stdlib/utils/nonenumerable-properties-in" nonEnumerablePropertyNames,"@stdlib/utils/nonenumerable-property-names" diff --git a/lib/node_modules/@stdlib/namespace/alias2standalone/data/data.csv b/lib/node_modules/@stdlib/namespace/alias2standalone/data/data.csv index 1823ae842e33..b7c62709535a 100644 --- a/lib/node_modules/@stdlib/namespace/alias2standalone/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/alias2standalone/data/data.csv @@ -2635,7 +2635,7 @@ noneBy,"@stdlib/utils-none-by" noneByAsync,"@stdlib/utils-async-none-by" noneByRight,"@stdlib/utils-none-by-right" noneByRightAsync,"@stdlib/utils-async-none-by-right" -noneInBy,"@stdlib/utils-none-in-by" +noneInBy,"@stdlib/object-none-in-by" nonEnumerableProperties,"@stdlib/utils-nonenumerable-properties" nonEnumerablePropertiesIn,"@stdlib/utils-nonenumerable-properties-in" nonEnumerablePropertyNames,"@stdlib/utils-nonenumerable-property-names" diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/e.js b/lib/node_modules/@stdlib/namespace/lib/namespace/e.js index 0770f5245b28..d75ea5c2440d 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/e.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/e.js @@ -263,7 +263,7 @@ ns.push({ 'type': 'Function', 'related': [ '@stdlib/utils/any-in-by', - '@stdlib/utils/none-in-by', + '@stdlib/object/none-in-by', '@stdlib/utils/some-in-by', '@stdlib/utils/every-by', '@stdlib/utils/every-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..0a5adc8dd3e2 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/n.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/n.js @@ -962,8 +962,8 @@ ns.push({ ns.push({ 'alias': 'noneInBy', - 'path': '@stdlib/utils/none-in-by', - 'value': require( '@stdlib/utils/none-in-by' ), + 'path': '@stdlib/object/none-in-by', + 'value': require( '@stdlib/object/none-in-by' ), 'type': 'Function', 'related': [ '@stdlib/utils/any-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..9b4fd1b8987a 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv @@ -2635,7 +2635,7 @@ "@stdlib/utils/async/none-by",noneByAsync "@stdlib/utils/none-by-right",noneByRight "@stdlib/utils/async/none-by-right",noneByRightAsync -"@stdlib/utils/none-in-by",noneInBy +"@stdlib/object/none-in-by",noneInBy "@stdlib/utils/nonenumerable-properties",nonEnumerableProperties "@stdlib/utils/nonenumerable-properties-in",nonEnumerablePropertiesIn "@stdlib/utils/nonenumerable-property-names",nonEnumerablePropertyNames diff --git a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv index a81675e56ed2..f49d7a73e99e 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv @@ -1616,7 +1616,7 @@ "@stdlib/utils/async/every-by","@stdlib/utils/async/any-by,@stdlib/utils/every-by,@stdlib/utils/async/every-by-right,@stdlib/utils/async/for-each,@stdlib/utils/async/none-by,@stdlib/utils/async/some-by" "@stdlib/utils/every-by-right","@stdlib/utils/any-by,@stdlib/utils/every,@stdlib/utils/every-by,@stdlib/utils/for-each-right,@stdlib/utils/none-by-right,@stdlib/utils/some-by-right" "@stdlib/utils/async/every-by-right","@stdlib/utils/async/any-by-right,@stdlib/utils/async/every-by,@stdlib/utils/every-by-right,@stdlib/utils/async/for-each-right,@stdlib/utils/async/none-by-right,@stdlib/utils/async/some-by-right" -"@stdlib/object/every-in-by","@stdlib/utils/any-in-by,@stdlib/utils/none-in-by,@stdlib/utils/some-in-by,@stdlib/utils/every-by,@stdlib/utils/every-own-by" +"@stdlib/object/every-in-by","@stdlib/utils/any-in-by,@stdlib/object/none-in-by,@stdlib/utils/some-in-by,@stdlib/utils/every-by,@stdlib/utils/every-own-by" "@stdlib/utils/every-own-by","@stdlib/utils/any-own-by,@stdlib/object/every-in-by,@stdlib/utils/none-own-by,@stdlib/utils/some-own-by,@stdlib/utils/every-by" "@stdlib/utils/eval","" "@stdlib/process/exec-path","" @@ -2635,7 +2635,7 @@ "@stdlib/utils/async/none-by","@stdlib/utils/async/any-by,@stdlib/utils/async/every-by,@stdlib/utils/async/for-each,@stdlib/utils/none-by,@stdlib/utils/async/none-by-right,@stdlib/utils/async/some-by" "@stdlib/utils/none-by-right","@stdlib/utils/any-by-right,@stdlib/utils/every-by-right,@stdlib/utils/for-each-right,@stdlib/utils/none,@stdlib/utils/none-by,@stdlib/utils/some-by-right" "@stdlib/utils/async/none-by-right","@stdlib/utils/async/any-by-right,@stdlib/utils/async/every-by-right,@stdlib/utils/async/for-each-right,@stdlib/utils/async/none-by,@stdlib/utils/none-by-right,@stdlib/utils/async/some-by-right" -"@stdlib/utils/none-in-by","@stdlib/utils/any-in-by,@stdlib/object/every-in-by,@stdlib/utils/for-in,@stdlib/utils/none-by,@stdlib/utils/some-in-by" +"@stdlib/object/none-in-by","@stdlib/utils/any-in-by,@stdlib/object/every-in-by,@stdlib/utils/for-in,@stdlib/utils/none-by,@stdlib/utils/some-in-by" "@stdlib/utils/nonenumerable-properties","@stdlib/utils/enumerable-properties,@stdlib/utils/inherited-nonenumerable-properties,@stdlib/utils/nonenumerable-properties-in,@stdlib/utils/properties" "@stdlib/utils/nonenumerable-properties-in","@stdlib/utils/enumerable-properties-in,@stdlib/utils/inherited-nonenumerable-properties,@stdlib/utils/nonenumerable-properties,@stdlib/utils/properties-in" "@stdlib/utils/nonenumerable-property-names","@stdlib/utils/keys,@stdlib/utils/inherited-nonenumerable-property-names,@stdlib/utils/nonenumerable-property-names-in,@stdlib/utils/nonenumerable-property-symbols,@stdlib/utils/property-names" diff --git a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv index a006ae007f15..15c286ad9aa5 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv @@ -2635,7 +2635,7 @@ "@stdlib/utils/async/none-by","@stdlib/utils-async-none-by" "@stdlib/utils/none-by-right","@stdlib/utils-none-by-right" "@stdlib/utils/async/none-by-right","@stdlib/utils-async-none-by-right" -"@stdlib/utils/none-in-by","@stdlib/utils-none-in-by" +"@stdlib/object/none-in-by","@stdlib/object-none-in-by" "@stdlib/utils/nonenumerable-properties","@stdlib/utils-nonenumerable-properties" "@stdlib/utils/nonenumerable-properties-in","@stdlib/utils-nonenumerable-properties-in" "@stdlib/utils/nonenumerable-property-names","@stdlib/utils-nonenumerable-property-names" diff --git a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv index 271a3a296207..232a9afe3c5d 100644 --- a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv @@ -2635,7 +2635,7 @@ "@stdlib/utils-async-none-by","@stdlib/utils/async/none-by" "@stdlib/utils-none-by-right","@stdlib/utils/none-by-right" "@stdlib/utils-async-none-by-right","@stdlib/utils/async/none-by-right" -"@stdlib/utils-none-in-by","@stdlib/utils/none-in-by" +"@stdlib/object-none-in-by","@stdlib/object/none-in-by" "@stdlib/utils-nonenumerable-properties","@stdlib/utils/nonenumerable-properties" "@stdlib/utils-nonenumerable-properties-in","@stdlib/utils/nonenumerable-properties-in" "@stdlib/utils-nonenumerable-property-names","@stdlib/utils/nonenumerable-property-names" diff --git a/lib/node_modules/@stdlib/object/every-in-by/README.md b/lib/node_modules/@stdlib/object/every-in-by/README.md index 5adf4eeba8f9..691aad518ed7 100644 --- a/lib/node_modules/@stdlib/object/every-in-by/README.md +++ b/lib/node_modules/@stdlib/object/every-in-by/README.md @@ -126,7 +126,7 @@ bool = everyInBy( o, isPositive ); [@stdlib/utils/any-in-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/any-in-by -[@stdlib/utils/none-in-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/none-in-by +[@stdlib/object/none-in-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/object/none-in-by [@stdlib/utils/some-in-by]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/utils/some-in-by From 68445e7c04b7c9fdd09e6b10fc72a9e5cb33bd39 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Mon, 21 Apr 2025 00:23:49 +0530 Subject: [PATCH 3/4] remove: remove `utils/none-in-by` This commit removes `@stdlib/utils/none-in-by` in favor of `@stdlib/object/none-in-by`. BREAKING CHANGE: remove `utils/none-in-by` To migrate, users should update their require/import paths to use `@stdlib/object/none-in-by` which provides the same API and implementation. Ref: https://github.com/stdlib-js/stdlib/issues/6758 --- .../@stdlib/utils/none-in-by/README.md | 244 ------------------ .../utils/none-in-by/benchmark/benchmark.js | 95 ------- .../@stdlib/utils/none-in-by/docs/repl.txt | 42 --- .../utils/none-in-by/docs/types/index.d.ts | 101 -------- .../utils/none-in-by/docs/types/test.ts | 61 ----- .../utils/none-in-by/examples/index.js | 37 --- .../@stdlib/utils/none-in-by/lib/index.js | 46 ---- .../@stdlib/utils/none-in-by/lib/main.js | 71 ----- .../@stdlib/utils/none-in-by/package.json | 68 ----- .../@stdlib/utils/none-in-by/test/test.js | 166 ------------ 10 files changed, 931 deletions(-) delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/README.md delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/benchmark/benchmark.js delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/docs/repl.txt delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/docs/types/index.d.ts delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/docs/types/test.ts delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/examples/index.js delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/lib/index.js delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/lib/main.js delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/package.json delete mode 100644 lib/node_modules/@stdlib/utils/none-in-by/test/test.js diff --git a/lib/node_modules/@stdlib/utils/none-in-by/README.md b/lib/node_modules/@stdlib/utils/none-in-by/README.md deleted file mode 100644 index 10a79bf53682..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-by/README.md +++ /dev/null @@ -1,244 +0,0 @@ - - -# noneInBy - -> Test whether every property of an object fails a test implemented by a predicate function. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var noneInBy = require( '@stdlib/utils/none-in-by' ); -``` - -#### noneInBy( object, predicate\[, thisArg ] ) - -Tests whether every property of an `object` fails a test implemented by a `predicate` function. - -```javascript -function isUnderage( age ) { - return ( age < 18 ); -} - -var obj = { - 'a': 28, - 'b': 22, - 'c': 25 -}; - -var bool = noneInBy( obj, isUnderage ); -// returns true -``` - -If a `predicate` function returns a truthy value, the function **immediately** returns `false`. - -```javascript -function isUnderage( age ) { - return ( age < 18 ); -} - -var obj = { - 'a': 12, - 'b': 22, - 'c': 25 -}; - -var bool = noneInBy( obj, isUnderage ); -// returns false -``` - -The invoked `function` is provided three agruments: - -- **value**: property value. -- **key**: property key. -- **object**: input object. - -To set the function execution context, provide a `thisArg`. - -```javascript -function sum( value ) { - if ( value < 0 ) { - return true; - } - this.sum += value; - this.count += 1; - return false; -} - -var obj = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4 -}; - -var context = { - 'sum': 0, - 'count': 0 -}; - -var bool = noneInBy( obj, sum, context ); -// returns true - -var mean = context.sum / context.count; -// returns 2.5 -``` - -
- - - - - -
- -## Notes - -- If the 1st argument is not an object or the second argument is not a fuction , the - function throws a Type Error. - -- If provided an empty object, the function returns `true`. - - ```javascript - function truthy() { - return true; - } - var bool = noneInBy( {}, truthy ); - // returns true - ``` - -- The function does **not** skip `undefined` elements. - - - - ```javascript - function log( value, index ) { - console.log( '%s: %s', index, value ); - return false; - } - - var obj = { - 'a': 1, - 'b': NaN, - 'c': NaN, - 'd': 4 - }; - - var bool = noneInBy( arr, log ); - /* => - 0: 1 - 1: undefined - 2: undefined - 3: 4 - */ - ``` - -
- - - - - -
- -## Examples - - - -```javascript -var noneInBy = require( '@stdlib/utils/none-in-by' ); - -function isUnderage( age ) { - return age < 18; -} - -var obj = { - 'a': 26, - 'b': 20, - 'c': 25 -}; - -var bool = noneInBy( obj, isUnderage ); -// returns true -``` - -
- - - - - -
- -
- - - - - - - - - - - - - - diff --git a/lib/node_modules/@stdlib/utils/none-in-by/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/none-in-by/benchmark/benchmark.js deleted file mode 100644 index 449b0cf13132..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-by/benchmark/benchmark.js +++ /dev/null @@ -1,95 +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 bench = require( '@stdlib/bench' ); -var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var pkg = require( './../package.json' ).name; -var noneInBy = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var bool; - var obj; - var i; - - function predicate( v ) { - return isnan( v ); - } - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = { - 'a': i, - 'b': i + 1, - 'c': i + 2, - 'd': i + 3, - 'e': i + 4 - }; - bool = noneInBy( obj, predicate ); - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::for-in-loop', function benchmark( b ) { - var bool; - var obj; - var key; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj = { - 'a': i, - 'b': i + 1, - 'c': i + 2, - 'd': i + 3, - 'e': i + 4 - }; - bool = true; - for ( key in obj ) { - if ( isnan( obj[key] ) ) { - bool = false; - break; - } - } - if ( typeof bool !== 'boolean' ) { - b.fail( 'should return a boolean' ); - } - } - b.toc(); - if ( !isBoolean( bool ) ) { - b.fail( 'should return a boolean' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/lib/node_modules/@stdlib/utils/none-in-by/docs/repl.txt b/lib/node_modules/@stdlib/utils/none-in-by/docs/repl.txt deleted file mode 100644 index 5a71d02491fe..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-by/docs/repl.txt +++ /dev/null @@ -1,42 +0,0 @@ - -{{alias}}( object, predicate[, thisArg ] ) - Tests whether every property in an object fails a test implemented by a - predicate function. - - The predicate function is provided three arguments: - - - value: object value. - - key: object key. - - object: the input object. - - The function immediately returns upon encountering a truthy return value. - - If provided an empty object, the function returns `true`. - - Parameters - ---------- - object: Object - Input object over which to iterate. - - predicate: Function - The test function. - - thisArg: any (optional) - Execution context. - - Returns - ------- - bool: boolean - The function returns `true` if the predicate function returns a falsy - value for all properties; otherwise, the function returns `false`. - - Examples - -------- - > function negative( v ) { return ( v < 0 ); }; - > var obj = { 'a': 1, 'b': 2, 'c': 4 }; - > var bool = {{alias}}( obj, negative ) - true - - See Also - -------- - diff --git a/lib/node_modules/@stdlib/utils/none-in-by/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/none-in-by/docs/types/index.d.ts deleted file mode 100644 index f0ac44d1d356..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-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 a property in a object passes a test. -* -* @returns boolean indicating whether a property in a object passes a test -*/ -type Nullary = ( this: U ) => boolean; - -/** -* Checks whether a property in a object passes a test. -* -* @param value - property value -* @returns boolean indicating whether a property in an object passes a test -*/ -type Unary = ( this: U, value: T ) => boolean; - -/** -* Checks whether a property in a object passes a test. -* -* @param value - property value -* @param key - property key -* @returns boolean indicating whether a property in a object passes a test -*/ -type Binary = ( this: U, value: T, key: number ) => boolean; - -/** -* Checks whether a property in a object passes a test. -* -* @param value - property value -* @param key - property key -* @param object - input object -* @returns boolean indicating whether a property in a object passes a test -*/ -type Ternary = ( this: U, value: T, index: number, object: Object ) => boolean; - -/** -* Checks whether a property in a object passes a test. -* -* @param value - property value -* @param index - property index -* @param object - input object -* @returns boolean indicating whether a property in a object passes a test -*/ -type Predicate = Nullary | Unary | Binary | Ternary; - -/** -* Tests whether every property in a object fail 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 `true`. -* -* @param object - input object -* @param predicate - test function -* @param thisArg - execution context -* @returns boolean indicating whether all property fails a test -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* } -* -* var obj = { 'a': -1, 'b': -2, 'c': -3, 'd': -4 }; -* -* var bool = noneInBy( obj, isPositive ); -* // returns true -*/ -declare function noneInBy( object: Record, predicate: Predicate, thisArg?: ThisParameterType> ): boolean; - - -// EXPORTS // - -export = noneInBy; diff --git a/lib/node_modules/@stdlib/utils/none-in-by/docs/types/test.ts b/lib/node_modules/@stdlib/utils/none-in-by/docs/types/test.ts deleted file mode 100644 index ea2fc50b415c..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-by/docs/types/test.ts +++ /dev/null @@ -1,61 +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 noneInBy = require( './index' ); - -const isPositive = ( v: number ): boolean => { - return ( v > 0 ); -}; - -// TESTS // - -const obj = { - 'a': 1, - 'b': 2, - 'c': 4 -}; - -// The function returns a boolean... -{ - noneInBy( obj, isPositive ); // $ExpectType boolean -} - -// The compiler throws an error if the function is provided a first argument which is not an object... -{ - noneInBy( '2', isPositive ); // $ExpectError - noneInBy( false, isPositive ); // $ExpectError - noneInBy( true, isPositive ); // $ExpectError - noneInBy( [ 1, 2 ], isPositive ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not a function... -{ - noneInBy( obj, 2 ); // $ExpectError - noneInBy( obj, false ); // $ExpectError - noneInBy( obj, true ); // $ExpectError - noneInBy( obj, 'abc' ); // $ExpectError - noneInBy( obj, {} ); // $ExpectError - noneInBy( obj, [] ); // $ExpectError -} - -// The compiler throws an error if the function is provided an invalid number of arguments... -{ - noneInBy(); // $ExpectError - noneInBy( [ 1, 2, 3] ); // $ExpectError - noneInBy( [ 1, 2, 3], isPositive, {}, 3 ); // $ExpectError -} diff --git a/lib/node_modules/@stdlib/utils/none-in-by/examples/index.js b/lib/node_modules/@stdlib/utils/none-in-by/examples/index.js deleted file mode 100644 index 249426d76a39..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-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 noneInBy = require( './../lib' ); - -function isNegative( value ) { - return ( value < 0 ); -} - -var bool; -var obj = {}; -var i; - -for ( i = 0; i < 100; i++ ) { - obj[ 'prop_' + i ] = randu(); -} - -bool = noneInBy( obj, isNegative ); -console.log( bool ); diff --git a/lib/node_modules/@stdlib/utils/none-in-by/lib/index.js b/lib/node_modules/@stdlib/utils/none-in-by/lib/index.js deleted file mode 100644 index 094a80e2c236..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-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 every property of an object fails a test implemented by a predicate function. -* -* @module @stdlib/utils/none-in-by -* -* @example -* var noneInBy = require( '@stdlib/utils/none-in-by' ); -* -* function isPositive( v ) { -* return ( v > 0 ); -* } -* -* var obj = { 'a' : -1, 'b' : -2, 'c' : -3, 'd' : -4 }; -* -* var bool = noneInBy( obj, isPositive ); -* // returns true -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/node_modules/@stdlib/utils/none-in-by/lib/main.js b/lib/node_modules/@stdlib/utils/none-in-by/lib/main.js deleted file mode 100644 index 59de6a2fc201..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-by/lib/main.js +++ /dev/null @@ -1,71 +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 isFunction = require( '@stdlib/assert/is-function' ); -var isObject = require( '@stdlib/assert/is-object' ); -var format = require( '@stdlib/string/format' ); - - -// MAIN // - -/** -* Tests whether every property of a provided object does not satisfy 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 indicating whether all elements fail a test -* -* @example -* function isPositive( v ) { -* return ( v > 0 ); -* }; -* -* var obj = { 'a' : -1, 'b' : -2, 'c' : -3, 'd' : -4}; -* -* var bool = noneInBy( obj, isPositive ); -* // returns true -*/ -function noneInBy( obj, predicate, thisArg ) { - 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 ( predicate.call( thisArg, obj[key], key, obj ) ) { - return false; - } - } - return true; -} - - -// EXPORTS // - -module.exports = noneInBy; diff --git a/lib/node_modules/@stdlib/utils/none-in-by/package.json b/lib/node_modules/@stdlib/utils/none-in-by/package.json deleted file mode 100644 index bff1da70e6b3..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-by/package.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "name": "@stdlib/utils/none-in-by", - "version": "0.0.0", - "description": "Test whether every property in an object fails a test implemented by 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": { - "benchmark": "./benchmark", - "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", - "none", - "all", - "every", - "iterate", - "object", - "validate" - ] -} diff --git a/lib/node_modules/@stdlib/utils/none-in-by/test/test.js b/lib/node_modules/@stdlib/utils/none-in-by/test/test.js deleted file mode 100644 index bda22ab0a4ea..000000000000 --- a/lib/node_modules/@stdlib/utils/none-in-by/test/test.js +++ /dev/null @@ -1,166 +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 noneInBy = require( './../lib' ); - - -// FUNCTIONS // - -function isPositive( value ) { - return ( value > 0 ); -} - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof noneInBy, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided 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() { - noneInBy( value, noop ); - }; - } -}); - -tape( 'the function throws an error if not provided a predicate function', function test( t ) { - var values; - - values = { - 'a': 10, - 'b': 12, - 'c': 15 - }; - - t.throws( badValue( values ), TypeError, 'throws a type error when provided '+values ); - t.end(); - - function badValue( value ) { - return function badValue() { - noneInBy( value, value ); - }; - } -}); - -tape( 'if provided an empty object, the function returns `true`', function test( t ) { - var bool; - var obj = {}; - - function foo() { - t.fail( 'should not be invoked' ); - } - - bool = noneInBy( obj, foo ); - - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape('the function returns `true` if every property fails a test ', function test( t ) { - var bool; - - var obj = { - 'a': -1, - 'b': -2, - 'c': -3 - }; - - bool = noneInBy( obj, isPositive ); - - t.strictEqual( bool, true, 'returns true' ); - t.end(); -}); - -tape( 'the function returns `false` if one or more properties pass a test ', function test( t ) { - var bool; - var obj = { - '0': -1, - '1': 2, - '2': -3 - }; - - bool = noneInBy( 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 sum( value ) { - /* eslint-disable no-invalid-this */ - if ( value < 0 ) { - return false; - } - this.sum += value; - this.count += 1; - return false; - } - - ctx = { - 'sum': 0, - 'count': 0 - }; - obj = { - '0': 1.0, - '1': 2.0, - '2': 3.0 - }; - - bool = noneInBy( obj, sum, ctx ); - - t.strictEqual( bool, true, 'returns true' ); - t.strictEqual( ctx.sum / ctx.count, 2.0, 'expected result' ); - - t.end(); -}); From f4363380546535eacc2ab3d924ef1d40cafd182b Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Mon, 21 Apr 2025 00:31:48 +0530 Subject: [PATCH 4/4] chore: fix README lint errors --- .../@stdlib/object/every-in-by/README.md | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lib/node_modules/@stdlib/object/every-in-by/README.md b/lib/node_modules/@stdlib/object/every-in-by/README.md index 691aad518ed7..09bcb7a23911 100644 --- a/lib/node_modules/@stdlib/object/every-in-by/README.md +++ b/lib/node_modules/@stdlib/object/every-in-by/README.md @@ -122,20 +122,6 @@ bool = everyInBy( o, isPositive );