time-to-botec

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

README.md (3502B)


      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 # isNonConfigurablePropertyIn
     22 
     23 > Test if an object's own or inherited property is non-configurable.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 <!-- eslint-disable id-length -->
     30 
     31 ```javascript
     32 var isNonConfigurablePropertyIn = require( '@stdlib/assert/is-nonconfigurable-property-in' );
     33 ```
     34 
     35 #### isNonConfigurablePropertyIn( value, property )
     36 
     37 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).
     38 
     39 <!-- eslint-disable no-restricted-syntax -->
     40 
     41 ```javascript
     42 var defineProperty = require( '@stdlib/utils/define-property' );
     43 
     44 var bool;
     45 var obj;
     46 
     47 function Foo() {
     48     this.foo = 'bar';
     49     return this;
     50 }
     51 
     52 defineProperty( Foo.prototype, 'beep', {
     53     'configurable': true,
     54     'enumerable': true,
     55     'writable': true,
     56     'value': true
     57 });
     58 
     59 defineProperty( Foo.prototype, 'boop', {
     60     'configurable': false,
     61     'enumerable': true,
     62     'writable': true,
     63     'value': true
     64 });
     65 
     66 obj = new Foo();
     67 
     68 bool = isNonConfigurablePropertyIn( obj, 'foo' );
     69 // returns false
     70 
     71 bool = isNonConfigurablePropertyIn( obj, 'beep' );
     72 // returns false
     73 
     74 bool = isNonConfigurablePropertyIn( obj, 'boop' );
     75 // returns true
     76 ```
     77 
     78 </section>
     79 
     80 <!-- /.usage -->
     81 
     82 <section class="notes">
     83 
     84 ## Notes
     85 
     86 -   Value arguments other than `null` or `undefined` are coerced to `objects`.
     87 
     88     ```javascript
     89     var bool = isNonConfigurablePropertyIn( 'beep', 'length' );
     90     // returns true
     91     ```
     92 
     93 -   Non-symbol property arguments are coerced to `strings`.
     94 
     95     ```javascript
     96     var defineProperty = require( '@stdlib/utils/define-property' );
     97 
     98     var obj = {};
     99 
    100     defineProperty( obj, 'null', {
    101         'configurable': false,
    102         'enumerable': true,
    103         'writable': true,
    104         'value': true
    105     });
    106 
    107     var bool = isNonConfigurablePropertyIn( obj, null );
    108     // returns true
    109     ```
    110 
    111 </section>
    112 
    113 <!-- /.notes -->
    114 
    115 <section class="examples">
    116 
    117 ## Examples
    118 
    119 <!-- eslint-disable object-curly-newline, id-length -->
    120 
    121 <!-- eslint no-undef: "error" -->
    122 
    123 ```javascript
    124 var isNonConfigurablePropertyIn = require( '@stdlib/assert/is-nonconfigurable-property-in' );
    125 
    126 var bool = isNonConfigurablePropertyIn( [ 'a' ], 'length' );
    127 // returns true
    128 
    129 bool = isNonConfigurablePropertyIn( {}, 'toString' );
    130 // returns false
    131 
    132 bool = isNonConfigurablePropertyIn( {}, 'hasOwnProperty' );
    133 // returns false
    134 
    135 bool = isNonConfigurablePropertyIn( { 'a': 'b' }, 'a' );
    136 // returns false
    137 
    138 bool = isNonConfigurablePropertyIn( [ 'a' ], 0 );
    139 // returns false
    140 
    141 bool = isNonConfigurablePropertyIn( { 'null': false }, null );
    142 // returns false
    143 
    144 bool = isNonConfigurablePropertyIn( { '[object Object]': false }, {} );
    145 // returns false
    146 
    147 bool = isNonConfigurablePropertyIn( null, 'a' );
    148 // returns false
    149 
    150 bool = isNonConfigurablePropertyIn( void 0, 'a' );
    151 // returns false
    152 ```
    153 
    154 </section>
    155 
    156 <!-- /.examples -->
    157 
    158 <section class="links">
    159 
    160 </section>
    161 
    162 <!-- /.links -->