See the documentation of the Google Home module right here!
See the Module!Get features that NodeJS doesn't provide!
See the coding help module and download it today this website! Maybe, you can also add it to your NPM module!
Are you a NodeJS developer and want to add some Google Home features to
your project? Well, now you can!
The Google Home module features many exciting features, such as the
User
class, the randomGreeting
method, and
much more!
Hooray! That means that you have successfully installed the module on your computer! By the way, please note that the version will be different for you. See the Shield below the Introduction title to see the actual version.
Once you have installed the google-home-module
and have the
node_modules
folder in your directory (unless you ran the
command with the -g
flag), you of course need to
require
it in your project!
import
statement, you can run
this command:
If you want to get specific commands, you can use curly bracket notation and specify the variables, methods, or classes you would like to import.
That is basically it for importing the
google-home-module
! See the tabs above to find out if you
want to search for variables, methods, or classes!
Variables are used for storing simple data. Use them in the Google Home module!
version
websiteVersion
version
This variable is soon to be deprecated!
This variable is going to be deprecated. Support may be completely be discarded in a later version.
Get the version of the NPM module for Google Home.
Example:websiteVersion
This variable is soon to be deprecated!
This variable is going to be deprecated. Support may be completely be discarded in a later version.
Get the website version of the Google Home website!
This is right now a static variable, which may not be accurate. We are
hoping to make a dynamic variable (or function) soon.
Please note that the version number will be different. This version was chosen since it was the version when the documentation arrived.
Methods are used for completing complex tasks! These are used to make the most of your coding experience!
randomGreeting
randomGreeting
Get a random greeting for the user.
If the user is signed in, then the user will get a random greeting, with
their username. Sometimes, the function will greet the user depending on
their local time (e.g. Good morning!). When the user is signed in, the
username parameter must be filled. If not, a TypeError
will
be thrown.
If no error occurs, the function will return the greeting it chose. If
the user isn't signed in, it will simply return, "Welcome!".
This function will get updates along with its website, such as more
greetings, or if this function gets an update that the website already
has, such as Settings.
We can see that the bolded part says that a
TypeError
exception was thrown. Why?
Well, because we said that the user is signed in, but they don't have a
username, the function could not compile the username, since there
wasn't anything. The reason there was an error was because if the user
is signed in, then the method will choose a random greeting with their
username in it.
Great! Now that we know what not to do, let's see what to do to make the method work correctly.
First, let's see some code. All of the code will be typed together, but we will output the code one by one for easier understanding.
So, first, let's go slowly and understand Example 1.
We can see that the first parameter was set to false
, which
means that the user is not signed in. We can also see that since we said
that the user isn't signed in, we can leave the username field empty.
Now, let's run it, and see what happens.
We see that there is no error, since the method knows that the user
isn't signed in, but we see text saying 'Welcome!'. This will not be
random and keep showing this as long as signedIn
is
false
.
Great! Now that we know what happens when signedIn
is
true
and the username is passed. We are going to run
it two times to show you some differences.
We see that the outputs both contain the username Someone, but they are different greetings. One says 'Good afternoon, Someone!', and the other says 'Welcome, someone!'. Sometimes, the function can choose a random greeting, or a greeting relating to the user's local time.
Class are helpful for using methods that closly relate to a topic, like Users.
BasicSearch
User
BasicSearch
Makes a new BasicSearch
, in which the user can search in
(not actually search, but we are actually hoping to implement that
functionality soon).
BasicSearch
formatQuery
search
BasicSearch
is very easy to make. You just need to privide
one mandatory parameter and one optional one. Let's see both in
action!
We can see that searchOne
didn't provide the second
parameter, but only the first, and searchTwo
provided both.
By the way, we did do console.log
to see those two
variables' parameter values. So let's see the result!
Note: We could've also used formatQuery
instead, but
we will see that later.
We have bolded the important parts, so we can see what the values are.
As we can see, when we left the searchEngine
parameter
empty, the value was automatically defaulted to 'Google'. But when we
specified it ourselves, it obviously changed it to our value. Also, as
we expect, the query
parameters are the same as specified.
formatQuery
Format the query of the user's search.
If we want to show the user what their query is, we can use the
formatQuery
method.
As we can see, the method by default gives the
username
field a value of 'Anonymous', unless specified. We
can also see that it formats the query very well, with the username, the
query, and the search engine.
search
Search for user's query with the search engine and the user's query.
Unfortunately, this method does not actually search, but we are hoping to implement that feature soon.
The usage is very simple. The search query and search engine are already provided when you make a newBasicSearch
, so all
the method does is make it into a usable URL, depending on the search
engine.
url
and
target
. You can see the output from the code above
below.
There you go! That is how you use the search
method.
User
Makes a new User
, in which you can use to store users, as
well as preform some tasks with their data.
User
changePassword
getEmailDomain
toggleAdminStatus
toggleExistsStatus
toggleSignedOutStatus
validateEmail
validatePassword
Please wait... we're still adding some more documentation!