time-to-botec

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

README.md (2803B)


      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 # copyBuffer
     22 
     23 > Copy [buffer][@stdlib/buffer/ctor] data to a new [`Buffer`][@stdlib/buffer/ctor] instance.
     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 copyBuffer = require( '@stdlib/buffer/from-buffer' );
     41 ```
     42 
     43 #### copyBuffer( buffer )
     44 
     45 Copies [buffer][@stdlib/buffer/ctor] data to a new [`Buffer`][@stdlib/buffer/ctor] instance.
     46 
     47 ```javascript
     48 var array2buffer = require( '@stdlib/buffer/from-array' );
     49 
     50 var b1 = array2buffer( [ 1, 2, 3, 4 ] );
     51 // returns <Buffer>[ 1, 2, 3, 4 ]
     52 
     53 var b2 = copyBuffer( b1 );
     54 // returns <Buffer>[ 1, 2, 3, 4 ]
     55 ```
     56 
     57 </section>
     58 
     59 <!-- /.usage -->
     60 
     61 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
     62 
     63 <section class="notes">
     64 
     65 </section>
     66 
     67 <!-- /.notes -->
     68 
     69 <!-- Package usage examples. -->
     70 
     71 <section class="examples">
     72 
     73 ## Examples
     74 
     75 <!-- eslint no-undef: "error" -->
     76 
     77 ```javascript
     78 var allocUnsafe = require( '@stdlib/buffer/alloc-unsafe' );
     79 var copyBuffer = require( '@stdlib/buffer/from-buffer' );
     80 
     81 var bool;
     82 var b1;
     83 var b2;
     84 var i;
     85 
     86 // Allocate a new buffer:
     87 b1 = allocUnsafe( 10 );
     88 
     89 // Generate a new buffer from the existing buffer:
     90 b2 = copyBuffer( b1 );
     91 
     92 bool = ( b2 === b1 );
     93 // returns false
     94 
     95 bool = ( b2.length === b1.length );
     96 // returns true
     97 
     98 for ( i = 0; i < b2.length; i++ ) {
     99     console.log( b2[ i ] === b1[ i ] );
    100     // => true
    101 }
    102 ```
    103 
    104 </section>
    105 
    106 <!-- /.examples -->
    107 
    108 <!-- 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. -->
    109 
    110 <section class="references">
    111 
    112 </section>
    113 
    114 <!-- /.references -->
    115 
    116 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
    117 
    118 <section class="links">
    119 
    120 [@stdlib/buffer/ctor]: https://www.npmjs.com/package/@stdlib/buffer/tree/main/ctor
    121 
    122 </section>
    123 
    124 <!-- /.links -->