time-to-botec

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

README.md (2304B)


      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 # propertyDescriptorIn
     22 
     23 > Return a property descriptor for an object's own or inherited property.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var propertyDescriptorIn = require( '@stdlib/utils/property-descriptor-in' );
     31 ```
     32 
     33 #### propertyDescriptorIn( obj, property )
     34 
     35 Returns a property descriptor for an object's own or inherited property.
     36 
     37 ```javascript
     38 var obj = {
     39     'a': 1,
     40     'b': 2
     41 };
     42 
     43 var desc = propertyDescriptorIn( obj, 'a' );
     44 // returns {'configurable':true,'enumerable':true,'writable':true,'value':1}
     45 ```
     46 
     47 </section>
     48 
     49 <!-- /.usage -->
     50 
     51 <section class="notes">
     52 
     53 ## Notes
     54 
     55 -   This function differs from the built-in `Object.getOwnPropertyDescriptor()` as follows:
     56 
     57     -   If provided `null` or `undefined`, the function returns `null`, rather than throwing an error.
     58     -   If an object does not have a provided property, the function returns `null`, rather than `undefined`.
     59 
     60 </section>
     61 
     62 <!-- /.notes -->
     63 
     64 <section class="examples">
     65 
     66 ## Examples
     67 
     68 <!-- eslint no-undef: "error" -->
     69 
     70 ```javascript
     71 var defineProperty = require( '@stdlib/utils/define-property' );
     72 var propertyDescriptorIn = require( '@stdlib/utils/property-descriptor-in' );
     73 
     74 function Foo() {
     75     this.beep = 'boop';
     76     this.a = {
     77         'b': 'c'
     78     };
     79     defineProperty( this, 'baz', {
     80         'value': 'qux',
     81         'configurable': true,
     82         'writable': true,
     83         'enumerable': false
     84     });
     85     return this;
     86 }
     87 
     88 Foo.prototype.foo = [ 'bar' ];
     89 
     90 var obj = new Foo();
     91 var desc = propertyDescriptorIn( obj, 'foo' );
     92 
     93 console.log( desc );
     94 // => {'configurable':true,'enumerable':true,'writable':true,'value':['bar']}
     95 ```
     96 
     97 </section>
     98 
     99 <!-- /.examples -->
    100 
    101 <section class="links">
    102 
    103 </section>
    104 
    105 <!-- /.links -->