README
Slice a string at multiple locations.
Installation
yarn add slice-all
npm install slice-all
API
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
- @bconnorwhite/bob: Bob is a toolkit for TypeScript projects