From c15a6eb9aeb54cd6f7890be4b6aebe1cc7bc4811 Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Tue, 24 Nov 2026 19:19:35 +0530 Subject: [PATCH 01/10] fix: handle missing `Object.prototype` methods in `@stdlib/assert` --- .../is-enumerable-property/lib/native.js | 17 +++- .../is-enumerable-property/lib/polyfill.js | 74 ++++++++++++++ .../is-enumerable-property/test/test.js | 73 ++++++++++++++ .../test/test.polyfill.js | 99 +++++++++++++++++++ .../assert/is-plain-object/lib/main.js | 13 +-- .../assert/is-plain-object/test/test.js | 64 ++++++++++++ 6 files changed, 333 insertions(+), 7 deletions(-) create mode 100644 lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js create mode 100644 lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/native.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/native.js index 5c4647426850..4e96f10809ca 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/native.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/native.js @@ -18,6 +18,16 @@ 'use strict'; +// MODULES // + +var polyfill = require( './polyfill.js' ); + + +// VARIABLES // + +var builtin = Object.prototype.propertyIsEnumerable; + + // MAIN // /** @@ -46,7 +56,12 @@ * var bool = isEnumerableProperty.call( beep, 'hasOwnProperty' ); * // returns false */ -var isEnumerableProperty = Object.prototype.propertyIsEnumerable; +var isEnumerableProperty; +if ( typeof builtin === 'function' ) { + isEnumerableProperty = builtin; +} else { + isEnumerableProperty = polyfill; +} // EXPORTS // diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js new file mode 100644 index 000000000000..9e4d8cf47eb5 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MAIN // + +/** +* Tests if an object's own property is enumerable. +* +* ## Notes +* +* - Enumerable own symbol properties are not detected (`Object.keys` cannot see symbols). +* +* @private +* @param {*} property - property to test +* @returns {boolean} boolean indicating if an object property is enumerable +* +* @example +* var beep = { +* 'boop': true +* }; +* +* var bool = isEnumerableProperty.call( beep, 'boop' ); +* // returns true +* +* @example +* var beep = { +* 'boop': true +* }; +* +* var bool = isEnumerableProperty.call( beep, 'hasOwnProperty' ); +* // returns false +*/ +function isEnumerableProperty( property ) { + var keys; + var prop; + var i; + + if ( this === null || this === void 0 ) { + return false; + } + if ( typeof property === 'symbol' ) { + return false; + } + keys = Object.keys( Object( this ) ); + prop = '' + property; + for ( i = 0; i < keys.length; i++ ) { + if ( keys[ i ] === prop ) { + return true; + } + } + return false; +} + + +// EXPORTS // + +module.exports = isEnumerableProperty; diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js index 2433d2b298e7..ba7e78fc7e2d 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js @@ -155,3 +155,76 @@ tape( 'property values are coerced to strings', function test( t ) { t.end(); }); + +tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are not present on `Object.prototype`', function test( t ) { + var isEnumerableProperty; + var origPropIsEnumerable; + var origIsPrototypeOf; + var count; + var bool; + var k; + + origPropIsEnumerable = Object.prototype.propertyIsEnumerable; + origIsPrototypeOf = Object.prototype.isPrototypeOf; + + delete Object.prototype.propertyIsEnumerable; + delete Object.prototype.isPrototypeOf; + + try { + delete require.cache[ require.resolve( './../lib/native.js' ) ]; + delete require.cache[ require.resolve( './../lib/polyfill.js' ) ]; + delete require.cache[ require.resolve( './../lib/has_string_enumerability_bug.js' ) ]; + delete require.cache[ require.resolve( './../lib/main.js' ) ]; + delete require.cache[ require.resolve( './../lib' ) ]; + + isEnumerableProperty = require( './../lib' ); + + bool = isEnumerableProperty( { 'a': 'b' }, 'a' ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = isEnumerableProperty( { 'a': 'b' }, 'c' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = isEnumerableProperty( [ 1, 2, 3 ], '1' ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = isEnumerableProperty( {}, 'hasOwnProperty' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = isEnumerableProperty( null, 'beep' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = isEnumerableProperty( void 0, 'beep' ); + t.strictEqual( bool, false, 'returns expected value' ); + } finally { + if ( origPropIsEnumerable ) { + Object.defineProperty( Object.prototype, 'propertyIsEnumerable', { + 'configurable': true, + 'enumerable': false, + 'writable': true, + 'value': origPropIsEnumerable + }); + } + if ( origIsPrototypeOf ) { + Object.defineProperty( Object.prototype, 'isPrototypeOf', { + 'configurable': true, + 'enumerable': false, + 'writable': true, + 'value': origIsPrototypeOf + }); + } + delete require.cache[ require.resolve( './../lib/native.js' ) ]; + delete require.cache[ require.resolve( './../lib/polyfill.js' ) ]; + delete require.cache[ require.resolve( './../lib/has_string_enumerability_bug.js' ) ]; + delete require.cache[ require.resolve( './../lib/main.js' ) ]; + delete require.cache[ require.resolve( './../lib' ) ]; + } + + count = 0; + for ( k in {} ) { + count += 1; + } + t.strictEqual( count, 0, 'no enumerable keys on empty object' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js new file mode 100644 index 000000000000..15f0f80bf1dc --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js @@ -0,0 +1,99 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' ); +var Symbol = require( '@stdlib/symbol/ctor' ); +var polyfill = require( './../lib/polyfill.js' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasSymbolSupport() +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof polyfill, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `false` if `this` is `null` or `undefined`', function test( t ) { + t.strictEqual( polyfill.call( null, 'a' ), false, 'returns false when null' ); + t.strictEqual( polyfill.call( void 0, 'a' ), false, 'returns false when undefined' ); + t.end(); +}); + +tape( 'the function returns `true` if an object property is enumerable', function test( t ) { + var obj = { + 'a': 'b', + 'c': 1 + }; + t.strictEqual( polyfill.call( obj, 'a' ), true, 'returns expected value' ); + t.strictEqual( polyfill.call( obj, 'c' ), true, 'returns expected value' ); + t.strictEqual( polyfill.call( [ 1, 2, 3 ], '1' ), true, 'returns expected value' ); + t.strictEqual( polyfill.call( [ 1, 2, 3 ], 1 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `false` if an object property is not enumerable', function test( t ) { + var obj = { + 'a': 'b' + }; + t.strictEqual( polyfill.call( obj, 'c' ), false, 'returns expected value' ); + t.strictEqual( polyfill.call( [ 'a' ], 'length' ), false, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `false` if provided an inherited property', function test( t ) { + t.strictEqual( polyfill.call( {}, 'hasOwnProperty' ), false, 'returns expected value' ); + t.strictEqual( polyfill.call( {}, 'toString' ), false, 'returns expected value' ); + t.strictEqual( polyfill.call( {}, 'constructor' ), false, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `true` for enumerable string indices', function test( t ) { + t.strictEqual( polyfill.call( 'beep', '1' ), true, 'returns expected value' ); + t.strictEqual( polyfill.call( 'beep', 1 ), true, 'returns expected value' ); + t.strictEqual( polyfill.call( 'beep', 'length' ), false, 'returns expected value' ); + t.strictEqual( polyfill.call( 'beep', '10' ), false, 'returns expected value' ); + t.end(); +}); + +tape( 'the function coerces property values to strings', function test( t ) { + var obj = { + 'null': true, + '[object Object]': true + }; + t.strictEqual( polyfill.call( obj, null ), true, 'returns expected value' ); + t.strictEqual( polyfill.call( obj, {} ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `false` when provided a symbol', opts, function test( t ) { + t.strictEqual( polyfill.call( {}, Symbol( 'a' ) ), false, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js index 2f4ec883044c..20cd4510a015 100644 --- a/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js @@ -92,16 +92,17 @@ function isPlainObject( value ) { isFunction( proto.constructor ) && nativeClass( proto.constructor ) === '[object Function]' && - // Test for object-specific method: - hasOwnProp( proto, 'isPrototypeOf' ) && - isFunction( proto.isPrototypeOf ) && - ( // Test if the prototype matches the global `Object` prototype (same realm): proto === objectPrototype || - // Test that all properties are own properties (cross-realm; *most* likely a plain object): - ownProps( value ) + // Test that all properties are own properties and prototype has + // object-specific methods (cross-realm; *most* likely a plain object): + ( + hasOwnProp( proto, 'isPrototypeOf' ) && + isFunction( proto.isPrototypeOf ) && + ownProps( value ) + ) ) ); } diff --git a/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js b/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js index 16a602c134c8..987b58ce66ec 100644 --- a/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js @@ -193,3 +193,67 @@ tape( 'the function returns `true` if provided a value whose prototype does not t.strictEqual( isPlainObject( new Foo() ), true, 'returns expected value' ); t.end(); }); + +tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are not present on `Object.prototype`', function test( t ) { + var isPlainObject; + var origPropIsEnumerable; + var origIsPrototypeOf; + var count; + var bool; + var k; + + origPropIsEnumerable = Object.prototype.propertyIsEnumerable; + origIsPrototypeOf = Object.prototype.isPrototypeOf; + + delete Object.prototype.propertyIsEnumerable; + delete Object.prototype.isPrototypeOf; + + try { + delete require.cache[ require.resolve( './../lib/main.js' ) ]; + delete require.cache[ require.resolve( './../lib' ) ]; + + isPlainObject = require( './../lib' ); + + bool = isPlainObject( {} ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = isPlainObject( { 'a': 'b' } ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = isPlainObject( Object.create( null ) ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = isPlainObject( [] ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = isPlainObject( null ); + t.strictEqual( bool, false, 'returns expected value' ); + } finally { + if ( origPropIsEnumerable ) { + Object.defineProperty( Object.prototype, 'propertyIsEnumerable', { + 'configurable': true, + 'enumerable': false, + 'writable': true, + 'value': origPropIsEnumerable + }); + } + if ( origIsPrototypeOf ) { + Object.defineProperty( Object.prototype, 'isPrototypeOf', { + 'configurable': true, + 'enumerable': false, + 'writable': true, + 'value': origIsPrototypeOf + }); + } + delete require.cache[ require.resolve( './../lib/main.js' ) ]; + delete require.cache[ require.resolve( './../lib' ) ]; + } + + count = 0; + for ( k in {} ) { + count += 1; + } + t.strictEqual( count, 0, 'no enumerable keys on empty object' ); + + t.end(); +}); From 2d72f37969ba0711fee30c3158100492826f12f6 Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Tue, 24 Nov 2026 21:36:28 +0530 Subject: [PATCH 02/10] style: resolve lint errors --- .../is-enumerable-property/lib/polyfill.js | 6 +++++- .../assert/is-enumerable-property/test/test.js | 16 ++++++++++++---- .../is-enumerable-property/test/test.polyfill.js | 12 ++++++++++-- .../@stdlib/assert/is-plain-object/lib/main.js | 4 ++-- .../@stdlib/assert/is-plain-object/test/test.js | 14 ++++++++++---- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js index 9e4d8cf47eb5..68194159e07f 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js @@ -16,6 +16,9 @@ * limitations under the License. */ +/* eslint-disable no-invalid-this, no-restricted-syntax */ +/* eslint-disable stdlib/require-globals */ + 'use strict'; // MAIN // @@ -25,7 +28,8 @@ * * ## Notes * -* - Enumerable own symbol properties are not detected (`Object.keys` cannot see symbols). +* - Enumerable own symbol properties are not detected (`Object.keys` cannot +* see symbols). * * @private * @param {*} property - property to test diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js index ba7e78fc7e2d..0ca523d80102 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js @@ -179,10 +179,14 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no isEnumerableProperty = require( './../lib' ); - bool = isEnumerableProperty( { 'a': 'b' }, 'a' ); + bool = isEnumerableProperty({ + 'a': 'b' + }, 'a' ); t.strictEqual( bool, true, 'returns expected value' ); - bool = isEnumerableProperty( { 'a': 'b' }, 'c' ); + bool = isEnumerableProperty({ + 'a': 'b' + }, 'c' ); t.strictEqual( bool, false, 'returns expected value' ); bool = isEnumerableProperty( [ 1, 2, 3 ], '1' ); @@ -197,6 +201,7 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no bool = isEnumerableProperty( void 0, 'beep' ); t.strictEqual( bool, false, 'returns expected value' ); } finally { + /* eslint-disable no-extend-native */ if ( origPropIsEnumerable ) { Object.defineProperty( Object.prototype, 'propertyIsEnumerable', { 'configurable': true, @@ -213,6 +218,7 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no 'value': origIsPrototypeOf }); } + /* eslint-enable no-extend-native */ delete require.cache[ require.resolve( './../lib/native.js' ) ]; delete require.cache[ require.resolve( './../lib/polyfill.js' ) ]; delete require.cache[ require.resolve( './../lib/has_string_enumerability_bug.js' ) ]; @@ -221,8 +227,10 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no } count = 0; - for ( k in {} ) { - count += 1; + for ( k in {} ) { // eslint-disable-line guard-for-in + if ( k ) { + count += 1; + } } t.strictEqual( count, 0, 'no enumerable keys on empty object' ); diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js index 15f0f80bf1dc..f3c5f127e91e 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js @@ -41,11 +41,19 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +/* eslint-disable no-useless-call */ tape( 'the function returns `false` if `this` is `null` or `undefined`', function test( t ) { - t.strictEqual( polyfill.call( null, 'a' ), false, 'returns false when null' ); - t.strictEqual( polyfill.call( void 0, 'a' ), false, 'returns false when undefined' ); + var bool; + + bool = polyfill.call( null, 'a' ); + t.strictEqual( bool, false, 'returns false when null' ); + + bool = polyfill.call( void 0, 'a' ); + t.strictEqual( bool, false, 'returns false when undefined' ); + t.end(); }); +/* eslint-enable no-useless-call */ tape( 'the function returns `true` if an object property is enumerable', function test( t ) { var obj = { diff --git a/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js index 20cd4510a015..52537afb4924 100644 --- a/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js @@ -96,9 +96,9 @@ function isPlainObject( value ) { // Test if the prototype matches the global `Object` prototype (same realm): proto === objectPrototype || - // Test that all properties are own properties and prototype has - // object-specific methods (cross-realm; *most* likely a plain object): ( + // Test that all properties are own and prototype has object + // methods (cross-realm; *most* likely a plain object): hasOwnProp( proto, 'isPrototypeOf' ) && isFunction( proto.isPrototypeOf ) && ownProps( value ) diff --git a/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js b/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js index 987b58ce66ec..e424f8bafd7a 100644 --- a/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js @@ -195,9 +195,9 @@ tape( 'the function returns `true` if provided a value whose prototype does not }); tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are not present on `Object.prototype`', function test( t ) { - var isPlainObject; var origPropIsEnumerable; var origIsPrototypeOf; + var isPlainObject; var count; var bool; var k; @@ -217,7 +217,9 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no bool = isPlainObject( {} ); t.strictEqual( bool, true, 'returns expected value' ); - bool = isPlainObject( { 'a': 'b' } ); + bool = isPlainObject({ + 'a': 'b' + }); t.strictEqual( bool, true, 'returns expected value' ); bool = isPlainObject( Object.create( null ) ); @@ -229,6 +231,7 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no bool = isPlainObject( null ); t.strictEqual( bool, false, 'returns expected value' ); } finally { + /* eslint-disable no-extend-native */ if ( origPropIsEnumerable ) { Object.defineProperty( Object.prototype, 'propertyIsEnumerable', { 'configurable': true, @@ -245,13 +248,16 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no 'value': origIsPrototypeOf }); } + /* eslint-enable no-extend-native */ delete require.cache[ require.resolve( './../lib/main.js' ) ]; delete require.cache[ require.resolve( './../lib' ) ]; } count = 0; - for ( k in {} ) { - count += 1; + for ( k in {} ) { // eslint-disable-line guard-for-in + if ( k ) { + count += 1; + } } t.strictEqual( count, 0, 'no enumerable keys on empty object' ); From 59fecbbe37a08616b741a6c880ae261d8773d583 Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Tue, 24 Nov 2026 21:55:10 +0530 Subject: [PATCH 03/10] style: add empty line before eslint-enable comment in test.polyfill.js --- .../@stdlib/assert/is-enumerable-property/test/test.polyfill.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js index f3c5f127e91e..a4ae166eb945 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js @@ -53,6 +53,7 @@ tape( 'the function returns `false` if `this` is `null` or `undefined`', functio t.end(); }); + /* eslint-enable no-useless-call */ tape( 'the function returns `true` if an object property is enumerable', function test( t ) { From cc964fedc5550c85ddc1a4edb09e63637e2f7f81 Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Tue, 24 Nov 2026 22:08:33 +0530 Subject: [PATCH 04/10] style: resolve capitalized-comments and unused disable directive --- .../@stdlib/assert/is-enumerable-property/test/test.js | 2 +- lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js | 4 ++-- lib/node_modules/@stdlib/assert/is-plain-object/test/test.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js index 0ca523d80102..7a96a81e1575 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js @@ -227,7 +227,7 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no } count = 0; - for ( k in {} ) { // eslint-disable-line guard-for-in + for ( k in {} ) { if ( k ) { count += 1; } diff --git a/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js index 52537afb4924..0eae568511ab 100644 --- a/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-plain-object/lib/main.js @@ -97,8 +97,8 @@ function isPlainObject( value ) { proto === objectPrototype || ( - // Test that all properties are own and prototype has object - // methods (cross-realm; *most* likely a plain object): + // Test that all properties are own properties (cross-realm). + // Prototype must have object methods: hasOwnProp( proto, 'isPrototypeOf' ) && isFunction( proto.isPrototypeOf ) && ownProps( value ) diff --git a/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js b/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js index e424f8bafd7a..e1bd8d157e9b 100644 --- a/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js @@ -254,7 +254,7 @@ tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are no } count = 0; - for ( k in {} ) { // eslint-disable-line guard-for-in + for ( k in {} ) { if ( k ) { count += 1; } From 3ce0d88ab66b20c4fa9207a21fe2ca3e601e27b4 Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Tue, 24 Nov 2026 23:16:03 +0530 Subject: [PATCH 05/10] test: prevent shell glob expansion of pattern in benchmark bundle CLI test --- .../@stdlib/_tools/benchmarks/bundle/test/test.cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/_tools/benchmarks/bundle/test/test.cli.js b/lib/node_modules/@stdlib/_tools/benchmarks/bundle/test/test.cli.js index 991a2ae58783..2d07afffcf7a 100644 --- a/lib/node_modules/@stdlib/_tools/benchmarks/bundle/test/test.cli.js +++ b/lib/node_modules/@stdlib/_tools/benchmarks/bundle/test/test.cli.js @@ -183,7 +183,7 @@ tape( 'the command-line interface supports providing a custom glob pattern', opt fpath, join( __dirname, 'fixtures', 'main' ), '--pattern', - '*.js' + '\'*.js\'' ]; opts = { 'maxBuffer': 400*1024 From 8e21c248e7c0abb916fce568d64cb1069eff11f9 Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Tue, 24 Nov 2026 23:34:31 +0530 Subject: [PATCH 06/10] Revert "test: prevent shell glob expansion of pattern in benchmark bundle CLI test" This reverts commit 3ce0d88ab66b20c4fa9207a21fe2ca3e601e27b4. --- .../@stdlib/_tools/benchmarks/bundle/test/test.cli.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/_tools/benchmarks/bundle/test/test.cli.js b/lib/node_modules/@stdlib/_tools/benchmarks/bundle/test/test.cli.js index 2d07afffcf7a..991a2ae58783 100644 --- a/lib/node_modules/@stdlib/_tools/benchmarks/bundle/test/test.cli.js +++ b/lib/node_modules/@stdlib/_tools/benchmarks/bundle/test/test.cli.js @@ -183,7 +183,7 @@ tape( 'the command-line interface supports providing a custom glob pattern', opt fpath, join( __dirname, 'fixtures', 'main' ), '--pattern', - '\'*.js\'' + '*.js' ]; opts = { 'maxBuffer': 400*1024 From 880d94dd5250c5077dcaaf8a89bac4a4f059c546 Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Wed, 25 Nov 2026 18:01:30 +0530 Subject: [PATCH 07/10] refactor: use barrel file and proxyquire in assert packages --- .../is-enumerable-property/lib/has_builtin.js | 28 +++++ .../lib/has_string_enumerability_bug.js | 3 + .../is-enumerable-property/lib/index.js | 14 ++- .../is-enumerable-property/lib/native.js | 17 +-- .../is-enumerable-property/lib/polyfill.js | 17 +-- .../is-enumerable-property/test/test.js | 118 +++++++----------- .../test/test.polyfill.js | 93 ++++++++++---- .../assert/is-plain-object/test/test.js | 86 ++++--------- 8 files changed, 191 insertions(+), 185 deletions(-) create mode 100644 lib/node_modules/@stdlib/assert/is-enumerable-property/lib/has_builtin.js diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/has_builtin.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/has_builtin.js new file mode 100644 index 000000000000..b2637bb5c0fb --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/has_builtin.js @@ -0,0 +1,28 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +// MAIN // + +var bool = ( typeof Object.prototype.propertyIsEnumerable === 'function' ); + + +// EXPORTS // + +module.exports = bool; diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/has_string_enumerability_bug.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/has_string_enumerability_bug.js index 3dffeb602791..d998143616cc 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/has_string_enumerability_bug.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/has_string_enumerability_bug.js @@ -37,6 +37,9 @@ var bool; * @returns {boolean} boolean indicating whether an environment has the bug */ function detect() { + if ( typeof isEnum !== 'function' ) { + return false; + } return !isEnum.call( 'beep', '0' ); } diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/index.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/index.js index fdcf913a4b04..b95a7e73fe36 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/index.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/index.js @@ -39,9 +39,21 @@ // MODULES // +var HAS_BUILTIN = require( './has_builtin.js' ); +var polyfill = require( './polyfill.js' ); var main = require( './main.js' ); +// MAIN // + +var isEnumerableProperty; +if ( HAS_BUILTIN ) { + isEnumerableProperty = main; +} else { + isEnumerableProperty = polyfill; +} + + // EXPORTS // -module.exports = main; +module.exports = isEnumerableProperty; diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/native.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/native.js index 4e96f10809ca..5c4647426850 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/native.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/native.js @@ -18,16 +18,6 @@ 'use strict'; -// MODULES // - -var polyfill = require( './polyfill.js' ); - - -// VARIABLES // - -var builtin = Object.prototype.propertyIsEnumerable; - - // MAIN // /** @@ -56,12 +46,7 @@ var builtin = Object.prototype.propertyIsEnumerable; * var bool = isEnumerableProperty.call( beep, 'hasOwnProperty' ); * // returns false */ -var isEnumerableProperty; -if ( typeof builtin === 'function' ) { - isEnumerableProperty = builtin; -} else { - isEnumerableProperty = polyfill; -} +var isEnumerableProperty = Object.prototype.propertyIsEnumerable; // EXPORTS // diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js index 68194159e07f..acdacfb632be 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js @@ -16,9 +16,6 @@ * limitations under the License. */ -/* eslint-disable no-invalid-this, no-restricted-syntax */ -/* eslint-disable stdlib/require-globals */ - 'use strict'; // MAIN // @@ -32,6 +29,7 @@ * see symbols). * * @private +* @param {*} value - value to test * @param {*} property - property to test * @returns {boolean} boolean indicating if an object property is enumerable * @@ -40,7 +38,7 @@ * 'boop': true * }; * -* var bool = isEnumerableProperty.call( beep, 'boop' ); +* var bool = isEnumerableProperty( beep, 'boop' ); * // returns true * * @example @@ -48,21 +46,24 @@ * 'boop': true * }; * -* var bool = isEnumerableProperty.call( beep, 'hasOwnProperty' ); +* var bool = isEnumerableProperty( beep, 'hasOwnProperty' ); * // returns false */ -function isEnumerableProperty( property ) { +function isEnumerableProperty( value, property ) { var keys; var prop; var i; - if ( this === null || this === void 0 ) { + if ( + value === void 0 || + value === null + ) { return false; } if ( typeof property === 'symbol' ) { return false; } - keys = Object.keys( Object( this ) ); + keys = Object.keys( Object( value ) ); prop = '' + property; for ( i = 0; i < keys.length; i++ ) { if ( keys[ i ] === prop ) { diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js index 7a96a81e1575..b165731d6c2d 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js @@ -22,6 +22,8 @@ var tape = require( 'tape' ); var proxyquire = require( 'proxyquire' ); +var polyfill = require( './../lib/polyfill.js' ); +var main = require( './../lib/main.js' ); var isEnumerableProperty = require( './../lib' ); @@ -156,83 +158,49 @@ tape( 'property values are coerced to strings', function test( t ) { t.end(); }); -tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are not present on `Object.prototype`', function test( t ) { - var isEnumerableProperty; - var origPropIsEnumerable; - var origIsPrototypeOf; - var count; +tape( 'the main export is a polyfill if an environment does not support native `propertyIsEnumerable`', function test( t ) { + var isEnumerableProperty = proxyquire( './../lib', { + './has_builtin.js': false + }); + t.strictEqual( isEnumerableProperty, polyfill, 'returns expected value' ); + t.end(); +}); + +tape( 'the main export is a wrapper around a builtin if an environment supports native `propertyIsEnumerable`', function test( t ) { + var isEnumerableProperty = proxyquire( './../lib', { + './has_builtin.js': true + }); + t.strictEqual( isEnumerableProperty, main, 'returns expected value' ); + t.end(); +}); + +tape( 'the function works when native `propertyIsEnumerable` is not supported (polyfill fallback)', function test( t ) { + var isEnumerableProperty = proxyquire( './../lib', { + './has_builtin.js': false + }); var bool; - var k; - - origPropIsEnumerable = Object.prototype.propertyIsEnumerable; - origIsPrototypeOf = Object.prototype.isPrototypeOf; - - delete Object.prototype.propertyIsEnumerable; - delete Object.prototype.isPrototypeOf; - - try { - delete require.cache[ require.resolve( './../lib/native.js' ) ]; - delete require.cache[ require.resolve( './../lib/polyfill.js' ) ]; - delete require.cache[ require.resolve( './../lib/has_string_enumerability_bug.js' ) ]; - delete require.cache[ require.resolve( './../lib/main.js' ) ]; - delete require.cache[ require.resolve( './../lib' ) ]; - - isEnumerableProperty = require( './../lib' ); - - bool = isEnumerableProperty({ - 'a': 'b' - }, 'a' ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = isEnumerableProperty({ - 'a': 'b' - }, 'c' ); - t.strictEqual( bool, false, 'returns expected value' ); - - bool = isEnumerableProperty( [ 1, 2, 3 ], '1' ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = isEnumerableProperty( {}, 'hasOwnProperty' ); - t.strictEqual( bool, false, 'returns expected value' ); - - bool = isEnumerableProperty( null, 'beep' ); - t.strictEqual( bool, false, 'returns expected value' ); - - bool = isEnumerableProperty( void 0, 'beep' ); - t.strictEqual( bool, false, 'returns expected value' ); - } finally { - /* eslint-disable no-extend-native */ - if ( origPropIsEnumerable ) { - Object.defineProperty( Object.prototype, 'propertyIsEnumerable', { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': origPropIsEnumerable - }); - } - if ( origIsPrototypeOf ) { - Object.defineProperty( Object.prototype, 'isPrototypeOf', { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': origIsPrototypeOf - }); - } - /* eslint-enable no-extend-native */ - delete require.cache[ require.resolve( './../lib/native.js' ) ]; - delete require.cache[ require.resolve( './../lib/polyfill.js' ) ]; - delete require.cache[ require.resolve( './../lib/has_string_enumerability_bug.js' ) ]; - delete require.cache[ require.resolve( './../lib/main.js' ) ]; - delete require.cache[ require.resolve( './../lib' ) ]; - } - count = 0; - for ( k in {} ) { - if ( k ) { - count += 1; - } - } - t.strictEqual( count, 0, 'no enumerable keys on empty object' ); + bool = isEnumerableProperty({ + 'a': 'b' + }, 'a' ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = isEnumerableProperty({ + 'a': 'b' + }, 'c' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = isEnumerableProperty( [ 1, 2, 3 ], '1' ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = isEnumerableProperty( {}, 'hasOwnProperty' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = isEnumerableProperty( null, 'beep' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = isEnumerableProperty( void 0, 'beep' ); + t.strictEqual( bool, false, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js index a4ae166eb945..4381fe8166e5 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js @@ -41,68 +41,111 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -/* eslint-disable no-useless-call */ -tape( 'the function returns `false` if `this` is `null` or `undefined`', function test( t ) { +tape( 'the function returns `false` if provided `null` or `undefined`', function test( t ) { var bool; - bool = polyfill.call( null, 'a' ); + bool = polyfill( null, 'a' ); t.strictEqual( bool, false, 'returns false when null' ); - bool = polyfill.call( void 0, 'a' ); + bool = polyfill( void 0, 'a' ); t.strictEqual( bool, false, 'returns false when undefined' ); t.end(); }); -/* eslint-enable no-useless-call */ - tape( 'the function returns `true` if an object property is enumerable', function test( t ) { - var obj = { + var bool; + var obj; + + obj = { 'a': 'b', 'c': 1 }; - t.strictEqual( polyfill.call( obj, 'a' ), true, 'returns expected value' ); - t.strictEqual( polyfill.call( obj, 'c' ), true, 'returns expected value' ); - t.strictEqual( polyfill.call( [ 1, 2, 3 ], '1' ), true, 'returns expected value' ); - t.strictEqual( polyfill.call( [ 1, 2, 3 ], 1 ), true, 'returns expected value' ); + bool = polyfill( obj, 'a' ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = polyfill( obj, 'c' ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = polyfill( [ 1, 2, 3 ], '1' ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = polyfill( [ 1, 2, 3 ], 1 ); + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); }); tape( 'the function returns `false` if an object property is not enumerable', function test( t ) { - var obj = { + var bool; + var obj; + + obj = { 'a': 'b' }; - t.strictEqual( polyfill.call( obj, 'c' ), false, 'returns expected value' ); - t.strictEqual( polyfill.call( [ 'a' ], 'length' ), false, 'returns expected value' ); + bool = polyfill( obj, 'c' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = polyfill( [ 'a' ], 'length' ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); }); tape( 'the function returns `false` if provided an inherited property', function test( t ) { - t.strictEqual( polyfill.call( {}, 'hasOwnProperty' ), false, 'returns expected value' ); - t.strictEqual( polyfill.call( {}, 'toString' ), false, 'returns expected value' ); - t.strictEqual( polyfill.call( {}, 'constructor' ), false, 'returns expected value' ); + var bool; + + bool = polyfill( {}, 'hasOwnProperty' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = polyfill( {}, 'toString' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = polyfill( {}, 'constructor' ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); }); tape( 'the function returns `true` for enumerable string indices', function test( t ) { - t.strictEqual( polyfill.call( 'beep', '1' ), true, 'returns expected value' ); - t.strictEqual( polyfill.call( 'beep', 1 ), true, 'returns expected value' ); - t.strictEqual( polyfill.call( 'beep', 'length' ), false, 'returns expected value' ); - t.strictEqual( polyfill.call( 'beep', '10' ), false, 'returns expected value' ); + var bool; + + bool = polyfill( 'beep', '1' ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = polyfill( 'beep', 1 ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = polyfill( 'beep', 'length' ); + t.strictEqual( bool, false, 'returns expected value' ); + + bool = polyfill( 'beep', '10' ); + t.strictEqual( bool, false, 'returns expected value' ); + t.end(); }); tape( 'the function coerces property values to strings', function test( t ) { - var obj = { + var bool; + var obj; + + obj = { 'null': true, '[object Object]': true }; - t.strictEqual( polyfill.call( obj, null ), true, 'returns expected value' ); - t.strictEqual( polyfill.call( obj, {} ), true, 'returns expected value' ); + bool = polyfill( obj, null ); + t.strictEqual( bool, true, 'returns expected value' ); + + bool = polyfill( obj, {} ); + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); }); tape( 'the function returns `false` when provided a symbol', opts, function test( t ) { - t.strictEqual( polyfill.call( {}, Symbol( 'a' ) ), false, 'returns expected value' ); + var bool; + + bool = polyfill( {}, Symbol( 'a' ) ); + t.strictEqual( bool, false, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js b/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js index e1bd8d157e9b..28c6e64e11de 100644 --- a/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-plain-object/test/test.js @@ -194,72 +194,38 @@ tape( 'the function returns `true` if provided a value whose prototype does not t.end(); }); -tape( 'the function works when `propertyIsEnumerable` and `isPrototypeOf` are not present on `Object.prototype`', function test( t ) { - var origPropIsEnumerable; - var origIsPrototypeOf; - var isPlainObject; - var count; - var bool; - var k; - - origPropIsEnumerable = Object.prototype.propertyIsEnumerable; - origIsPrototypeOf = Object.prototype.isPrototypeOf; - - delete Object.prototype.propertyIsEnumerable; - delete Object.prototype.isPrototypeOf; - - try { - delete require.cache[ require.resolve( './../lib/main.js' ) ]; - delete require.cache[ require.resolve( './../lib' ) ]; - - isPlainObject = require( './../lib' ); - - bool = isPlainObject( {} ); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = isPlainObject({ - 'a': 'b' - }); - t.strictEqual( bool, true, 'returns expected value' ); - - bool = isPlainObject( Object.create( null ) ); - t.strictEqual( bool, true, 'returns expected value' ); +tape( 'the function returns `true` if provided a plain object in the same realm even when `isPrototypeOf` is missing', function test( t ) { + var isPlainObject = proxyquire( './../lib/main.js', { + '@stdlib/assert/has-own-property': hasOwnProp + }); - bool = isPlainObject( [] ); - t.strictEqual( bool, false, 'returns expected value' ); + t.strictEqual( isPlainObject( {} ), true, 'returns expected value' ); + t.strictEqual( isPlainObject({ + 'a': 'b' + }), true, 'returns expected value' ); + t.end(); - bool = isPlainObject( null ); - t.strictEqual( bool, false, 'returns expected value' ); - } finally { - /* eslint-disable no-extend-native */ - if ( origPropIsEnumerable ) { - Object.defineProperty( Object.prototype, 'propertyIsEnumerable', { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': origPropIsEnumerable - }); - } - if ( origIsPrototypeOf ) { - Object.defineProperty( Object.prototype, 'isPrototypeOf', { - 'configurable': true, - 'enumerable': false, - 'writable': true, - 'value': origIsPrototypeOf - }); + function hasOwnProp( obj, prop ) { + if ( prop === 'isPrototypeOf' ) { + return false; } - /* eslint-enable no-extend-native */ - delete require.cache[ require.resolve( './../lib/main.js' ) ]; - delete require.cache[ require.resolve( './../lib' ) ]; + return Object.prototype.hasOwnProperty.call( obj, prop ); } +}); - count = 0; - for ( k in {} ) { - if ( k ) { - count += 1; - } +tape( 'the function returns `false` if provided a value whose prototype does not equal the global `Object` prototype and lacks `isPrototypeOf` (cross-realm)', function test( t ) { + function Foo() { + this.foo = 'bar'; + return this; } - t.strictEqual( count, 0, 'no enumerable keys on empty object' ); + Foo.prototype = Object.create( Object.prototype ); + defineProperty( Foo.prototype, 'constructor', { + 'configurable': true, + 'enumerable': false, + 'value': Foo + }); + + t.strictEqual( isPlainObject( new Foo() ), false, 'returns expected value' ); t.end(); }); From 16904b94283f36f28bb7d878607bc6460feac36e Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Wed, 25 Nov 2026 18:11:19 +0530 Subject: [PATCH 08/10] style: disable no-restricted-syntax and require-globals in polyfill --- .../@stdlib/assert/is-enumerable-property/lib/polyfill.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js index acdacfb632be..c0725a77cedf 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable no-restricted-syntax, stdlib/require-globals */ + 'use strict'; // MAIN // From 1b8063c4d718c7224f634e751ce5cf1bd3ff960d Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Sat, 28 Nov 2026 08:49:50 +0530 Subject: [PATCH 09/10] refactor: use cached Object.keys and String conversion in polyfill --- .../is-enumerable-property/lib/polyfill.js | 18 ++++++++++++++---- .../assert/is-enumerable-property/test/test.js | 8 ++++++++ .../test/test.polyfill.js | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js index c0725a77cedf..c5d260af95e2 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js @@ -16,10 +16,20 @@ * limitations under the License. */ -/* eslint-disable no-restricted-syntax, stdlib/require-globals */ - 'use strict'; +// MODULES // + +var Object = require( '@stdlib/object/ctor' ); + + +// VARIABLES // + +// NOTE: we explicitly avoid using `@stdlib/utils/keys` in order to avoid +// circular dependencies, as that package depends on this one. +var objectKeys = Object.keys; + + // MAIN // /** @@ -65,8 +75,8 @@ function isEnumerableProperty( value, property ) { if ( typeof property === 'symbol' ) { return false; } - keys = Object.keys( Object( value ) ); - prop = '' + property; + keys = objectKeys( Object( value ) ); + prop = String( property ); for ( i = 0; i < keys.length; i++ ) { if ( keys[ i ] === prop ) { return true; diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js index b165731d6c2d..ac8772feaa36 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js @@ -204,3 +204,11 @@ tape( 'the function works when native `propertyIsEnumerable` is not supported (p t.end(); }); + +tape( 'the string enumerability bug check safely returns `false` if native method is not a function', function test( t ) { + var hasBug = proxyquire( './../lib/has_string_enumerability_bug.js', { + './native.js': null + }); + t.strictEqual( hasBug, false, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js index 4381fe8166e5..9c4c5d84b94c 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.polyfill.js @@ -127,6 +127,7 @@ tape( 'the function returns `true` for enumerable string indices', function test tape( 'the function coerces property values to strings', function test( t ) { var bool; + var prop; var obj; obj = { @@ -139,6 +140,21 @@ tape( 'the function coerces property values to strings', function test( t ) { bool = polyfill( obj, {} ); t.strictEqual( bool, true, 'returns expected value' ); + prop = { + 'toString': function toString() { + return 'foo'; + }, + 'valueOf': function valueOf() { + return 'bar'; + } + }; + obj = { + 'foo': true, + 'bar': false + }; + bool = polyfill( obj, prop ); + t.strictEqual( bool, true, 'returns expected value' ); + t.end(); }); From 3d4926e4b78b454fa1fbc498c29697a2213dd6aa Mon Sep 17 00:00:00 2001 From: Abir Maity Date: Sat, 28 Nov 2026 09:05:40 +0530 Subject: [PATCH 10/10] style: fix comment formatting and remove invalid proxyquire stub --- .../@stdlib/assert/is-enumerable-property/lib/polyfill.js | 3 +-- .../@stdlib/assert/is-enumerable-property/test/test.js | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js index c5d260af95e2..554f027fa927 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/lib/polyfill.js @@ -25,8 +25,7 @@ var Object = require( '@stdlib/object/ctor' ); // VARIABLES // -// NOTE: we explicitly avoid using `@stdlib/utils/keys` in order to avoid -// circular dependencies, as that package depends on this one. +// NOTE: we explicitly avoid using `@stdlib/utils/keys` in order to avoid circular dependencies, as that package depends on this one. var objectKeys = Object.keys; diff --git a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js index ac8772feaa36..b165731d6c2d 100644 --- a/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js +++ b/lib/node_modules/@stdlib/assert/is-enumerable-property/test/test.js @@ -204,11 +204,3 @@ tape( 'the function works when native `propertyIsEnumerable` is not supported (p t.end(); }); - -tape( 'the string enumerability bug check safely returns `false` if native method is not a function', function test( t ) { - var hasBug = proxyquire( './../lib/has_string_enumerability_bug.js', { - './native.js': null - }); - t.strictEqual( hasBug, false, 'returns expected value' ); - t.end(); -});