Last change
on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | # is-buffer [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url]
|
---|
2 |
|
---|
3 | [travis-image]: https://img.shields.io/travis/feross/is-buffer/master.svg
|
---|
4 | [travis-url]: https://travis-ci.org/feross/is-buffer
|
---|
5 | [npm-image]: https://img.shields.io/npm/v/is-buffer.svg
|
---|
6 | [npm-url]: https://npmjs.org/package/is-buffer
|
---|
7 | [downloads-image]: https://img.shields.io/npm/dm/is-buffer.svg
|
---|
8 | [downloads-url]: https://npmjs.org/package/is-buffer
|
---|
9 | [standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
|
---|
10 | [standard-url]: https://standardjs.com
|
---|
11 |
|
---|
12 | #### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (including the [browserify Buffer](https://github.com/feross/buffer))
|
---|
13 |
|
---|
14 | [![saucelabs][saucelabs-image]][saucelabs-url]
|
---|
15 |
|
---|
16 | [saucelabs-image]: https://saucelabs.com/browser-matrix/is-buffer.svg
|
---|
17 | [saucelabs-url]: https://saucelabs.com/u/is-buffer
|
---|
18 |
|
---|
19 | ## Why not use `Buffer.isBuffer`?
|
---|
20 |
|
---|
21 | This module lets you check if an object is a `Buffer` without using `Buffer.isBuffer` (which includes the whole [buffer](https://github.com/feross/buffer) module in [browserify](http://browserify.org/)).
|
---|
22 |
|
---|
23 | It's future-proof and works in node too!
|
---|
24 |
|
---|
25 | ## install
|
---|
26 |
|
---|
27 | ```bash
|
---|
28 | npm install is-buffer
|
---|
29 | ```
|
---|
30 |
|
---|
31 | ## usage
|
---|
32 |
|
---|
33 | ```js
|
---|
34 | var isBuffer = require('is-buffer')
|
---|
35 |
|
---|
36 | isBuffer(new Buffer(4)) // true
|
---|
37 |
|
---|
38 | isBuffer(undefined) // false
|
---|
39 | isBuffer(null) // false
|
---|
40 | isBuffer('') // false
|
---|
41 | isBuffer(true) // false
|
---|
42 | isBuffer(false) // false
|
---|
43 | isBuffer(0) // false
|
---|
44 | isBuffer(1) // false
|
---|
45 | isBuffer(1.0) // false
|
---|
46 | isBuffer('string') // false
|
---|
47 | isBuffer({}) // false
|
---|
48 | isBuffer(function foo () {}) // false
|
---|
49 | ```
|
---|
50 |
|
---|
51 | ## license
|
---|
52 |
|
---|
53 | MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org).
|
---|
Note:
See
TracBrowser
for help on using the repository browser.