-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.mjs
More file actions
28 lines (26 loc) · 775 Bytes
/
event.mjs
File metadata and controls
28 lines (26 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//import EventEmitter from "node:events";
//class Emitter extends EventEmitter{}
/* const myE=new Emitter()
myE.once('foo',()=>console.log('an events'))
myE.once('foo',()=>console.log('an events 2'))
myE.once('foo',(x)=>console.log(`an event ${x}`))
myE.once('boo',()=>console.log('boom event'))
myE.emit('foo')
myE.emit('foo')
console.log(myE); */
import fs from "fs/promises";
(async () => {
console.time('write');
const fd=await fs.open('./Node.js-Express-Course-Build-4-Projects.mp4','r')
const stream= fd.createReadStream()
stream.on('data',chunk=>{
console.log(chunk);
})
stream.on('end',()=>{
console.log('done');
console.timeEnd('write')
})
stream.on('error',err=>{
throw err
})
})()