time-to-botec

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

README.md (2928B)


      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 # writablePropertySymbolsIn
     22 
     23 > Return an array of an object's own and inherited writable symbol properties.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var writablePropertySymbolsIn = require( '@stdlib/utils/writable-property-symbols-in' );
     31 ```
     32 
     33 #### writablePropertySymbolsIn( obj )
     34 
     35 Returns an `array` of an object's own and inherited writable symbol properties.
     36 
     37 ```javascript
     38 var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
     39 var Symbol = require( '@stdlib/symbol/ctor' );
     40 var defineProperty = require( '@stdlib/utils/define-property' );
     41 
     42 var obj = {};
     43 
     44 if ( hasSymbolSupport() ) {
     45     defineProperty( obj, Symbol( 'a' ), {
     46         'configurable': false,
     47         'enumerable': false,
     48         'writable': true,
     49         'value': 'b'
     50     });
     51 }
     52 
     53 var symbols = writablePropertySymbolsIn( obj );
     54 ```
     55 
     56 </section>
     57 
     58 <!-- /.usage -->
     59 
     60 <section class="notes">
     61 
     62 ## Notes
     63 
     64 -   Property order is not guaranteed, as `object` property enumeration is not specified according to the [ECMAScript specification][ecma-262-for-in]. In practice, however, most engines use insertion order to sort an `object`'s properties, thus allowing for deterministic extraction.
     65 
     66 </section>
     67 
     68 <!-- /.notes -->
     69 
     70 <section class="examples">
     71 
     72 ## Examples
     73 
     74 <!-- eslint no-undef: "error" -->
     75 
     76 ```javascript
     77 var defineProperty = require( '@stdlib/utils/define-property' );
     78 var hasSymbolSupport = require( '@stdlib/assert/has-symbol-support' );
     79 var Symbol = require( '@stdlib/symbol/ctor' );
     80 var writablePropertySymbolsIn = require( '@stdlib/utils/writable-property-symbols-in' );
     81 
     82 var hasSymbols = hasSymbolSupport();
     83 var symbols;
     84 var obj;
     85 
     86 function Foo() {
     87     if ( hasSymbols ) {
     88         defineProperty( this, Symbol( 'baz' ), {
     89             'configurable': false,
     90             'enumerable': false,
     91             'writable': true,
     92             'value': 'qux'
     93         });
     94     }
     95     return this;
     96 }
     97 
     98 if ( hasSymbols ) {
     99     defineProperty( Foo.prototype, Symbol( 'bip' ), {
    100         'configurable': false,
    101         'enumerable': false,
    102         'writable': true,
    103         'value': 'bop'
    104     });
    105 }
    106 
    107 obj = new Foo();
    108 symbols = writablePropertySymbolsIn( obj );
    109 
    110 console.log( symbols );
    111 ```
    112 
    113 </section>
    114 
    115 <!-- /.examples -->
    116 
    117 <section class="links">
    118 
    119 [ecma-262-for-in]: http://www.ecma-international.org/ecma-262/5.1/#sec-12.6.4
    120 
    121 </section>
    122 
    123 <!-- /.links -->