# multisplice

> easily splice a string multiple times, using offsets into the original string

Latest version **1.0.0** (published 2018-02-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install multisplice
pnpm add multisplice
yarn add multisplice
bun add multisplice
```

## 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 | 2018-02-21 |
| First published | 2018-02-21 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 15 |
| Author | Renée Kooi |
| Maintainers | goto-bus-stop |
| Keywords | string, splice, replace |

## Links

- npm: https://www.npmjs.com/package/multisplice
- Repository: https://github.com/goto-bus-stop/multisplice
- Issues: https://github.com/goto-bus-stop/multisplice/issues
- npm.io page: https://npm.io/package/multisplice

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-02-21

## README

# multisplice

easily splice a string multiple times, using offsets into the original string

[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url]

[npm-image]: https://img.shields.io/npm/v/multisplice.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/multisplice
[travis-image]: https://img.shields.io/travis/goto-bus-stop/multisplice.svg?style=flat-square
[travis-url]: https://travis-ci.org/goto-bus-stop/multisplice
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard

## Install

```
npm install multisplice
```

## Usage

Renaming identifiers in Javascript code:

```js
var multisplice = require('./')
var dedent = require('dedent')
var astw = require('astw')

var src = dedent`
  function beep (boop) {
    boop *= baz
    console.log(boop)
  }
  var baz = 10
  beep(17)
`

var splicer = multisplice(src)
var renames = {}
var nextName = 'a'.charCodeAt()
astw(src)(function (node) {
  if (node.type === 'Identifier') {
    if (!renames[node.name]) renames[node.name] = String.fromCharCode(nextName++)

    splicer.splice(node.start, node.end, renames[node.name])
  }
})

console.log(splicer.toString())
```

```
function a (b) {
  b *= c
  d.e(b)
}
var c = 10
a(17)
```

## API

### `var s = multisplice(string)`

Create a string splicer instance. This instance will splice things into `string`.

### `s.splice(start, end, value)`

Replace the slice from indices `start` to `end` in the original string with `value`.

### `s.slice(start, end)`

Get a part of the spliced string, using indices `start` to `end` from the original string.

### `s.toString()`

Get the full spliced string (`.slice(0)`).

## License

[Apache-2.0](LICENSE.md)

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