isBufferList.js 564 B

1234567891011121314151617181920212223242526272829303132
  1. 'use strict'
  2. const tape = require('tape')
  3. const { BufferList, BufferListStream } = require('../')
  4. const { Buffer } = require('buffer')
  5. tape('isBufferList positives', (t) => {
  6. t.ok(BufferList.isBufferList(new BufferList()))
  7. t.ok(BufferList.isBufferList(new BufferListStream()))
  8. t.end()
  9. })
  10. tape('isBufferList negatives', (t) => {
  11. const types = [
  12. null,
  13. undefined,
  14. NaN,
  15. true,
  16. false,
  17. {},
  18. [],
  19. Buffer.alloc(0),
  20. [Buffer.alloc(0)]
  21. ]
  22. for (const obj of types) {
  23. t.notOk(BufferList.isBufferList(obj))
  24. }
  25. t.end()
  26. })