time-to-botec

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

README.md (3388B)


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