</>PackageGraphPackageGraph

has-flag

npmv5.0.1

Check if argv has a specific flag

Not recommended for new projects

No — has-flag should not be adopted for new projects. Last published 1878 days ago.

  • AAdoption: grade A, Excellent.

    166.9M downloads per week and 1 known dependents.

  • FMaintenance: grade F, Failing.

    Last published 1878 days ago.

  • AWeight: grade A, Excellent.

    Zero runtime dependencies, about 4.2 KB installed.

  • BSupply chain: grade B, Good.

    This package has a single maintainer (bus factor of 1).

  • ALicense: grade A, Excellent.

    MIT — permissive, with no copyleft found in the dependency tree.

Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.

Install cost

What you actually take on by adding has-flag to a project.

0
Direct dependencies

Runtime packages this one declares itself.

0
Total installed

Distinct packages in the full runtime tree, deduplicated the way a package manager would.

4.2 KB
Install size

Unpacked size of this package plus its entire runtime tree.

Tree depth

Longest resolved dependency chain below this package.

Compatibility

Node.js
node >=12
Module format
ESM only
TypeScript
No bundled types
Install scripts
None

Quick start

A usage example from the has-flag README.

// foo.js
import hasFlag from 'has-flag';

hasFlag('unicorn');
//=> true

hasFlag('--unicorn');
//=> true

hasFlag('f');
//=> true

hasFlag('-f');
//=> true
Example truncated — see the full README.

has-flag vs the alternatives

Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.

PackageWeekly downloadsDependentsLicenseLast release
has-flagthis page166.9M1MIT5 years ago
commander451.1M11MIT1 day ago
yargs-parser178.8M2ISC1 day ago
open130.4M4MIT1 day ago
is-wsl117.6M4MIT1 day ago
supports-hyperlinks35.4M1MIT1 day ago

Dependencies

Declared by has-flag v5.0.1. Runtime dependencies are installed with the package; dev dependencies are not.

Dev (3)

ava ^3.15.0tsd ^0.14.0xo ^0.38.2

Used by

Popular packages that depend on has-flag.

Relationship graph

Dependencies (left) and dependents (right) of has-flag.

supports-hyperlin…has-flag
has-flag dependencies dependents

Release history

No releases in the last two years, typically about 459 days apart.

Recent versions of has-flag
VersionPublishedSizeLicense
5.0.1latest5 years ago4.2 KBMIT
5.0.05 years ago4.1 KBMIT
4.0.07 years ago4.3 KBMIT
3.0.08 years agoMIT
2.0.010 years agoMIT
1.0.011 years agoMIT

Overview

has-flag is an npm package that check if argv has a specific flag. It is extremely widely used, with about 166.9M downloads per week and 1 known dependents in the graph. The latest version is 5.0.1, released under the MIT license.

Who should use it

Teams working in the npm ecosystem who need check if argv has a specific flag and value a battle-tested, widely-adopted solution.

When not to use it

Consider an alternative if you need to have first-class TypeScript types out of the box, or if a more actively-maintained option better fits your npm stack.

Pros

  • Large, well-established user base (166.9M weekly downloads).
  • Clear open-source license (MIT).
  • Lean dependency tree (3 direct dependencies).

Cons

  • No bundled TypeScript types (may require a separate @types package).

Auto-generated from collected registry metadata. No external claims are inferred.

Maintainers

Keywords

Funding

Frequently asked questions

Should I use has-flag?

No — has-flag should not be adopted for new projects. Last published 1878 days ago.

How do I install has-flag?

Run `npm install has-flag` to add has-flag to your npm project.

What license is has-flag released under?

has-flag is distributed under the MIT license.

How popular is has-flag?

has-flag has approximately 166,912,582 downloads per week and 1 known dependent packages.

Is has-flag still maintained?

The most recent release of has-flag (v5.0.1) was published 5 years ago.

Does has-flag run install scripts?

No. has-flag does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.