# safe-splice

> A wrapper for splice that returns a spliced copy, instead of modifying the original

Latest version **1.0.0** (published 2015-12-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install safe-splice
pnpm add safe-splice
yarn add safe-splice
bun add safe-splice
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-12-19 |
| First published | 2015-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrew Nichols |
| Maintainers | tandrewnichols |
| Keywords | splice, array, in place |

## Links

- npm: https://www.npmjs.com/package/safe-splice
- Repository: https://github.com/tandrewnichols/safe-splice
- Issues: https://github.com/tandrewnichols/safe-splice/issues
- npm.io page: https://npm.io/package/safe-splice

## Recent versions

- 1.0.0 (latest) — 2015-12-19

## README

[![Build Status](https://travis-ci.org/tandrewnichols/safe-splice.png)](https://travis-ci.org/tandrewnichols/safe-splice) [![downloads](http://img.shields.io/npm/dm/safe-splice.svg)](https://npmjs.org/package/safe-splice) [![npm](http://img.shields.io/npm/v/safe-splice.svg)](https://npmjs.org/package/safe-splice) [![Code Climate](https://codeclimate.com/github/tandrewnichols/safe-splice/badges/gpa.svg)](https://codeclimate.com/github/tandrewnichols/safe-splice) [![Test Coverage](https://codeclimate.com/github/tandrewnichols/safe-splice/badges/coverage.svg)](https://codeclimate.com/github/tandrewnichols/safe-splice) [![dependencies](https://david-dm.org/tandrewnichols/safe-splice.png)](https://david-dm.org/tandrewnichols/safe-splice) ![Size](https://img.shields.io/badge/size-199b-brightgreen.svg)

# safe-splice

A wrapper for splice that returns a spliced copy, instead of modifying the original

## Installation

`npm install --save safe-splice`

## Summary

There are times when it would be nice to call Array#splice and get the modified array as the return value, rather than the removed items (the normal implementation). This thin wrapper clones the original array (leaving it intact) and returns the modified copy.

## Usage

```
var splice = require('safe-splice');
var arr = [1, 2, 4];
var newArr = splice(arr, 2, 0, 3);
console.log(newArr); // [1, 2, 3, 4]
console.log(oldArr); // [1, 2, 4]
var splice = require('safe-splice');
var arr = [1, 2, 4];
var newArr = splice(arr, 2, 0, 3);
console.log(newArr); // [1, 2, 3, 4]
console.log(oldArr); // [1, 2, 4]
```

### Browser

Serve `dist/safe-splice.js` or `dist/safe-splice.min.js` however you serve javascript files in your application.

## Contributing

Please see [the contribution guidelines](CONTRIBUTING.md).

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