Nominating Presidential Muppets

    @stdlib/assert-is-nonconfigurable-property
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.7 • Public • Published

    isNonConfigurableProperty

    NPM version Build Status Coverage Status

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

    Installation

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

    Usage

    var isNonConfigurableProperty = require( '@stdlib/assert-is-nonconfigurable-property' );

    isNonConfigurableProperty( value, property )

    Returns a boolean indicating if a value has a non-configurable property (i.e., a property which cannot be deleted and whose descriptor cannot be changed).

    var defineProperty = require( '@stdlib/utils-define-property' );
    
    var obj = {
        'foo': 'bar'
    };
    
    defineProperty( obj, 'beep', {
        'configurable': false,
        'enumerable': true,
        'writable': true,
        'value': 'boop'
    });
    
    var bool = isNonConfigurableProperty( obj, 'beep' );
    // returns true
    
    bool = isNonConfigurableProperty( obj, 'foo' );
    // returns false

    Notes

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

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

    Examples

    var isNonConfigurableProperty = require( '@stdlib/assert-is-nonconfigurable-property' );
    
    var bool = isNonConfigurableProperty( [ 'a' ], 'length' );
    // returns true
    
    bool = isNonConfigurableProperty( { 'a': 'b' }, 'a' );
    // returns false
    
    bool = isNonConfigurableProperty( [ 'a' ], 0 );
    // returns false
    
    bool = isNonConfigurableProperty( {}, 'toString' );
    // returns false
    
    bool = isNonConfigurableProperty( {}, 'hasOwnProperty' );
    // returns false
    
    bool = isNonConfigurableProperty( null, 'a' );
    // returns false
    
    bool = isNonConfigurableProperty( void 0, 'a' );
    // returns false
    
    bool = isNonConfigurableProperty( { 'null': false }, null );
    // returns false
    
    bool = isNonConfigurableProperty( { '[object Object]': false }, {} );
    // returns false

    See Also


    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.

    Install

    npm i @stdlib/assert-is-nonconfigurable-property

    Homepage

    stdlib.io

    DownloadsWeekly Downloads

    27

    Version

    0.0.7

    License

    Apache-2.0

    Unpacked Size

    40.4 kB

    Total Files

    9

    Last publish

    Collaborators

    • stdlib-bot
    • kgryte
    • planeshifter
    • rreusser