1
00:00:00,390 --> 00:00:06,780
All right, and once we have covered the general existence of built in modules, now let's take a look

2
00:00:06,780 --> 00:00:07,500
at a few of them.

3
00:00:07,920 --> 00:00:12,200
And I'm going to start by creating that file that I promised ureters ago.

4
00:00:12,390 --> 00:00:17,520
Remember when I was setting up the modules, I said that eventually there's going to be a file by the

5
00:00:17,520 --> 00:00:18,720
name of three modules.

6
00:00:19,050 --> 00:00:21,270
And this one, I would want to do it together.

7
00:00:21,780 --> 00:00:26,000
Just so you don't think that I'm not fulfilling my promises.

8
00:00:26,400 --> 00:00:34,710
So we're going to go with a module and then I guess modules that dress I'll grab that I currently have

9
00:00:34,710 --> 00:00:37,230
and just pretty much everything.

10
00:00:37,620 --> 00:00:38,990
And we copy and paste.

11
00:00:39,000 --> 00:00:42,990
And in this case, I also uncommented the CIHI again.

12
00:00:43,350 --> 00:00:49,260
This all stays for your reference and you'll have access to it if you navigate to the gate.

13
00:00:49,260 --> 00:00:52,170
Apropo So grab everything and apparatus.

14
00:00:52,170 --> 00:00:55,470
I'll actually cut it out and start from scratch and copy and paste.

15
00:00:55,710 --> 00:01:00,450
All this code is sending in the modules and just keep in mind that we're still referencing the names

16
00:01:00,450 --> 00:01:07,320
utils alternative flavor as well as my favorite, the Minecraft and Back in Objets.

17
00:01:08,190 --> 00:01:13,560
Now let's start by taking a look at the OS module and always module.

18
00:01:13,740 --> 00:01:20,880
The built in module provides many useful properties and methods for interacting with operating system,

19
00:01:21,000 --> 00:01:28,470
as well as the server and the general setup for the built in modules or even the external ones that

20
00:01:28,470 --> 00:01:34,530
we're going to cover a bit later is going to be similar where we're going to go with some kind of variable.

21
00:01:35,010 --> 00:01:38,490
And in this case, I'm going to call this OS four operating system.

22
00:01:38,820 --> 00:01:45,120
Then we're going to go with require and in require will have to pass in the name.

23
00:01:45,750 --> 00:01:49,290
So since this is a built in module, of course we don't need to install anything.

24
00:01:49,770 --> 00:01:52,320
Remember it later when we work with external ones.

25
00:01:52,620 --> 00:01:55,320
Yes, we'll have to install that module first.

26
00:01:55,650 --> 00:01:58,940
In this case, it is a built in, so we just go with OS.

27
00:01:58,950 --> 00:02:00,900
But again, let me stress something.

28
00:02:01,200 --> 00:02:04,500
We're not doing the attention for now.

29
00:02:04,800 --> 00:02:06,240
We just go with OS.

30
00:02:06,240 --> 00:02:07,340
So that way Node knows.

31
00:02:07,380 --> 00:02:15,330
All right, so you're looking for the built in module and once we set this up, then we have multiple

32
00:02:15,330 --> 00:02:15,720
options.

33
00:02:16,200 --> 00:02:21,240
Either you can access those methods by just running this variable.

34
00:02:21,570 --> 00:02:28,410
So it would look something like this where I go with OS and notice the moment I press that I have all

35
00:02:28,410 --> 00:02:29,120
these options.

36
00:02:29,130 --> 00:02:36,450
So these are the methods and properties that I can use, or if we know that we want a specific one,

37
00:02:36,780 --> 00:02:38,520
you can simply the structure here.

38
00:02:38,820 --> 00:02:44,490
And of course throughout the course I'll use multiple setups, just so you understand that both of them

39
00:02:44,490 --> 00:02:45,920
effectively do the same thing.

40
00:02:46,260 --> 00:02:53,580
So here I have access to all the methods and properties that this module provides and I can go crazy.

41
00:02:53,940 --> 00:03:00,630
For example, I could get a useful info about the current user, which of course it has me so say info

42
00:03:00,870 --> 00:03:05,040
about current and my user.

43
00:03:05,400 --> 00:03:09,540
And you're not as a side note, I'll save here and I'll close all the files.

44
00:03:09,930 --> 00:03:15,300
It's just a bit annoying that I have all those times open back in the address now.

45
00:03:15,300 --> 00:03:17,580
I would want to assign it to a user.

46
00:03:18,720 --> 00:03:24,150
And we'll simply go with hours, since that is the name of my variable and one method that I'm looking

47
00:03:24,150 --> 00:03:25,620
for is user info.

48
00:03:25,890 --> 00:03:27,090
I don't need to pass anything.

49
00:03:27,300 --> 00:03:28,860
I simply invoke it.

50
00:03:28,860 --> 00:03:30,200
And so I would want to see the result.

51
00:03:30,210 --> 00:03:36,990
I simply go along and I'm looking for the user and you can probably already guess that we'll just around

