username

WebJar for username

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

username
Last Version

Last Version

2.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

username
WebJar for username
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/sindresorhus/username

Download username

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/username/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>username</artifactId>
    <version>2.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/username/
implementation 'org.webjars.npm:username:2.3.0'
// https://jarcasting.com/artifacts/org.webjars.npm/username/
implementation ("org.webjars.npm:username:2.3.0")
'org.webjars.npm:username:jar:2.3.0'
<dependency org="org.webjars.npm" name="username" rev="2.3.0">
  <artifact name="username" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='username', version='2.3.0')
)
libraryDependencies += "org.webjars.npm" % "username" % "2.3.0"
[org.webjars.npm/username "2.3.0"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : execa jar [0.4.0,0.5)
org.webjars.npm : mem jar [0.1.0,0.2)

Project Modules

There are no modules declared in this project.

username Build Status

Get the username of the current user

This module is meant for informational purposes and not for secure identification.

Install

$ npm install username

This package only works in Node.js, not in browsers.

Usage

const username = require('username');

(async () => {
	console.log(await username());
	//=> 'sindresorhus'
})();

API

It first tries to get the username from the SUDO_USER LOGNAME USER LNAME USERNAME environment variables. Then falls back to $ id -un on macOS / Linux and $ whoami on Windows, in the rare case none of the environment variables are set. The result is cached.

username()

Returns a Promise<string> with the username.

username.sync()

Returns the username.

Related

Versions

Version
2.3.0