time-to-botec

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

README.md (2878B)


      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 # Reviver
     22 
     23 > Revive a JSON-serialized 64-bit [complex number][@stdlib/complex/float32].
     24 
     25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
     26 
     27 <section class="intro">
     28 
     29 </section>
     30 
     31 <!-- /.intro -->
     32 
     33 <!-- Package usage documentation. -->
     34 
     35 <section class="usage">
     36 
     37 ## Usage
     38 
     39 ```javascript
     40 var reviver = require( '@stdlib/complex/reviver-float32' );
     41 ```
     42 
     43 #### reviver( key, value )
     44 
     45 Revives a JSON-serialized 64-bit [complex number][@stdlib/complex/float32].
     46 
     47 ```javascript
     48 var parseJSON = require( '@stdlib/utils/parse-json' );
     49 
     50 var str = '{"type":"Complex64","re":5,"im":3}';
     51 
     52 var z = parseJSON( str, reviver );
     53 // returns <Complex64>
     54 ```
     55 
     56 For details on the JSON serialization format, see [`Complex64`][@stdlib/complex/float32].
     57 
     58 </section>
     59 
     60 <!-- /.usage -->
     61 
     62 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     63 
     64 <section class="notes">
     65 
     66 </section>
     67 
     68 <!-- /.notes -->
     69 
     70 <!-- Package usage examples. -->
     71 
     72 <section class="examples">
     73 
     74 ## Examples
     75 
     76 <!-- eslint no-undef: "error" -->
     77 
     78 ```javascript
     79 var Complex64 = require( '@stdlib/complex/float32' );
     80 var parseJSON = require( '@stdlib/utils/parse-json' );
     81 var reviver = require( '@stdlib/complex/reviver-float32' );
     82 
     83 var z = new Complex64( 5.0, 3.0 );
     84 var str = JSON.stringify( z );
     85 // returns '{"type":"Complex64","re":5,"im":3}'
     86 
     87 var w = parseJSON( str, reviver );
     88 if ( w instanceof Error ) {
     89     throw w;
     90 }
     91 var bool = ( w instanceof z.constructor );
     92 // returns true
     93 
     94 bool = ( w.re === z.re );
     95 // returns true
     96 
     97 bool = ( w.im === z.im );
     98 // returns true
     99 ```
    100 
    101 </section>
    102 
    103 <!-- /.examples -->
    104 
    105 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    106 
    107 <section class="references">
    108 
    109 </section>
    110 
    111 <!-- /.references -->
    112 
    113 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    114 
    115 <section class="links">
    116 
    117 [@stdlib/complex/float32]: https://www.npmjs.com/package/@stdlib/complex/tree/main/float32
    118 
    119 </section>
    120 
    121 <!-- /.links -->