# safe-array-concat

> `Array.prototype.concat`, but made safe by ignoring Symbol.isConcatSpreadable

Latest version **1.1.4** (published 2026-04-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install safe-array-concat
pnpm add safe-array-concat
yarn add safe-array-concat
bun add safe-array-concat
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2026-04-20 |
| First published | 2023-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.4 |
| Dependencies | 5 |
| Unpacked size | 18.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | safe, Array, concat, push, isConcatSpreadable |

## Links

- npm: https://www.npmjs.com/package/safe-array-concat
- Repository: https://github.com/ljharb/safe-array-concat
- Homepage: https://github.com/ljharb/safe-array-concat#readme
- Issues: https://github.com/ljharb/safe-array-concat/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/safe-array-concat

## Dependencies (5)

- [isarray](https://npm.io/package/isarray.md) ^2.0.5
- [call-bind](https://npm.io/package/call-bind.md) ^1.0.9
- [call-bound](https://npm.io/package/call-bound.md) ^1.0.4
- [has-symbols](https://npm.io/package/has-symbols.md) ^1.1.0
- [get-intrinsic](https://npm.io/package/get-intrinsic.md) ^1.3.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.1.4 (latest) — 2026-04-20
- 1.1.3 — 2024-12-12
- 1.1.2 — 2024-03-09
- 1.1.1 — 2024-03-09
- 1.1.0 — 2024-01-15
- 1.0.1 — 2023-09-06
- 1.0.0 — 2023-04-20

## README

# safe-array-concat <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

`Array.prototype.concat`, but made safe by ignoring Symbol.isConcatSpreadable

## Getting started

```sh
npm install --save safe-array-concat
```

## Usage/Examples

```js
var safeConcat = require('safe-array-concat');
var assert = require('assert');

assert.deepEqual([].concat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'arrays spread as expected with normal concat');
assert.deepEqual(safeConcat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'arrays spread as expected with safe concat');

String.prototype[Symbol.isConcatSpreadable] = true;
assert.deepEqual([].concat('foo', Object('bar')), ['foo', 'b', 'a', 'r'], 'spreadable String objects are spread with normal concat!!!');
assert.deepEqual(safeConcat('foo', Object('bar')), ['foo', Object('bar')], 'spreadable String objects are not spread with safe concat');

Array.prototype[Symbol.isConcatSpreadable] = false;
assert.deepEqual([].concat([1, 2], 3, [[4]]), [[], [1, 2], 3, [[4]]], 'non-concat-spreadable arrays do not spread with normal concat!!!');
assert.deepEqual(safeConcat([1, 2], 3, [[4]]), [1, 2, 3, [4]], 'non-concat-spreadable arrays still spread with safe concat');
```

## Tests
Simply clone the repo, `npm install`, and run `npm test`

[package-url]: https://npmjs.org/package/safe-array-concat
[npm-version-svg]: https://versionbadg.es/ljharb/safe-array-concat.svg
[deps-svg]: https://david-dm.org/ljharb/safe-array-concat.svg
[deps-url]: https://david-dm.org/ljharb/safe-array-concat
[dev-deps-svg]: https://david-dm.org/ljharb/safe-array-concat/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/safe-array-concat#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/safe-array-concat.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/safe-array-concat.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/safe-array-concat.svg
[downloads-url]: https://npm-stat.com/charts.html?package=safe-array-concat
[codecov-image]: https://codecov.io/gh/ljharb/safe-array-concat/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/safe-array-concat/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/safe-array-concat
[actions-url]: https://github.com/ljharb/safe-array-concat/actions

---
_Source: https://npm.io/package/safe-array-concat · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
