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.

buf.js 773B

123456789101112131415161718192021222324252627282930313233
  1. var path = require('path');
  2. var test = require('tape');
  3. var Buffer = require('safe-buffer').Buffer;
  4. var Writable = require('../').Writable;
  5. var inherits = require('inherits');
  6. inherits(TestWritable, Writable);
  7. function TestWritable(opt) {
  8. if (!(this instanceof TestWritable))
  9. return new TestWritable(opt);
  10. Writable.call(this, opt);
  11. this._written = [];
  12. }
  13. TestWritable.prototype._write = function(chunk, encoding, cb) {
  14. this._written.push(chunk);
  15. cb();
  16. };
  17. var buf = Buffer.from([ 88 ]);
  18. test('.writable writing ArrayBuffer', function(t) {
  19. var writable = new TestWritable();
  20. writable.write(buf);
  21. writable.end();
  22. t.equal(writable._written.length, 1);
  23. t.equal(writable._written[0].toString(), 'X')
  24. t.end()
  25. });