52
00:03:37,200 --> 00:03:38,750
node objets.

53
00:03:39,120 --> 00:03:44,030
And latish I have info about the user, which is me.

54
00:03:44,070 --> 00:03:45,840
So this would be a home directory.

55
00:03:46,080 --> 00:03:50,280
This is going to be the default shell and all kinds of useful stuff.

56
00:03:50,770 --> 00:03:58,140
Then I don't want to show you how we can get the uptime of the system so effectively, how long the

57
00:03:58,140 --> 00:04:00,600
computer has been running in seconds.

58
00:04:00,990 --> 00:04:03,150
And I'll just add a comment.

59
00:04:03,330 --> 00:04:12,270
Method returns the system system uptime, uptime in seconds.

60
00:04:12,460 --> 00:04:13,620
The way I'm going to run that.

61
00:04:13,620 --> 00:04:14,130
All right.

62
00:04:14,130 --> 00:04:20,670
Or set up the console log, just totally understand that we have multiple options how we can invoke

63
00:04:20,670 --> 00:04:21,350
those methods.

64
00:04:21,870 --> 00:04:24,990
You don't always have to assign to some kind of variable.

65
00:04:25,260 --> 00:04:32,550
Now, I'll leave this one in here, so I'll leave the console log and then user and let's say right

66
00:04:32,550 --> 00:04:34,230
above or not, let's do it this way.

67
00:04:34,500 --> 00:04:38,820
So we have the console log where the user is and then let's go with another one.

68
00:04:39,240 --> 00:04:40,130
Go along.

69
00:04:40,290 --> 00:04:48,510
In this case, I'm going to go with Template String and I say the system sys uptime is and then let's

70
00:04:48,510 --> 00:04:53,400
use a interpolation and the method that I'm looking for is uptime.

71
00:04:53,460 --> 00:04:58,080
So again, I go with my variable name and I know I've said this before, but I just want to stress this

72
00:04:58,080 --> 00:05:00,510
point just so we all are on the same page.

73
00:05:00,900 --> 00:05:05,820
And in this case I'm going to go with OS and the method name is uptime.

74
00:05:06,270 --> 00:05:08,520
And then let's just add seconds.

75
00:05:08,880 --> 00:05:16,860
And again, Sendhil, back in the integrated terminal run node and then Abcess not only have the info,

76
00:05:17,130 --> 00:05:20,070
I also have the system uptime.

77
00:05:20,400 --> 00:05:27,920
And what's interesting, this actually is one hundred seconds, meaning if I run this notice that you

78
00:05:27,930 --> 00:05:30,810
would expect that this would probably stop at 60.

79
00:05:30,810 --> 00:05:33,630
Right, since we have 60 seconds in a minute.

80
00:05:33,840 --> 00:05:40,020
But no, actually this one goes to a hundred and then I'm just going to set up a object where I'll show

81
00:05:40,020 --> 00:05:45,990
you a few more methods and then we'll move on to the next module, because, again, the point is not

82
00:05:45,990 --> 00:05:53,190
to cover each and every method point is just to give you a general idea how the modules, the built

83
00:05:53,190 --> 00:05:55,560
in modules would work in node.

84
00:05:55,800 --> 00:06:00,030
So clear my terminal and then I'll create a object.

85
00:06:00,030 --> 00:06:07,110
I'll call this current and then OS and then in this object set up properties and I'll set them equal

86
00:06:07,410 --> 00:06:13,020
to the method that actually returns that value from my OS module.

87
00:06:13,230 --> 00:06:17,760
So I'll go with name and OS and this is going to be equal to a type method.

88
00:06:18,090 --> 00:06:24,720
Then I can get the release and this one will be equal to OS and then release again.

89
00:06:24,720 --> 00:06:28,500
We invoke it, then we'll look for total memory and free memory.

90
00:06:29,500 --> 00:06:37,810
Total and ma'am, I'll go with OS and then total, ma'am, as you can see, somewhat predictable, and

91
00:06:37,820 --> 00:06:42,820
then we're going to go with free memory and it's not going to be surprised if we're just going to go

92
00:06:42,820 --> 00:06:44,710
with free memory here.

93
00:06:45,040 --> 00:06:47,190
Let's save that one last little.

94
00:06:47,200 --> 00:06:54,130
Let's just lock it and we should get a bunch of info about our current operating system.

95
00:06:54,460 --> 00:07:01,600
Again, we're going to go with Node and that app Jass and not only have the user information, not only

96
00:07:01,600 --> 00:07:10,000
I know how long the system has been up in seconds, I can also get some useful data about my operating

97
00:07:10,000 --> 00:07:10,330
system.

98
00:07:10,330 --> 00:07:12,540
And again, we're just scratching the surface.

99
00:07:12,700 --> 00:07:19,540
There's more methods and properties, but hopefully you have a clear understanding how powerful these

100
00:07:19,690 --> 00:07:21,280
built in modules are.

101
00:07:21,610 --> 00:07:22,420
Notorious.

