# @ultraq/string-utils

> A collection of utilities for JavaScript strings

Latest version **3.1.0** (published 2023-12-24) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @ultraq/string-utils
pnpm add @ultraq/string-utils
yarn add @ultraq/string-utils
bun add @ultraq/string-utils
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2023-12-24 |
| First published | 2017-04-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 19.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Emanuel Rabina |
| Maintainers | ultraq |
| Keywords | string, utilities, format, escape, html |

## Links

- npm: https://www.npmjs.com/package/@ultraq/string-utils
- Repository: https://github.com/ultraq/string-utils
- Homepage: https://github.com/ultraq/string-utils#readme
- Issues: https://github.com/ultraq/string-utils/issues
- npm.io page: https://npm.io/package/@ultraq/string-utils

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [stringify-attributes](https://npm.io/package/stringify-attributes.md) — 58.6K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2023-12-24
- 3.0.0 — 2023-09-06
- 2.1.0 — 2020-08-09
- 2.0.0 — 2020-05-10
- 1.2.0 — 2018-04-20
- 1.1.0 — 2017-05-04
- 1.0.0 — 2017-04-30

## README

string-utils
============

[![Build Status](https://github.com/ultraq/string-utils/actions/workflows/build.yml/badge.svg)](https://github.com/ultraq/string-utils/actions)
[![codecov](https://codecov.io/gh/ultraq/string-utils/graph/badge.svg?token=CYvb2fQJBY)](https://codecov.io/gh/ultraq/string-utils)
[![npm](https://img.shields.io/npm/v/@ultraq/string-utils.svg?maxAge=3600)](https://www.npmjs.com/package/@ultraq/string-utils)
[![Bundlephobia minified size](https://img.shields.io/bundlephobia/min/@ultraq/string-utils)](https://bundlephobia.com/result?p=@ultraq/string-utils)

A collection of utilities for JavaScript strings.


Installation
------------

Via npm:

```
npm install @ultraq/string-utils
```


API
---

### escapeHtml(string)

Escapes special HTML characters in a string with their entity code equivalents.
Returns a string safe to use as text within an HTML document.

 - **string**: string to escape.

### format(template, ...values)

Returns the replacement of each placeholder in a template string with a
corresponding replacement value.

 - **template**: String containing indexed (`{0}`, `{1}`, ...) or named
   (`{value}`, `{greeting}`, ...) placeholders, but not both.
   where `n` is the corresponding index value to have filled-in.
 - **...values**: Either an argument list / array of values to replace values in
   an indexed template string, or an object where the keys are the names in a
   named template string to replace with their values.

---
_Source: https://npm.io/package/@ultraq/string-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
