time-to-botec

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

README.md (2368B)


      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 # isBuffer
     22 
     23 > Test if a value is a [Buffer][node-buffer] object.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var isBuffer = require( '@stdlib/assert/is-buffer' );
     31 ```
     32 
     33 #### isBuffer( value )
     34 
     35 Tests if a `value` is a [`Buffer`][node-buffer] object.
     36 
     37 <!-- TODO: update once Buffer wrapper -->
     38 
     39 <!-- eslint-disable no-buffer-constructor -->
     40 
     41 ```javascript
     42 var Buffer = require( '@stdlib/buffer/ctor' );
     43 
     44 var value = new Buffer( [ 1, 2, 3, 4 ] );
     45 
     46 var bool = isBuffer( value );
     47 // returns true
     48 ```
     49 
     50 </section>
     51 
     52 <!-- /.usage -->
     53 
     54 <section class="notes">
     55 
     56 ## Notes
     57 
     58 -   The implementation supports both [Node.js][node-buffer] and [browser polyfill][browser-buffer] `Buffer` objects.
     59 
     60 </section>
     61 
     62 <!-- /.notes -->
     63 
     64 <section class="examples">
     65 
     66 ## Examples
     67 
     68 <!-- TODO: update once Buffer wrapper -->
     69 
     70 <!-- eslint no-undef: "error" -->
     71 
     72 <!-- eslint-disable no-buffer-constructor, no-restricted-syntax, no-empty-function -->
     73 
     74 ```javascript
     75 var Int8Array = require( '@stdlib/array/int8' );
     76 var Buffer = require( '@stdlib/buffer/ctor' );
     77 var isBuffer = require( '@stdlib/assert/is-buffer' );
     78 
     79 var bool = isBuffer( new Buffer( [ 1, 2, 3, 4 ] ) );
     80 // returns true
     81 
     82 bool = isBuffer( new Buffer( 'beep' ) );
     83 // returns true
     84 
     85 bool = isBuffer( [] );
     86 // returns false
     87 
     88 bool = isBuffer( {} );
     89 // returns false
     90 
     91 bool = isBuffer( new Int8Array() );
     92 // returns false
     93 
     94 bool = isBuffer( function foo() {} );
     95 // returns false
     96 
     97 bool = isBuffer( null );
     98 // returns false
     99 
    100 bool = isBuffer( void 0 );
    101 // returns false
    102 
    103 bool = isBuffer( 'beep' );
    104 // returns false
    105 
    106 bool = isBuffer( 5 );
    107 // returns false
    108 ```
    109 
    110 </section>
    111 
    112 <!-- /.examples -->
    113 
    114 <section class="links">
    115 
    116 [node-buffer]: http://nodejs.org/api/buffer.html
    117 
    118 [browser-buffer]: https://github.com/feross/buffer
    119 
    120 </section>
    121 
    122 <!-- /.links -->