NPM.Format (NPM v0.6.0)

Copy Markdown View Source

Formatting utilities for npm CLI output.

Shared formatting functions used across Mix tasks for consistent output.

Summary

Functions

Format a byte size into human-readable string.

Format a duration in microseconds.

Format a package name and version.

Pluralize a word based on count.

Truncate a string to a maximum length.

Functions

bytes(b)

@spec bytes(non_neg_integer()) :: String.t()

Format a byte size into human-readable string.

duration(us)

@spec duration(non_neg_integer()) :: String.t()

Format a duration in microseconds.

package(name, version)

@spec package(String.t(), String.t()) :: String.t()

Format a package name and version.

pluralize(count, singular, plural)

@spec pluralize(non_neg_integer(), String.t(), String.t()) :: String.t()

Pluralize a word based on count.

truncate(str, max)

@spec truncate(String.t(), non_neg_integer()) :: String.t()

Truncate a string to a maximum length.