# @alwatr/flat-string

> The `flat-string` function flattens the underlying C structures of a concatenated JavaScript string.

Latest version **10.4.0** (published 2026-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install @alwatr/flat-string
pnpm add @alwatr/flat-string
yarn add @alwatr/flat-string
bun add @alwatr/flat-string
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 10.4.0 |
| Published | 2026-10-01 |
| First published | 2023-12-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | S. Ali Mihandoost |
| Maintainers | alimd |
| Keywords | alwatr, browser, concat, cross-platform, ECMAScript, esm, flat, flatten, javascript, module, nanolib, node, nodejs, optimize, string, typescript, util, utility, utils |

## Links

- npm: https://www.npmjs.com/package/@alwatr/flat-string
- Repository: https://github.com/Alwatr/alwatr
- Homepage: https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/flat-string#readme
- Issues: https://github.com/Alwatr/alwatr/issues
- npm.io page: https://npm.io/package/@alwatr/flat-string

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 10.4.0 (latest) — 2026-10-01
- 10.3.0 — 2026-09-21
- 10.2.0 — 2026-09-08
- 10.0.0 — 2026-07-26
- 9.38.2 — 2026-07-12
- 9.38.1 — 2026-06-28
- 9.36.0 — 2026-06-11
- 9.33.1 — 2026-06-10
- 9.33.0 — 2026-06-10
- 9.25.0 — 2026-05-21
- 9.16.0 — 2026-04-27
- 9.14.0 — 2026-04-25
- 9.11.2 — 2026-04-21
- 9.10.1 — 2026-04-18
- 9.10.0 — 2026-04-15
- … 75 more at https://npm.io/package/@alwatr/flat-string/versions

## README

# Flat String

This function simplifies the complex C structures that are part of a combined JavaScript string.

If you're frequently combining strings and then using that combined string somewhere else, you might discover that running your string through `flatString` significantly enhances performance.

In simpler terms, `flatString` is a function that optimizes the way strings are stored in memory in JavaScript. When you concatenate strings, JavaScript internally creates a complex structure to save memory. However, when you need to use this string, for example, to write it to a file or send it over the network, this complex structure needs to be flattened, which can take time. By using `flatString`, you flatten the string right after concatenation, making the subsequent use of the string faster.

## Installation

```bash
yarn add @alwatr/flat-string
```

## Usage

```typescript
import {flatString} from '@alwatr/flat-string';

myStr = flatString(myStr);
```

## Sponsors

The following companies, organizations, and individuals support Nanolib ongoing maintenance and development. Become a Sponsor to get your logo on our README and website.

### Contributing

Contributions are welcome! Please read our [contribution guidelines](https://github.com/Alwatr/.github/blob/next/CONTRIBUTING.md) before submitting a pull request.

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