You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB

4 years ago
  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. [travis-image]: https://img.shields.io/travis/feross/is-buffer/master.svg
  3. [travis-url]: https://travis-ci.org/feross/is-buffer
  4. [npm-image]: https://img.shields.io/npm/v/is-buffer.svg
  5. [npm-url]: https://npmjs.org/package/is-buffer
  6. [downloads-image]: https://img.shields.io/npm/dm/is-buffer.svg
  7. [downloads-url]: https://npmjs.org/package/is-buffer
  8. [standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg
  9. [standard-url]: https://standardjs.com
  10. #### Determine if an object is a [`Buffer`](http://nodejs.org/api/buffer.html) (including the [browserify Buffer](https://github.com/feross/buffer))
  11. [![saucelabs][saucelabs-image]][saucelabs-url]
  12. [saucelabs-image]: https://saucelabs.com/browser-matrix/is-buffer.svg
  13. [saucelabs-url]: https://saucelabs.com/u/is-buffer
  14. ## Why not use `Buffer.isBuffer`?
  15. 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/)).
  16. It's future-proof and works in node too!
  17. ## install
  18. ```bash
  19. npm install is-buffer
  20. ```
  21. ## usage
  22. ```js
  23. var isBuffer = require('is-buffer')
  24. isBuffer(new Buffer(4)) // true
  25. isBuffer(undefined) // false
  26. isBuffer(null) // false
  27. isBuffer('') // false
  28. isBuffer(true) // false
  29. isBuffer(false) // false
  30. isBuffer(0) // false
  31. isBuffer(1) // false
  32. isBuffer(1.0) // false
  33. isBuffer('string') // false
  34. isBuffer({}) // false
  35. isBuffer(function foo () {}) // false
  36. ```
  37. ## license
  38. MIT. Copyright (C) [Feross Aboukhadijeh](http://feross.org).