From 0f29e93036e8d82eac5a00f10704579aeb9038a1 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Sat, 27 Dec 2025 14:48:45 +0530 Subject: [PATCH 1/4] feat: add `object/common-keys-in` Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- .../@stdlib/object/common-keys-in/README.md | 125 +++++++++++ .../common-keys-in/benchmark/benchmark.js | 71 ++++++ .../benchmark/benchmark.num_arguments.js | 107 +++++++++ .../benchmark/benchmark.num_properties.js | 104 +++++++++ .../object/common-keys-in/docs/repl.txt | 29 +++ .../common-keys-in/docs/types/index.d.ts | 70 ++++++ .../object/common-keys-in/docs/types/test.ts | 33 +++ .../object/common-keys-in/examples/index.js | 41 ++++ .../object/common-keys-in/lib/index.js | 51 +++++ .../@stdlib/object/common-keys-in/lib/main.js | 106 +++++++++ .../object/common-keys-in/package.json | 72 +++++++ .../object/common-keys-in/test/test.js | 204 ++++++++++++++++++ 12 files changed, 1013 insertions(+) create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/README.md create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.num_arguments.js create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.num_properties.js create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/examples/index.js create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/lib/index.js create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/lib/main.js create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/package.json create mode 100644 lib/node_modules/@stdlib/object/common-keys-in/test/test.js diff --git a/lib/node_modules/@stdlib/object/common-keys-in/README.md b/lib/node_modules/@stdlib/object/common-keys-in/README.md new file mode 100644 index 000000000000..3db11e18a5a3 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/README.md @@ -0,0 +1,125 @@ + + +# commonKeysIn + +> Return the common own and inherited property names of two or more objects. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var commonKeysIn = require( '@stdlib/object/common-keys-in' ); +``` + +#### commonKeysIn( obj1, obj2\[, obj3\[,...,objN]] ) + +Returns the common own and inherited property names of two or more objects. + +```javascript +var obj = { + 'a': 1, + 'b': 2, + 'c': 3 +}; + +var obj2 = { + 'a': 1, + 'b': 2 +}; + +var keys = commonKeysIn( obj, obj2 ); +// returns [ 'a', 'b' ] +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var commonKeysIn = require( '@stdlib/object/common-keys-in' ); + +function Foo() { + this.beep = 'boop'; + this.a = { + 'b': 'c' + }; + return this; +} + +Foo.prototype.foo = [ 'bar' ]; + +var obj1 = new Foo(); + +var obj2 = { + 'beep': 'boop', + 'foo': 'bar' +}; + +var keys = commonKeysIn( obj1, obj2 ); +// returns [ 'beep', 'foo' ] +``` + +
+ + + + + +
+ +
+ + + + + + + + diff --git a/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.js b/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.js new file mode 100644 index 000000000000..7a4795874ea0 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); +var fromCodePoint = require( '@stdlib/string/from-code-point' ); +var pkg = require( './../package.json' ).name; +var commonKeysIn = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var obj1; + var obj2; + var out; + var i; + + obj1 = { + 'b': 3.141592653589793, + 'c': { + 'c1': 'bap', + 'c3': { + 'c3b': 5, + 'c3c': 'bop' + }, + 'c4': 1337 + }, + 'd': [ 4, 5, 6 ], + 'e': true + }; + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + obj2 = { + 'a': 'beep', + 'b': 'baz', + 'c': 'boop' + }; + obj2[ fromCodePoint( i%126 ) ] = 'bar'; + out = commonKeysIn( obj1, obj2 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isStringArray( out ) && !isEmptyArray( out ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.num_arguments.js b/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.num_arguments.js new file mode 100644 index 000000000000..c7aea10dc45e --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.num_arguments.js @@ -0,0 +1,107 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 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 pow = require( '@stdlib/math/base/special/pow' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); +var pkg = require( './../package.json' ).name; +var commonKeysIn = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of arguments +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var args; + var o; + var i; + var j; + + args = []; + for ( i = 0; i < N; i++ ) { + o = {}; + for ( j = 0; j < 10; j++ ) { + o[ j ] = i * j; + } + args.push( o ); + } + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var keys; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + keys = commonKeysIn.apply( null, args ); + if ( typeof keys !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isStringArray( keys ) && !isEmptyArray( keys ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 2^min + max = 6; // 2^max + + for ( i = min; i <= max; i++ ) { + len = pow( 2, i ); + f = createBenchmark( len ); + bench( pkg+':num_args='+len+',num_properties=10', f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.num_properties.js b/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.num_properties.js new file mode 100644 index 000000000000..e977bafe7f12 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/benchmark/benchmark.num_properties.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 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 pow = require( '@stdlib/math/base/special/pow' ); +var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; +var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); +var pkg = require( './../package.json' ).name; +var commonKeysIn = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} N - number of properties +* @returns {Function} benchmark function +*/ +function createBenchmark( N ) { + var x; + var y; + var i; + + x = {}; + y = {}; + for ( i = 0; i < N; i++ ) { + x[ i ] = i; + y[ i ] = i + 1; + } + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var keys; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + keys = commonKeysIn( x, y ); + if ( typeof keys !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !isStringArray( keys ) && !isEmptyArray( keys ) ) { + b.fail( 'should return an array of strings' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':num_properties='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/object/common-keys-in/docs/repl.txt b/lib/node_modules/@stdlib/object/common-keys-in/docs/repl.txt new file mode 100644 index 000000000000..792412fa2821 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/docs/repl.txt @@ -0,0 +1,29 @@ + +{{alias}}( obj1, obj2[, ...obj] ) + Returns the common own and inherited property names of two or more objects. + + Parameters + ---------- + obj1: any + First object. + + obj2: any + Second object. + + obj: ...any (optional) + Additional objects. + + Returns + ------- + out: Array + Common keys. + + Examples + -------- + > var obj1 = { 'a': 1, 'b': 2 }; + > var obj2 = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }; + > var keys = {{alias}}( obj1, obj2 ) + [ 'a', 'b' ] + + See Also + -------- diff --git a/lib/node_modules/@stdlib/object/common-keys-in/docs/types/index.d.ts b/lib/node_modules/@stdlib/object/common-keys-in/docs/types/index.d.ts new file mode 100644 index 000000000000..9238351b757c --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/docs/types/index.d.ts @@ -0,0 +1,70 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 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 + +/// + +/** +* Returns the common own and inherited property names of two or more objects. +* +* @param obj1 - first object +* @param obj2 - second object +* @param obj - additional objects +* @returns common keys +* +* @example +* var obj = { +* 'a': 1, +* 'b': 2, +* 'c': 3 +* }; +* +* var obj2 = { +* 'a': 1, +* 'b': 2 +* }; +* +* var keys = commonKeysIn( obj, obj2 ); +* // returns [ 'a', 'b' ] +* +* @example +* var obj1 = { +* 'a': 1, +* 'b': 2, +* 'c': 3 +* }; +* +* var obj2 = { +* 'a': 1, +* 'b': 2 +* }; +* +* var obj3 = { +* 'a': 1, +* }; +* +* var keys = commonKeysIn( obj1, obj2, obj3 ); +* // returns [ 'a' ] +*/ +declare function commonKeysIn( obj1: any, obj2: any, ...obj: Array ): Array; + + +// EXPORTS // + +export = commonKeysIn; diff --git a/lib/node_modules/@stdlib/object/common-keys-in/docs/types/test.ts b/lib/node_modules/@stdlib/object/common-keys-in/docs/types/test.ts new file mode 100644 index 000000000000..63cb933fc170 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/docs/types/test.ts @@ -0,0 +1,33 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2021 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 commonKeysIn = require( './index' ); + + +// TESTS // + +// The function returns an array of strings... +{ + commonKeysIn( { 'a': 0, 'b': 1 }, { 'a': 0 } ); // $ExpectType string[] +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + commonKeysIn(); // $ExpectError + commonKeysIn( {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/object/common-keys-in/examples/index.js b/lib/node_modules/@stdlib/object/common-keys-in/examples/index.js new file mode 100644 index 000000000000..e9124fd7d531 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/examples/index.js @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 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 commonKeysIn = require( './../lib' ); + +function Foo() { + this.beep = 'boop'; + this.a = { + 'b': 'c' + }; + return this; +} + +Foo.prototype.foo = [ 'bar' ]; + +var obj1 = new Foo(); + +var obj2 = { + 'beep': 'boop', + 'foo': 'bar' +}; + +console.log( commonKeysIn( obj1, obj2 ) ); +// => [ 'beep', 'foo' ] diff --git a/lib/node_modules/@stdlib/object/common-keys-in/lib/index.js b/lib/node_modules/@stdlib/object/common-keys-in/lib/index.js new file mode 100644 index 000000000000..dc4ef63421c4 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/lib/index.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 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'; + +/** +* Return the common own and inherited property names of two or more objects. +* +* @module @stdlib/object/common-keys-in +* +* @example +* var commonKeysIn = require( '@stdlib/object/common-keys-in' ); +* +* var obj = { +* 'a': 1, +* 'b': 2, +* 'c': 3 +* }; +* +* var obj2 = { +* 'a': 1, +* 'b': 2 +* }; +* +* var keys = commonKeysIn( obj, obj2 ); +* // returns [ 'a', 'b' ] +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/object/common-keys-in/lib/main.js b/lib/node_modules/@stdlib/object/common-keys-in/lib/main.js new file mode 100644 index 000000000000..beb3ab6f7b10 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/lib/main.js @@ -0,0 +1,106 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 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 keysIn = require( '@stdlib/utils/keys-in' ); +var hasProp = require( '@stdlib/assert/has-property' ); + + +// MAIN // + +/** +* Returns the common own and inherited property names of two or more objects. +* +* @param {*} obj1 - first object +* @param {*} obj2 - second object +* @param {...*} [obj] - additional objects +* @throws {Error} must provide at least two objects +* @returns {(StringArray|EmptyArray)} common keys +* +* @example +* var obj = { +* 'a': 1, +* 'b': 2, +* 'c': 3 +* }; +* +* var obj2 = { +* 'a': 1, +* 'b': 2 +* }; +* +* var keys = commonKeysIn( obj, obj2 ); +* // returns [ 'a', 'b' ] +* +* @example +* var obj1 = { +* 'a': 1, +* 'b': 2, +* 'c': 3 +* }; +* +* var obj2 = { +* 'a': 1, +* 'b': 2 +* }; +* +* var obj3 = { +* 'a': 1, +* }; +* +* var keys = commonKeysIn( obj1, obj2, obj3 ); +* // returns [ 'a' ] +*/ +function commonKeysIn() { + var nargs; + var keys; + var arg; + var ptr; + var N; + var i; + var j; + + nargs = arguments.length; + if ( nargs < 2 ) { + throw new Error( 'insufficient arguments. Must provide at least two objects.' ); + } + keys = keysIn( arguments[ 0 ] ); + N = keys.length; + + for ( i = 1; i < nargs; i++ ) { + arg = arguments[ i ]; + ptr = 0; + for ( j = 0; j < N; j++ ) { + if ( hasProp( arg, keys[ j ] ) ) { + keys[ ptr ] = keys[ j ]; + ptr += 1; + } + } + N = ptr; + } + keys.length = N; + return keys; +} + + +// EXPORTS // + +module.exports = commonKeysIn; diff --git a/lib/node_modules/@stdlib/object/common-keys-in/package.json b/lib/node_modules/@stdlib/object/common-keys-in/package.json new file mode 100644 index 000000000000..0794835676c2 --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/package.json @@ -0,0 +1,72 @@ +{ + "name": "@stdlib/object/common-keys-in", + "version": "0.0.0", + "description": "Return the common own and inherited property names of two or more objects.", + "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", + "object", + "obj", + "names", + "keys", + "enumerable", + "own", + "common", + "shared", + "properties", + "props", + "inherited", + "prototype" + ] +} diff --git a/lib/node_modules/@stdlib/object/common-keys-in/test/test.js b/lib/node_modules/@stdlib/object/common-keys-in/test/test.js new file mode 100644 index 000000000000..28ecc1d6e82e --- /dev/null +++ b/lib/node_modules/@stdlib/object/common-keys-in/test/test.js @@ -0,0 +1,204 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 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 commonKeysIn = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof commonKeysIn, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function throws an error if provided insufficient arguments', function test( t ) { + t.throws( foo, Error, 'throws error' ); + t.throws( bar, Error, 'throws error' ); + t.end(); + function foo() { + commonKeysIn(); + } + function bar() { + commonKeysIn( {} ); + } +}); + +tape( 'the function returns an array of common property names (two objects)', function test( t ) { + var expected; + var actual; + var obj1; + var obj2; + var obj3; + + obj1 = { + 'a': 1, + 'b': 2, + 'c': 3, + 'd': 4 + }; + obj2 = { + 'a': 1, + 'b': 2, + 'c': 3 + }; + obj3 = { + 'c': 3, + 'd': 4 + }; + + actual = commonKeysIn( obj1, obj2 ); + expected = [ 'a', 'b', 'c' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + actual = commonKeysIn( obj1, obj3 ); + expected = [ 'c', 'd' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + actual = commonKeysIn( obj2, obj3 ); + expected = [ 'c' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + t.end(); +}); + +tape( 'the function returns an array of common property names (multiple objects)', function test( t ) { + var expected; + var actual; + var obj1; + var obj2; + var obj3; + var obj4; + + obj1 = { + 'a': 1, + 'b': 2, + 'c': 3, + 'd': 4, + 'e': 5, + 'f': 6 + }; + obj2 = { + 'a': 1, + 'b': 2, + 'c': 3, + 'd': 4, + 'f': 6 + }; + obj3 = { + 'a': 1, + 'c': 3, + 'd': 4 + }; + obj4 = { + 'a': 1, + 'b': 2 + }; + + actual = commonKeysIn( obj1, obj2, obj3, obj4 ); + expected = [ 'a' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + actual = commonKeysIn( obj2, obj3, obj4 ); + expected = [ 'a' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + actual = commonKeysIn( obj3, obj2, obj1 ); + expected = [ 'a', 'c', 'd' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + actual = commonKeysIn( obj4, obj2, obj1 ); + expected = [ 'a', 'b' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + actual = commonKeysIn( obj2, obj1, obj3 ); + expected = [ 'a', 'c', 'd' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + t.end(); +}); + +tape( 'the function returns an array of common property names (arrays, strings)', function test( t ) { + var expected; + var actual; + var x; + var y; + + x = [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]; + y = [ 5, 6, 7, 8, 9 ]; + expected = [ '0', '1', '2', '3', '4' ]; + actual = commonKeysIn( x, y ); + t.deepEqual( actual, expected, 'returns expected keys' ); + + x = { + '0': 0, + '2': 2 + }; + y = [ 0, 1, 2 ]; + expected = [ '0', '2' ]; + actual = commonKeysIn( x, y ); + t.deepEqual( actual, expected, 'returns expected keys' ); + + x = 'abcd'; + y = 'abcdef'; + expected = [ '0', '1', '2', '3' ]; + actual = commonKeysIn( x, y ); + t.deepEqual( actual, expected, 'returns expected keys' ); + + t.end(); +}); + +tape( 'the function returns an array of common property names (inherited properties)', function test( t ) { + var expected; + var actual; + var obj1; + var obj2; + var obj3; + + obj1 = { + 'a': 1, + 'b': 2, + 'c': 3, + 'd': 4 + }; + obj2 = Object.create( obj1 ); + obj2.e = 5; + obj2.f = 6; + obj3 = Object.create( obj2 ); + obj3.g = 7; + obj3.h = 8; + + actual = commonKeysIn( obj1, obj2, obj3 ); + expected = [ 'a', 'b', 'c', 'd' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + actual = commonKeysIn( obj2, obj3 ); + expected = [ 'e', 'f', 'a', 'b', 'c', 'd' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + actual = commonKeysIn( obj3, obj3 ); + expected = [ 'g', 'h', 'e', 'f', 'a', 'b', 'c', 'd' ]; + t.deepEqual( actual, expected, 'returns expected keys' ); + + t.end(); +}); From b7b06cfa2746a86c1f428af76a5501c4d88ce289 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Sat, 27 Dec 2025 14:50:03 +0530 Subject: [PATCH 2/4] remove: remove `commonKeysIn` from namespace This commit removes the `commonKeysIn` symbol from the `@stdlib/utils` namespace due to a package migration. BREAKING CHANGE: remove `commonKeysIn` To migrate, users should access the same symbol via the `@stdlib/object` namespace. Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- .../@stdlib/utils/docs/types/index.d.ts | 45 ------------------- lib/node_modules/@stdlib/utils/lib/index.js | 9 ---- 2 files changed, 54 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/docs/types/index.d.ts index 5b83e832a32e..6af6c2aa5bf0 100644 --- a/lib/node_modules/@stdlib/utils/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/docs/types/index.d.ts @@ -30,7 +30,6 @@ import bifurcate = require( '@stdlib/utils/bifurcate' ); import bifurcateBy = require( '@stdlib/utils/bifurcate-by' ); import bifurcateIn = require( '@stdlib/utils/bifurcate-in' ); import bifurcateOwn = require( '@stdlib/utils/bifurcate-own' ); -import commonKeysIn = require( '@stdlib/utils/common-keys-in' ); import compose = require( '@stdlib/utils/compose' ); import constantFunction = require( '@stdlib/utils/constant-function' ); import constructorName = require( '@stdlib/utils/constructor-name' ); @@ -570,50 +569,6 @@ interface Namespace { */ bifurcateOwn: typeof bifurcateOwn; - /** - * Returns the common own and inherited property names of two or more objects. - * - * @param obj1 - first object - * @param obj2 - second object - * @param obj - additional objects - * @returns common keys - * - * @example - * var obj = { - * 'a': 1, - * 'b': 2, - * 'c': 3 - * }; - * - * var obj2 = { - * 'a': 1, - * 'b': 2 - * }; - * - * var keys = ns.commonKeysIn( obj, obj2 ); - * // returns [ 'a', 'b' ] - * - * @example - * var obj1 = { - * 'a': 1, - * 'b': 2, - * 'c': 3 - * }; - * - * var obj2 = { - * 'a': 1, - * 'b': 2 - * }; - * - * var obj3 = { - * 'a': 1, - * }; - * - * var keys = ns.commonKeysIn( obj1, obj2, obj3 ); - * // returns [ 'a' ] - */ - commonKeysIn: typeof commonKeysIn; - /** * Function composition. * diff --git a/lib/node_modules/@stdlib/utils/lib/index.js b/lib/node_modules/@stdlib/utils/lib/index.js index e86b750197f3..badc25367154 100644 --- a/lib/node_modules/@stdlib/utils/lib/index.js +++ b/lib/node_modules/@stdlib/utils/lib/index.js @@ -130,15 +130,6 @@ setReadOnly( utils, 'bifurcateIn', require( '@stdlib/utils/bifurcate-in' ) ); */ setReadOnly( utils, 'bifurcateOwn', require( '@stdlib/utils/bifurcate-own' ) ); -/** -* @name commonKeysIn -* @memberof utils -* @readonly -* @type {Function} -* @see {@link module:@stdlib/utils/common-keys-in} -*/ -setReadOnly( utils, 'commonKeysIn', require( '@stdlib/utils/common-keys-in' ) ); - /** * @name compose * @memberof utils From e642d022599039169156fe686192248cf3d70599 Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Sat, 27 Dec 2025 14:53:45 +0530 Subject: [PATCH 3/4] refactor: update paths Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv | 2 +- lib/node_modules/@stdlib/namespace/lib/namespace/c.js | 6 +++--- 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 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv index af8abb5a877a..0beda5c23b05 100644 --- a/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/alias2pkg/data/data.csv @@ -1527,7 +1527,7 @@ close,"@stdlib/fs/close" CMUDICT,"@stdlib/datasets/cmudict" codePointAt,"@stdlib/string/code-point-at" commonKeys,"@stdlib/object/common-keys" -commonKeysIn,"@stdlib/utils/common-keys-in" +commonKeysIn,"@stdlib/object/common-keys-in" complex,"@stdlib/complex/cmplx" Complex64,"@stdlib/complex/float32/ctor" COMPLEX64_NAN,"@stdlib/constants/complex64/nan" diff --git a/lib/node_modules/@stdlib/namespace/lib/namespace/c.js b/lib/node_modules/@stdlib/namespace/lib/namespace/c.js index ea2b799c076d..0fe8879a78da 100644 --- a/lib/node_modules/@stdlib/namespace/lib/namespace/c.js +++ b/lib/node_modules/@stdlib/namespace/lib/namespace/c.js @@ -208,15 +208,15 @@ ns.push({ 'value': require( '@stdlib/object/common-keys' ), 'type': 'Function', 'related': [ - '@stdlib/utils/common-keys-in', + '@stdlib/object/common-keys-in', '@stdlib/utils/keys' ] }); ns.push({ 'alias': 'commonKeysIn', - 'path': '@stdlib/utils/common-keys-in', - 'value': require( '@stdlib/utils/common-keys-in' ), + 'path': '@stdlib/object/common-keys-in', + 'value': require( '@stdlib/object/common-keys-in' ), 'type': 'Function', 'related': [ '@stdlib/object/common-keys', diff --git a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv index 2f930f5f45ab..129167495b6f 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2alias/data/data.csv @@ -1527,7 +1527,7 @@ "@stdlib/datasets/cmudict",CMUDICT "@stdlib/string/code-point-at",codePointAt "@stdlib/object/common-keys",commonKeys -"@stdlib/utils/common-keys-in",commonKeysIn +"@stdlib/object/common-keys-in",commonKeysIn "@stdlib/complex/cmplx",complex "@stdlib/complex/float32/ctor",Complex64 "@stdlib/constants/complex64/nan",COMPLEX64_NAN diff --git a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv index 62ad5fb13206..522dc6186513 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2related/data/data.csv @@ -1526,8 +1526,8 @@ "@stdlib/fs/close","@stdlib/fs/exists,@stdlib/fs/open,@stdlib/fs/read-file" "@stdlib/datasets/cmudict","" "@stdlib/string/code-point-at","@stdlib/string/from-code-point" -"@stdlib/object/common-keys","@stdlib/utils/common-keys-in,@stdlib/utils/keys" -"@stdlib/utils/common-keys-in","@stdlib/object/common-keys,@stdlib/utils/keys-in" +"@stdlib/object/common-keys","@stdlib/object/common-keys-in,@stdlib/utils/keys" +"@stdlib/object/common-keys-in","@stdlib/object/common-keys,@stdlib/utils/keys-in" "@stdlib/complex/cmplx","@stdlib/complex/float64/ctor,@stdlib/complex/float32/ctor" "@stdlib/complex/float32/ctor","@stdlib/complex/cmplx,@stdlib/complex/float64/ctor" "@stdlib/constants/complex64/nan","@stdlib/constants/complex128/nan" diff --git a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv index 167e74ea8ead..60bdd7af0bc3 100644 --- a/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/pkg2standalone/data/data.csv @@ -1527,7 +1527,7 @@ "@stdlib/datasets/cmudict","@stdlib/datasets-cmudict" "@stdlib/string/code-point-at","@stdlib/string-code-point-at" "@stdlib/object/common-keys","@stdlib/object-common-keys" -"@stdlib/utils/common-keys-in","@stdlib/utils-common-keys-in" +"@stdlib/object/common-keys-in","@stdlib/object-common-keys-in" "@stdlib/complex/cmplx","@stdlib/complex-cmplx" "@stdlib/complex/float32/ctor","@stdlib/complex-float32-ctor" "@stdlib/constants/complex64/nan","@stdlib/constants-complex64-nan" diff --git a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv index a1a35021f95d..1571d9805f5e 100644 --- a/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv +++ b/lib/node_modules/@stdlib/namespace/standalone2pkg/data/data.csv @@ -1527,7 +1527,7 @@ "@stdlib/datasets-cmudict","@stdlib/datasets/cmudict" "@stdlib/string-code-point-at","@stdlib/string/code-point-at" "@stdlib/object-common-keys","@stdlib/object/common-keys" -"@stdlib/utils-common-keys-in","@stdlib/utils/common-keys-in" +"@stdlib/object-common-keys-in","@stdlib/object/common-keys-in" "@stdlib/complex-cmplx","@stdlib/complex/cmplx" "@stdlib/complex-float32-ctor","@stdlib/complex/float32/ctor" "@stdlib/constants-complex64-nan","@stdlib/constants/complex64/nan" From 2a46d3240d3c8c0049fc24aff17f3424e996676a Mon Sep 17 00:00:00 2001 From: NEERAJ Date: Sat, 27 Dec 2025 14:54:39 +0530 Subject: [PATCH 4/4] remove: remove `utils/common-keys-in` This commit removes `@stdlib/utils/common-keys-in` in favor of `@stdlib/object/common-keys-in`. BREAKING CHANGE: remove `utils/common-keys-in` To migrate, users should update their require/import paths to use `@stdlib/object/common-keys-in` which provides the same API and implementation. Ref: https://github.com/stdlib-js/stdlib/issues/8755 --- .../@stdlib/utils/common-keys-in/README.md | 125 ----------- .../common-keys-in/benchmark/benchmark.js | 71 ------ .../benchmark/benchmark.num_arguments.js | 107 --------- .../benchmark/benchmark.num_properties.js | 104 --------- .../utils/common-keys-in/docs/repl.txt | 29 --- .../common-keys-in/docs/types/index.d.ts | 70 ------ .../utils/common-keys-in/docs/types/test.ts | 33 --- .../utils/common-keys-in/examples/index.js | 41 ---- .../@stdlib/utils/common-keys-in/lib/index.js | 51 ----- .../@stdlib/utils/common-keys-in/lib/main.js | 106 --------- .../@stdlib/utils/common-keys-in/package.json | 72 ------- .../@stdlib/utils/common-keys-in/test/test.js | 204 ------------------ 12 files changed, 1013 deletions(-) delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/README.md delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.js delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.num_arguments.js delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.num_properties.js delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/docs/repl.txt delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/docs/types/index.d.ts delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/docs/types/test.ts delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/examples/index.js delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/lib/index.js delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/lib/main.js delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/package.json delete mode 100644 lib/node_modules/@stdlib/utils/common-keys-in/test/test.js diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/README.md b/lib/node_modules/@stdlib/utils/common-keys-in/README.md deleted file mode 100644 index 08e94d47058f..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/README.md +++ /dev/null @@ -1,125 +0,0 @@ - - -# commonKeysIn - -> Return the common own and inherited property names of two or more objects. - - - -
- -
- - - - - -
- -## Usage - -```javascript -var commonKeysIn = require( '@stdlib/utils/common-keys-in' ); -``` - -#### commonKeysIn( obj1, obj2\[, obj3\[,...,objN]] ) - -Returns the common own and inherited property names of two or more objects. - -```javascript -var obj = { - 'a': 1, - 'b': 2, - 'c': 3 -}; - -var obj2 = { - 'a': 1, - 'b': 2 -}; - -var keys = commonKeysIn( obj, obj2 ); -// returns [ 'a', 'b' ] -``` - -
- - - - - -
- -
- - - - - -
- -## Examples - - - -```javascript -var commonKeysIn = require( '@stdlib/utils/common-keys-in' ); - -function Foo() { - this.beep = 'boop'; - this.a = { - 'b': 'c' - }; - return this; -} - -Foo.prototype.foo = [ 'bar' ]; - -var obj1 = new Foo(); - -var obj2 = { - 'beep': 'boop', - 'foo': 'bar' -}; - -var keys = commonKeysIn( obj1, obj2 ); -// returns [ 'beep', 'foo' ] -``` - -
- - - - - -
- -
- - - - - - - - diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.js b/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.js deleted file mode 100644 index 7a4795874ea0..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.js +++ /dev/null @@ -1,71 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 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 isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); -var fromCodePoint = require( '@stdlib/string/from-code-point' ); -var pkg = require( './../package.json' ).name; -var commonKeysIn = require( './../lib' ); - - -// MAIN // - -bench( pkg, function benchmark( b ) { - var obj1; - var obj2; - var out; - var i; - - obj1 = { - 'b': 3.141592653589793, - 'c': { - 'c1': 'bap', - 'c3': { - 'c3b': 5, - 'c3c': 'bop' - }, - 'c4': 1337 - }, - 'd': [ 4, 5, 6 ], - 'e': true - }; - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - obj2 = { - 'a': 'beep', - 'b': 'baz', - 'c': 'boop' - }; - obj2[ fromCodePoint( i%126 ) ] = 'bar'; - out = commonKeysIn( obj1, obj2 ); - if ( typeof out !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isStringArray( out ) && !isEmptyArray( out ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.num_arguments.js b/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.num_arguments.js deleted file mode 100644 index c7aea10dc45e..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.num_arguments.js +++ /dev/null @@ -1,107 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 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 pow = require( '@stdlib/math/base/special/pow' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); -var pkg = require( './../package.json' ).name; -var commonKeysIn = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - number of arguments -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - var args; - var o; - var i; - var j; - - args = []; - for ( i = 0; i < N; i++ ) { - o = {}; - for ( j = 0; j < 10; j++ ) { - o[ j ] = i * j; - } - args.push( o ); - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var keys; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - keys = commonKeysIn.apply( null, args ); - if ( typeof keys !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isStringArray( keys ) && !isEmptyArray( keys ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 2^min - max = 6; // 2^max - - for ( i = min; i <= max; i++ ) { - len = pow( 2, i ); - f = createBenchmark( len ); - bench( pkg+':num_args='+len+',num_properties=10', f ); - } -} - -main(); diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.num_properties.js b/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.num_properties.js deleted file mode 100644 index e977bafe7f12..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/benchmark/benchmark.num_properties.js +++ /dev/null @@ -1,104 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 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 pow = require( '@stdlib/math/base/special/pow' ); -var isStringArray = require( '@stdlib/assert/is-string-array' ).primitives; -var isEmptyArray = require( '@stdlib/assert/is-empty-array' ); -var pkg = require( './../package.json' ).name; -var commonKeysIn = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveInteger} N - number of properties -* @returns {Function} benchmark function -*/ -function createBenchmark( N ) { - var x; - var y; - var i; - - x = {}; - y = {}; - for ( i = 0; i < N; i++ ) { - x[ i ] = i; - y[ i ] = i + 1; - } - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var keys; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - keys = commonKeysIn( x, y ); - if ( typeof keys !== 'object' ) { - b.fail( 'should return an object' ); - } - } - b.toc(); - if ( !isStringArray( keys ) && !isEmptyArray( keys ) ) { - b.fail( 'should return an array of strings' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var len; - var min; - var max; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - len = pow( 10, i ); - f = createBenchmark( len ); - bench( pkg+':num_properties='+len, f ); - } -} - -main(); diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/docs/repl.txt b/lib/node_modules/@stdlib/utils/common-keys-in/docs/repl.txt deleted file mode 100644 index 792412fa2821..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/docs/repl.txt +++ /dev/null @@ -1,29 +0,0 @@ - -{{alias}}( obj1, obj2[, ...obj] ) - Returns the common own and inherited property names of two or more objects. - - Parameters - ---------- - obj1: any - First object. - - obj2: any - Second object. - - obj: ...any (optional) - Additional objects. - - Returns - ------- - out: Array - Common keys. - - Examples - -------- - > var obj1 = { 'a': 1, 'b': 2 }; - > var obj2 = { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }; - > var keys = {{alias}}( obj1, obj2 ) - [ 'a', 'b' ] - - See Also - -------- diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/common-keys-in/docs/types/index.d.ts deleted file mode 100644 index 9238351b757c..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/docs/types/index.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 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 - -/// - -/** -* Returns the common own and inherited property names of two or more objects. -* -* @param obj1 - first object -* @param obj2 - second object -* @param obj - additional objects -* @returns common keys -* -* @example -* var obj = { -* 'a': 1, -* 'b': 2, -* 'c': 3 -* }; -* -* var obj2 = { -* 'a': 1, -* 'b': 2 -* }; -* -* var keys = commonKeysIn( obj, obj2 ); -* // returns [ 'a', 'b' ] -* -* @example -* var obj1 = { -* 'a': 1, -* 'b': 2, -* 'c': 3 -* }; -* -* var obj2 = { -* 'a': 1, -* 'b': 2 -* }; -* -* var obj3 = { -* 'a': 1, -* }; -* -* var keys = commonKeysIn( obj1, obj2, obj3 ); -* // returns [ 'a' ] -*/ -declare function commonKeysIn( obj1: any, obj2: any, ...obj: Array ): Array; - - -// EXPORTS // - -export = commonKeysIn; diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/docs/types/test.ts b/lib/node_modules/@stdlib/utils/common-keys-in/docs/types/test.ts deleted file mode 100644 index 63cb933fc170..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/docs/types/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2021 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 commonKeysIn = require( './index' ); - - -// TESTS // - -// The function returns an array of strings... -{ - commonKeysIn( { 'a': 0, 'b': 1 }, { 'a': 0 } ); // $ExpectType string[] -} - -// The compiler throws an error if the function is provided insufficient arguments... -{ - commonKeysIn(); // $ExpectError - commonKeysIn( {} ); // $ExpectError -} diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/examples/index.js b/lib/node_modules/@stdlib/utils/common-keys-in/examples/index.js deleted file mode 100644 index e9124fd7d531..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/examples/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 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 commonKeysIn = require( './../lib' ); - -function Foo() { - this.beep = 'boop'; - this.a = { - 'b': 'c' - }; - return this; -} - -Foo.prototype.foo = [ 'bar' ]; - -var obj1 = new Foo(); - -var obj2 = { - 'beep': 'boop', - 'foo': 'bar' -}; - -console.log( commonKeysIn( obj1, obj2 ) ); -// => [ 'beep', 'foo' ] diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/lib/index.js b/lib/node_modules/@stdlib/utils/common-keys-in/lib/index.js deleted file mode 100644 index 71aef90222c0..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/lib/index.js +++ /dev/null @@ -1,51 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 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'; - -/** -* Return the common own and inherited property names of two or more objects. -* -* @module @stdlib/utils/common-keys-in -* -* @example -* var commonKeysIn = require( '@stdlib/utils/common-keys-in' ); -* -* var obj = { -* 'a': 1, -* 'b': 2, -* 'c': 3 -* }; -* -* var obj2 = { -* 'a': 1, -* 'b': 2 -* }; -* -* var keys = commonKeysIn( obj, obj2 ); -* // returns [ 'a', 'b' ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/lib/main.js b/lib/node_modules/@stdlib/utils/common-keys-in/lib/main.js deleted file mode 100644 index beb3ab6f7b10..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/lib/main.js +++ /dev/null @@ -1,106 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 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 keysIn = require( '@stdlib/utils/keys-in' ); -var hasProp = require( '@stdlib/assert/has-property' ); - - -// MAIN // - -/** -* Returns the common own and inherited property names of two or more objects. -* -* @param {*} obj1 - first object -* @param {*} obj2 - second object -* @param {...*} [obj] - additional objects -* @throws {Error} must provide at least two objects -* @returns {(StringArray|EmptyArray)} common keys -* -* @example -* var obj = { -* 'a': 1, -* 'b': 2, -* 'c': 3 -* }; -* -* var obj2 = { -* 'a': 1, -* 'b': 2 -* }; -* -* var keys = commonKeysIn( obj, obj2 ); -* // returns [ 'a', 'b' ] -* -* @example -* var obj1 = { -* 'a': 1, -* 'b': 2, -* 'c': 3 -* }; -* -* var obj2 = { -* 'a': 1, -* 'b': 2 -* }; -* -* var obj3 = { -* 'a': 1, -* }; -* -* var keys = commonKeysIn( obj1, obj2, obj3 ); -* // returns [ 'a' ] -*/ -function commonKeysIn() { - var nargs; - var keys; - var arg; - var ptr; - var N; - var i; - var j; - - nargs = arguments.length; - if ( nargs < 2 ) { - throw new Error( 'insufficient arguments. Must provide at least two objects.' ); - } - keys = keysIn( arguments[ 0 ] ); - N = keys.length; - - for ( i = 1; i < nargs; i++ ) { - arg = arguments[ i ]; - ptr = 0; - for ( j = 0; j < N; j++ ) { - if ( hasProp( arg, keys[ j ] ) ) { - keys[ ptr ] = keys[ j ]; - ptr += 1; - } - } - N = ptr; - } - keys.length = N; - return keys; -} - - -// EXPORTS // - -module.exports = commonKeysIn; diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/package.json b/lib/node_modules/@stdlib/utils/common-keys-in/package.json deleted file mode 100644 index 161dce1fdaf5..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/package.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "name": "@stdlib/utils/common-keys-in", - "version": "0.0.0", - "description": "Return the common own and inherited property names of two or more objects.", - "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", - "object", - "obj", - "names", - "keys", - "enumerable", - "own", - "common", - "shared", - "properties", - "props", - "inherited", - "prototype" - ] -} diff --git a/lib/node_modules/@stdlib/utils/common-keys-in/test/test.js b/lib/node_modules/@stdlib/utils/common-keys-in/test/test.js deleted file mode 100644 index 28ecc1d6e82e..000000000000 --- a/lib/node_modules/@stdlib/utils/common-keys-in/test/test.js +++ /dev/null @@ -1,204 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 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 commonKeysIn = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof commonKeysIn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided insufficient arguments', function test( t ) { - t.throws( foo, Error, 'throws error' ); - t.throws( bar, Error, 'throws error' ); - t.end(); - function foo() { - commonKeysIn(); - } - function bar() { - commonKeysIn( {} ); - } -}); - -tape( 'the function returns an array of common property names (two objects)', function test( t ) { - var expected; - var actual; - var obj1; - var obj2; - var obj3; - - obj1 = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4 - }; - obj2 = { - 'a': 1, - 'b': 2, - 'c': 3 - }; - obj3 = { - 'c': 3, - 'd': 4 - }; - - actual = commonKeysIn( obj1, obj2 ); - expected = [ 'a', 'b', 'c' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - actual = commonKeysIn( obj1, obj3 ); - expected = [ 'c', 'd' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - actual = commonKeysIn( obj2, obj3 ); - expected = [ 'c' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - t.end(); -}); - -tape( 'the function returns an array of common property names (multiple objects)', function test( t ) { - var expected; - var actual; - var obj1; - var obj2; - var obj3; - var obj4; - - obj1 = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5, - 'f': 6 - }; - obj2 = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'f': 6 - }; - obj3 = { - 'a': 1, - 'c': 3, - 'd': 4 - }; - obj4 = { - 'a': 1, - 'b': 2 - }; - - actual = commonKeysIn( obj1, obj2, obj3, obj4 ); - expected = [ 'a' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - actual = commonKeysIn( obj2, obj3, obj4 ); - expected = [ 'a' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - actual = commonKeysIn( obj3, obj2, obj1 ); - expected = [ 'a', 'c', 'd' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - actual = commonKeysIn( obj4, obj2, obj1 ); - expected = [ 'a', 'b' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - actual = commonKeysIn( obj2, obj1, obj3 ); - expected = [ 'a', 'c', 'd' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - t.end(); -}); - -tape( 'the function returns an array of common property names (arrays, strings)', function test( t ) { - var expected; - var actual; - var x; - var y; - - x = [ 0, 1, 2, 3, 4, 5, 6, 7, 8 ]; - y = [ 5, 6, 7, 8, 9 ]; - expected = [ '0', '1', '2', '3', '4' ]; - actual = commonKeysIn( x, y ); - t.deepEqual( actual, expected, 'returns expected keys' ); - - x = { - '0': 0, - '2': 2 - }; - y = [ 0, 1, 2 ]; - expected = [ '0', '2' ]; - actual = commonKeysIn( x, y ); - t.deepEqual( actual, expected, 'returns expected keys' ); - - x = 'abcd'; - y = 'abcdef'; - expected = [ '0', '1', '2', '3' ]; - actual = commonKeysIn( x, y ); - t.deepEqual( actual, expected, 'returns expected keys' ); - - t.end(); -}); - -tape( 'the function returns an array of common property names (inherited properties)', function test( t ) { - var expected; - var actual; - var obj1; - var obj2; - var obj3; - - obj1 = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4 - }; - obj2 = Object.create( obj1 ); - obj2.e = 5; - obj2.f = 6; - obj3 = Object.create( obj2 ); - obj3.g = 7; - obj3.h = 8; - - actual = commonKeysIn( obj1, obj2, obj3 ); - expected = [ 'a', 'b', 'c', 'd' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - actual = commonKeysIn( obj2, obj3 ); - expected = [ 'e', 'f', 'a', 'b', 'c', 'd' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - actual = commonKeysIn( obj3, obj3 ); - expected = [ 'g', 'h', 'e', 'f', 'a', 'b', 'c', 'd' ]; - t.deepEqual( actual, expected, 'returns expected keys' ); - - t.end(); -});