has-flag
npmv5.0.1Check 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.
Runtime packages this one declares itself.
Distinct packages in the full runtime tree, deduplicated the way a package manager would.
Unpacked size of this package plus its entire runtime tree.
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');
//=> truehas-flag vs the alternatives
Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.
| Package | Weekly downloads | Dependents | License | Last release |
|---|---|---|---|---|
| has-flagthis page | 166.9M | 1 | MIT | 5 years ago |
| commander | 451.1M | 11 | MIT | 1 day ago |
| yargs-parser | 178.8M | 2 | ISC | 1 day ago |
| open | 130.4M | 4 | MIT | 1 day ago |
| is-wsl | 117.6M | 4 | MIT | 1 day ago |
| supports-hyperlinks | 35.4M | 1 | MIT | 1 day ago |
Dependencies
Declared by has-flag v5.0.1. Runtime dependencies are installed with the package; dev dependencies are not.
Dev (3)
Used by
Popular packages that depend on has-flag.
Relationship graph
Dependencies (left) and dependents (right) of has-flag.
Release history
No releases in the last two years, typically about 459 days apart.
| Version | Published | Size | License |
|---|---|---|---|
| 5.0.1latest | 5 years ago | 4.2 KB | MIT |
| 5.0.0 | 5 years ago | 4.1 KB | MIT |
| 4.0.0 | 7 years ago | 4.3 KB | MIT |
| 3.0.0 | 8 years ago | — | MIT |
| 2.0.0 | 10 years ago | — | MIT |
| 1.0.0 | 11 years ago | — | MIT |
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
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.