JavaScript Set 6 Flashcards

1
Q

What is the filesystem module?

A

Allows you to work with the file system using node.js
require(“fs”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What functions can the file system module perform?

A
  1. Read files
  2. Create files
  3. Update files
  4. Delete files
  5. Rename files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the URL module?

A

Splits up a web address into readable parts

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the url.parse() method?

A

Returns a URL object with each part
Ex:
q = url.parse(adr)
log(q.host)
log(q.pathname)
log(q.search)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Node.js Crypto module?

A

Contains OpenSSL and allows you to encrypt and decrypt data
require(“crypto”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can you encrypt data with the crypto module?

A
  1. Create encryption cipher key with
    var key = crypto.Cipher(encryption method, key);
  2. Encrypt the data with the key
    var cipherText = key.update(text, encoding method, return format);
  3. Get any remaining encrypted data
    cipherText += key.final(return format)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How can you decrypt data with the crypto module?

A
  1. Create decryption key with
    var key = crypto.Decipher(encryption method, key);
  2. Decrypt the data with the key
    var plainText = key.update(input text, input encoding, output encoding);
  3. Get any remaining decrypted data
    plainText += key.final(output encoding);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the dns module do?

A

Can convert URLs to IP addresses and vice-versa
require(“dns”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you convert a URL to an IP using the DNS module?

A

dns.lookup(URL, callback function (err, addresses, family));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you convert an IP to a URL using the DNS module?

A

dns.reverse(IP, callback function (err, url));

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the events module do?

A

Allows you to create, fire, and listen for your own events
require(‘events’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you access event properties and methods?

A

By creating an EventEmitter object
var emitter = new events.EventEmitter();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you assign an event handler to an event?

A

eventEmitter.on(event name, handler function);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you fire an event?

A

eventEmitter.emit(event name);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the timer module do?

A

Contains functions that can execute code after a certain period of time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the 3 scheduling timer functions available in the timers module?

A
  1. setImmediate() executes a function immediately
  2. setInterval() executes a function every given milliseconds
  3. setTimeout() executes a function after a given time in milliseconds
17
Q

What are the 3 cancelling timer functions available in the timers module?

A
  1. clearImmediate() cancels and immediate object
  2. clearInterval() cancels an interval object
  3. clearTimeout() cancels a timeout object