time-to-botec

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

README.md (3328B)


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