slice-all
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

slice-all

NPM TypeScript Coverage Status

Slice a string at multiple locations.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


Installation

yarn add slice-all
npm install slice-all
pnpm add slice-all

Usage

Slice at multiple locations:

import sliceAll from "slice-all";

sliceAll("20200101T123456", [4, 6, 8, 9, 11, 13]);

// => ["2020", "01", "01", "T", "12", "34", "56"]

Use negatives when index from left is unknown:

import sliceAll from "slice-all";

sliceAll("12-------------34", [2, -2]);

// => ["12", "-------------", "34"]

To specify segment lengths instead of indicies, use negatives:

import sliceAll from "slice-all";

sliceAll("20200101T123456", [-8, -1, -2, -2, -2])

// => ["20200101", "T", "12", "34", "56"]

Dev Dependencies

  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

License license

MIT

Package Sidebar

Install

npm i slice-all

Weekly Downloads

1

Version

2.0.0

License

MIT

Unpacked Size

4.29 kB

Total Files

8

Last publish

Collaborators

  • bconnorwhite