time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (2681B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # isNonConfigurableProperty
     22 
     23 > Test if an object's own property is non-configurable.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isNonConfigurableProperty = require( '@stdlib/assert/is-nonconfigurable-property' );
     31 ```
     32 
     33 #### isNonConfigurableProperty( value, property )
     34 
     35 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).
     36 
     37 ```javascript
     38 var defineProperty = require( '@stdlib/utils/define-property' );
     39 
     40 var obj = {
     41     'foo': 'bar'
     42 };
     43 
     44 defineProperty( obj, 'beep', {
     45     'configurable': false,
     46     'enumerable': true,
     47     'writable': true,
     48     'value': 'boop'
     49 });
     50 
     51 var bool = isNonConfigurableProperty( obj, 'beep' );
     52 // returns true
     53 
     54 bool = isNonConfigurableProperty( obj, 'foo' );
     55 // returns false
     56 ```
     57 
     58 </section>
     59 
     60 <!-- /.usage -->
     61 
     62 <section class="notes">
     63 
     64 ## Notes
     65 
     66 -   Value arguments other than `null` or `undefined` are coerced to `objects`.
     67 
     68     ```javascript
     69     var bool = isNonConfigurableProperty( 'beep', 'length' );
     70     // returns true
     71     ```
     72 
     73 </section>
     74 
     75 <!-- /.notes -->
     76 
     77 <section class="examples">
     78 
     79 ## Examples
     80 
     81 <!-- eslint-disable object-curly-newline -->
     82 
     83 <!-- eslint no-undef: "error" -->
     84 
     85 ```javascript
     86 var isNonConfigurableProperty = require( '@stdlib/assert/is-nonconfigurable-property' );
     87 
     88 var bool = isNonConfigurableProperty( [ 'a' ], 'length' );
     89 // returns true
     90 
     91 bool = isNonConfigurableProperty( { 'a': 'b' }, 'a' );
     92 // returns false
     93 
     94 bool = isNonConfigurableProperty( [ 'a' ], 0 );
     95 // returns false
     96 
     97 bool = isNonConfigurableProperty( {}, 'toString' );
     98 // returns false
     99 
    100 bool = isNonConfigurableProperty( {}, 'hasOwnProperty' );
    101 // returns false
    102 
    103 bool = isNonConfigurableProperty( null, 'a' );
    104 // returns false
    105 
    106 bool = isNonConfigurableProperty( void 0, 'a' );
    107 // returns false
    108 
    109 bool = isNonConfigurableProperty( { 'null': false }, null );
    110 // returns false
    111 
    112 bool = isNonConfigurableProperty( { '[object Object]': false }, {} );
    113 // returns false
    114 ```
    115 
    116 </section>
    117 
    118 <!-- /.examples -->
    119 
    120 <section class="links">
    121 
    122 </section>
    123 
    124 <!-- /.links -->