1.0.9 • Published 3 years ago

informing v1.0.9

Weekly downloads
9
License
MIT
Repository
github
Last release
3 years ago

Informing

A simple, ridiculously small module (the module itself is <2KB, excluding the README, LICENSE, and package.json files) to get information about various things


Installation:

npm i informing

Then require() it in your code. Done!

Or if you're in a browser, :

Use a CDN to import it onto your website:

<script src="https://cdn.jsdelivr.net/npm/informing@1.x.x/index.js"></script>

This will pull in the latest version of Informing that doesn't have breaking changes, which I can't see a simple library like this having. To pull in the latest version, even with potential breaking changes.


Informing supports:

defaults
maintained node versions
not ie 11
not ie_mob 11

BrowsersList


Usage

informing.agent()

informing.agent()

Returns the browser's user agent. Returns null in NodeJS.


informing.argv()

informing.argv()

Returns the arguments passed to the program through the CLI. Returns null in the browser.


informing.baseURL()

informing.baseURL()

Returns the origin of the URL. Returns null in NodeJS.


informing.day()

informing.day()

Returns the current day (for example, if today was January 1st, it would return 1, because today is the first day of the month). Supported in both NodeJS and the browser.


informing.dayOfWeek(number)

informing.dayOfWeek()
// OR
informing.dayOfWeek(true)

Returns day of the week. Returns a string ("Sunday", "Monday", "Tuesday", etc.) if the parameter is left alone or set to false or a falsy value. If it's set to true or a truthy value, it returns the default value of new Date().getDay(). Supported in both NodeJS and the browser.


informing.directory()

informing.directory()

Returns the directory where the JS file is located. Not necessarily the current working directory (the path returned by pwd). Returns null in the browser.


informing.environment()

informing.environment()

Returns "node" or "browser", depending on where the code's being run. Supported in both NodeJS and the browser (obviously).


informing.file()

informing.file()

Similar to informing.directory(), but it returns the file path, not the directory that the file's in. Returns null in the browser.


informing.hash()

informing.hash()

Returns the URL hash. Returns null in NodeJS.


informing.host()

informing.argv()

Like informing.baseURL(), but it also includes the protocol. Returns null in NodeJS.


informing.hostname()

informing.argv()

Like informing.host(), but it also includes the port (In https://www.example.com:8000, www.example.com is the host, but www.example.com:8000 is the host name). Returns null in NodeJS.


informing.hour()

informing.hour()

Returns the current hour (for example, if it was 4:00 PM, informing.hour() would be 16). Supported in both NodeJS and the browser.


informing.millisecond()

informing.millisecond()

Returns the current millisecond. Supported in both NodeJS and the browser.


informing.minute()

informing.minute()

Returns the current minute. Supported in both NodeJS and the browser.


informing.month(number)

informing.month()
// OR
informing.month(true)

Returns day of the week. Returns a string ("January", "February", "March", etc.) if the parameter is left alone or set to false or a falsy value. If it's set to true or a truthy value, it returns the default value of new Date().getMonth(). Supported in both NodeJS and the browser.


informing.pathname()

informing.pathname()

Gives the current path. For example, if the URL was, https://www.example.com/path/to/a/file.html, informing.pathname() would be /path/to/a/file.html. Returns null in NodeJS.


informing.port()

informing.port()

Returns the port (for example, if the URL was https://www.example.com:8000, informing.port() would return 8000). Returns null in NodeJS.


informing.protocol()

informing.protocol()

Returns the protocol (for example, if the URL was https://www.example.com, informing.protocol() would return https:). Returns null in NodeJS.


informing.query()

informing.query()

Returns the query string part of the URL (for example, if the URL was https://www.example.com?myquerystring&otherquerystring=xyz, informing.query() would return ?myquerystring&otherquerystring=xyz). Returns null in NodeJS.


informing.second()

informing.second()

Returns the current second. Supported in both NodeJS and the browser.


informing.URL()

informing.URL()

Returns the full URL. Returns null in NodeJS.

1.0.9

3 years ago

1.1.0

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago