time-to-botec

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

README.md (2196B)


      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 # Non-Enumerable Write-Only Accessor
     22 
     23 > [Define][@stdlib/utils/define-property] a non-enumerable **write-only** accessor.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 <!-- eslint-disable id-length -->
     30 
     31 ```javascript
     32 var setNonEnumerableWriteOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-write-only-accessor' );
     33 ```
     34 
     35 #### setNonEnumerableWriteOnlyAccessor( obj, prop, setter )
     36 
     37 [Defines][@stdlib/utils/define-property] a non-enumerable **write-only** accessor.
     38 
     39 <!-- eslint-disable id-length -->
     40 
     41 ```javascript
     42 var obj = {};
     43 var val = '';
     44 
     45 function setter( v ) {
     46     val = v;
     47 }
     48 
     49 setNonEnumerableWriteOnlyAccessor( obj, 'foo', setter );
     50 
     51 obj.foo = 'boop';
     52 
     53 var bool = ( val === 'boop' );
     54 // returns true
     55 ```
     56 
     57 </section>
     58 
     59 <!-- /.usage -->
     60 
     61 <section class="notes">
     62     
     63 ## Notes
     64 
     65 -   Non-enumerable write-only accessors are **non-configurable**.
     66 
     67 </section>
     68 
     69 <!-- /.notes -->
     70 
     71 <section class="examples">
     72 
     73 ## Examples
     74 
     75 <!-- eslint-disable id-length -->
     76 
     77 <!-- eslint no-undef: "error" -->
     78 
     79 ```javascript
     80 var setNonEnumerableWriteOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-write-only-accessor' );
     81 
     82 function Foo( secret ) {
     83     if ( !(this instanceof Foo) ) {
     84         return new Foo( secret );
     85     }
     86     setNonEnumerableWriteOnlyAccessor( this, 'secret', setter );
     87     return this;
     88 
     89     function setter( v ) {
     90         secret = v;
     91     }
     92 }
     93 
     94 var foo = new Foo( 'beep' );
     95 
     96 foo.secret = 'boop';
     97 ```
     98 
     99 </section>
    100 
    101 <!-- /.examples -->
    102 
    103 <section class="links">
    104 
    105 [@stdlib/utils/define-property]: https://www.npmjs.com/package/@stdlib/utils/tree/main/define-property
    106 
    107 </section>
    108 
    109 <!-- /.links -->