JAVASCRIPT   15

obj js

Guest on 25th July 2022 04:13:43 PM

  1. var test = require('tape');
  2. var concat = require('concat-stream');
  3. var staticModule = require('../');
  4. var fs = require('fs');
  5. var path = require('path');
  6.  
  7. test('object', function (t) {
  8.     t.plan(2);
  9.    
  10.     var expected = [ 12, 555 ];
  11.     var sm = staticModule({
  12.         beep: { x: 4, f: function (n) { return n * 111 } }
  13.     });
  14.     readStream('source.js').pipe(sm).pipe(concat(function (body) {
  15.         Function(['console'],body)({ log: log });
  16.         function log (msg) { t.equal(msg, expected.shift()) }
  17.     }));
  18. });
  19.  
  20. function readStream (file) {
  21.     return fs.createReadStream(path.join(__dirname, 'obj', file));
  22. }

Raw Paste


Login or Register to edit or fork this paste. It's free.