@stdlib/assert-is-nonenumerable-property

Test if an object's own property is non-enumerable.

Usage no npm install needed!

<script type="module">
  import stdlibAssertIsNonenumerableProperty from 'https://cdn.skypack.dev/@stdlib/assert-is-nonenumerable-property';
</script>

README

isNonEnumerableProperty

NPM version Build Status Coverage Status

Test if an object's own property is non-enumerable.

Installation

npm install @stdlib/assert-is-nonenumerable-property

Usage

var isNonEnumerableProperty = require( '@stdlib/assert-is-nonenumerable-property' );

isNonEnumerableProperty( value, property )

Returns a boolean indicating if a value has a non-enumerable property.

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

var obj = {
    'foo': 'bar'
};

defineProperty( obj, 'beep', {
    'configurable': false,
    'enumerable': false,
    'writable': true,
    'value': 'boop'
});

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

bool = isNonEnumerableProperty( obj, 'foo' );
// returns false

Notes

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

    var bool = isNonEnumerableProperty( 'beep', 'length' );
    // returns true
    

Examples

var isNonEnumerableProperty = require( '@stdlib/assert-is-nonenumerable-property' );

var bool = isNonEnumerableProperty( [ 'a' ], 'length' );
// returns true

bool = isNonEnumerableProperty( { 'a': 'b' }, 'a' );
// returns false

bool = isNonEnumerableProperty( [ 'a' ], 0 );
// returns false

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

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

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

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

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

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

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2022. The Stdlib Authors.