time-to-botec

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

README.md (3297B)


      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 # Buffer
     22 
     23 > [Buffer][node-buffer] constructor.
     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 Buffer = require( '@stdlib/buffer/ctor' );
     41 ```
     42 
     43 #### Buffer( size )
     44 
     45 Allocates a [`Buffer`][node-buffer] having a specified number of bytes.
     46 
     47 <!-- eslint-disable stdlib/require-globals, no-buffer-constructor -->
     48 
     49 ```javascript
     50 var b = new Buffer( 10 );
     51 // returns <Buffer>
     52 ```
     53 
     54 #### Buffer( array )
     55 
     56 Allocates a [`Buffer`][node-buffer] from an array of octets.
     57 
     58 <!-- eslint-disable stdlib/require-globals, no-buffer-constructor -->
     59 
     60 ```javascript
     61 var b = new Buffer( [ 1, 2, 3, 4 ] );
     62 // returns <Buffer>[ 1, 2, 3, 4 ]
     63 ```
     64 
     65 #### Buffer( buffer )
     66 
     67 Copies [buffer][node-buffer] data to a new [`Buffer`][node-buffer] instance.
     68 
     69 <!-- eslint-disable stdlib/require-globals, no-buffer-constructor -->
     70 
     71 ```javascript
     72 var b1 = new Buffer( [ 1, 2, 3, 4 ] );
     73 var b2 = new Buffer( b1 );
     74 // returns <Buffer>[ 1, 2, 3, 4 ]
     75 ```
     76 
     77 #### Buffer( str\[, encoding] )
     78 
     79 Returns a [`Buffer`][node-buffer] containing a provided `string`.
     80 
     81 <!-- eslint-disable stdlib/require-globals, no-buffer-constructor -->
     82 
     83 ```javascript
     84 var b = new Buffer( 'beep boop' );
     85 // returns <Buffer>
     86 ```
     87 
     88 * * *
     89 
     90 ### Properties
     91 
     92 TODO: add properties
     93 
     94 * * *
     95 
     96 ### Methods
     97 
     98 TODO: add methods
     99 
    100 </section>
    101 
    102 <!-- /.usage -->
    103 
    104 * * *
    105 
    106 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    107 
    108 <section class="notes">
    109 
    110 </section>
    111 
    112 <!-- /.notes -->
    113 
    114 <!-- Package usage examples. -->
    115 
    116 <section class="examples">
    117 
    118 ## Examples
    119 
    120 <!-- eslint no-undef: "error" -->
    121 
    122 ```javascript
    123 var ctor = require( '@stdlib/buffer/ctor' );
    124 
    125 var b;
    126 var i;
    127 
    128 // Allocate uninitialized memory:
    129 if ( typeof ctor.alloc === 'function' ) {
    130     b = ctor.alloc( 10 );
    131 } else {
    132     b = new ctor( 10 );
    133 }
    134 
    135 // Zero fill the buffer...
    136 for ( i = 0; i < b.length; i++ ) {
    137     b[ i ] = 0;
    138 }
    139 console.log( b );
    140 ```
    141 
    142 </section>
    143 
    144 <!-- /.examples -->
    145 
    146 <!-- 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. -->
    147 
    148 <section class="references">
    149 
    150 </section>
    151 
    152 <!-- /.references -->
    153 
    154 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    155 
    156 <section class="links">
    157 
    158 [node-buffer]: https://nodejs.org/api/buffer.html
    159 
    160 </section>
    161 
    162 <!-- /.links -->