time-to-botec

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

README.md (3057B)


      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 # isEnumerablePropertyIn
     22 
     23 > Test if an object's own or inherited property is enumerable.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isEnumerablePropertyIn = require( '@stdlib/assert/is-enumerable-property-in' );
     31 ```
     32 
     33 #### isEnumerablePropertyIn( value, property )
     34 
     35 Returns a `boolean` indicating if a `value` has an 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 = isEnumerablePropertyIn( obj, 'foo' );
     67 // returns true
     68 
     69 bool = isEnumerablePropertyIn( obj, 'beep' );
     70 // returns true
     71 
     72 bool = isEnumerablePropertyIn( obj, 'boop' );
     73 // returns false
     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 = isEnumerablePropertyIn( 'beep', 'toString' );
     88     // returns false
     89     ```
     90 
     91 -   Property arguments are coerced to `strings`.
     92 
     93     ```javascript
     94     var obj = {
     95         'null': 'foo'
     96     };
     97 
     98     var bool = isEnumerablePropertyIn( obj, null );
     99     // returns true
    100     ```
    101 
    102 </section>
    103 
    104 <!-- /.notes -->
    105 
    106 <section class="examples">
    107 
    108 ## Examples
    109 
    110 <!-- eslint-disable object-curly-newline -->
    111 
    112 <!-- eslint no-undef: "error" -->
    113 
    114 ```javascript
    115 var isEnumerablePropertyIn = require( '@stdlib/assert/is-enumerable-property-in' );
    116 
    117 var bool = isEnumerablePropertyIn( { 'a': 'b' }, 'a' );
    118 // returns true
    119 
    120 bool = isEnumerablePropertyIn( [ 'a' ], 0 );
    121 // returns true
    122 
    123 bool = isEnumerablePropertyIn( { 'null': false }, null );
    124 // returns true
    125 
    126 bool = isEnumerablePropertyIn( { '[object Object]': false }, {} );
    127 // returns true
    128 
    129 bool = isEnumerablePropertyIn( {}, 'toString' );
    130 // returns false
    131 
    132 bool = isEnumerablePropertyIn( {}, 'hasOwnProperty' );
    133 // returns false
    134 
    135 bool = isEnumerablePropertyIn( [ 'a' ], 'length' );
    136 // returns false
    137 
    138 bool = isEnumerablePropertyIn( null, 'a' );
    139 // returns false
    140 
    141 bool = isEnumerablePropertyIn( void 0, 'a' );
    142 // returns false
    143 ```
    144 
    145 </section>
    146 
    147 <!-- /.examples -->
    148 
    149 <section class="links">
    150 
    151 </section>
    152 
    153 <!-- /.links -->