string-length
npmv7.0.1TypeScriptGet the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes
Safe to adopt
Yes — string-length scores well across adoption, maintenance, weight, supply chain, and licensing. No download data reported for this package yet. Last published 231 days ago. 2 releases in the last 2 years.
- ?Adoption: grade ?, Not reported by this registry.
No download data reported for this package yet.
- BMaintenance: grade B, Good.
Last published 231 days ago. 2 releases in the last 2 years.
- AWeight: grade A, Excellent.
Zero runtime dependencies, about 4.3 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 string-length 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 >=20
- Module format
- ESM only
- TypeScript
- Types included
- Install scripts
- None
Quick start
A usage example from the string-length README.
import stringLength from 'string-length';
'🐴'.length;
//=> 2
stringLength('🐴');
//=> 1
stringLength('\u001B[1municorn\u001B[22m');
//=> 7string-length 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 |
|---|---|---|---|---|
| string-lengththis page | 0 | 3 | MIT | 7 months ago |
| string-width | 0 | 3 | MIT | 1 day ago |
| escape-string-regexp | 316.5M | 8 | MIT | 1 day ago |
| get-east-asian-width | 69.3M | 1 | MIT | 1 day ago |
| css.escape | 48.7M | 2 | MIT | 1 day ago |
| terminal-link | 18.8M | 1 | MIT | 1 day ago |
Dependencies
Declared by string-length v7.0.1. Runtime dependencies are installed with the package; dev dependencies are not.
Dev (2)
Used by
Popular packages that depend on string-length.
Relationship graph
Dependencies (left) and dependents (right) of string-length.
Frequently installed together
This packages is a collection of utilities and helper functions
A Node.js module for sending notifications on native Mac, Windows (post and pre 8) and Linux (or Growl as fallback)
This package contains shared types of Jest's packages.
TypeScript definitions for node
No description provided.
No description provided.
Source maps support for istanbul
No description provided.
`@jest/pattern` is a helper library for the jest library that implements the logic for parsing and matching patterns.
No description provided.
Module for executing heavy tasks under forked processes in parallel, by providing a `Promise` based interface, minimum overhead, and bound workers.
Convert Windows backslash paths to slash paths
Release history
2 releases in the last two years, typically about 104 days apart.
| Version | Published | Size | License |
|---|---|---|---|
| 7.0.1latest | 7 months ago | 4.3 KB | MIT |
| 7.0.0 | 7 months ago | 4.2 KB | MIT |
| 6.0.0 | 3 years ago | 4.2 KB | MIT |
| 5.0.1 | 5 years ago | 4.5 KB | MIT |
| 5.0.0 | 5 years ago | 4.5 KB | MIT |
| 4.0.2 | 5 years ago | 4.0 KB | MIT |
| 4.0.1 | 6 years ago | 4.0 KB | MIT |
| 4.0.0 | 6 years ago | 4.0 KB | MIT |
| 3.1.0 | 7 years ago | 3.8 KB | MIT |
| 3.0.0 | 7 years ago | 3.5 KB | MIT |
| 2.0.0 | 9 years ago | — | MIT |
| 1.0.1 | 11 years ago | — | MIT |
| 1.0.0 | 12 years ago | — | MIT |
| 0.1.2 | 12 years ago | — | MIT |
| 0.1.1 | 12 years ago | — | MIT |
Overview
string-length is an npm package that get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes. It has 3 known dependents in the graph. The latest version is 7.0.1, released under the MIT license.
Who should use it
Teams working in the npm ecosystem who need get the real length of a string - by correctly counting astral symbols and ignoring ansi escape codes and value a focused solution.
When not to use it
Consider an alternative if you need to or if a more actively-maintained option better fits your npm stack.
Pros
- Ships TypeScript type definitions.
- Clear open-source license (MIT).
- Lean dependency tree (2 direct dependencies).
Cons
- No significant drawbacks detected from available metadata.
Auto-generated from collected registry metadata. No external claims are inferred.
Maintainers
Funding
Frequently asked questions
Should I use string-length?
Yes — string-length scores well across adoption, maintenance, weight, supply chain, and licensing. No download data reported for this package yet. Last published 231 days ago. 2 releases in the last 2 years.
How do I install string-length?
Run `npm install string-length` to add string-length to your npm project.
What license is string-length released under?
string-length is distributed under the MIT license.
How popular is string-length?
npm does not publish download counts. Within PackageGraph's crawl, 3 known packages depend on string-length.
Is string-length still maintained?
The most recent release of string-length (v7.0.1) was published 7 months ago.
Does string-length run install scripts?
No. string-length does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.