time-to-botec/squiggle/node_modules/@stdlib/assert/is-enumerable-property-in
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

isEnumerablePropertyIn

Test if an object's own or inherited property is enumerable.

Usage

var isEnumerablePropertyIn = require( '@stdlib/assert/is-enumerable-property-in' );

isEnumerablePropertyIn( value, property )

Returns a boolean indicating if a value has an enumerable property.

var defineProperty = require( '@stdlib/utils/define-property' );

var bool;
var obj;

function Foo() {
    this.foo = 'bar';
    return this;
}

defineProperty( Foo.prototype, 'beep', {
    'configurable': true,
    'enumerable': true,
    'writable': true,
    'value': true
});

defineProperty( Foo.prototype, 'boop', {
    'configurable': true,
    'enumerable': false,
    'writable': true,
    'value': true
});

obj = new Foo();

bool = isEnumerablePropertyIn( obj, 'foo' );
// returns true

bool = isEnumerablePropertyIn( obj, 'beep' );
// returns true

bool = isEnumerablePropertyIn( obj, 'boop' );
// returns false

Notes

  • Value arguments other than null or undefined are coerced to objects.

    var bool = isEnumerablePropertyIn( 'beep', 'toString' );
    // returns false
    
  • Property arguments are coerced to strings.

    var obj = {
        'null': 'foo'
    };
    
    var bool = isEnumerablePropertyIn( obj, null );
    // returns true
    

Examples

var isEnumerablePropertyIn = require( '@stdlib/assert/is-enumerable-property-in' );

var bool = isEnumerablePropertyIn( { 'a': 'b' }, 'a' );
// returns true

bool = isEnumerablePropertyIn( [ 'a' ], 0 );
// returns true

bool = isEnumerablePropertyIn( { 'null': false }, null );
// returns true

bool = isEnumerablePropertyIn( { '[object Object]': false }, {} );
// returns true

bool = isEnumerablePropertyIn( {}, 'toString' );
// returns false

bool = isEnumerablePropertyIn( {}, 'hasOwnProperty' );
// returns false

bool = isEnumerablePropertyIn( [ 'a' ], 'length' );
// returns false

bool = isEnumerablePropertyIn( null, 'a' );
// returns false

bool = isEnumerablePropertyIn( void 0, 'a' );
// returns false