@ulisesgascon/string-to-array
A simple and opinionated way to convert a string to an array
About
A simple and opinionated way to convert a string to an array
❤️ Awesome Features:
- Simple and easy to use 🔥
- Typescript support 💪
- Zero dependencies 🚀
- Easy to use and great test coverage ✅
Installation
npm install @ulisesgascon/string-to-array
Usage
Simple example
Importation
const { stringToArray } = require("@ulisesgascon/string-to-array");
import { stringToArray } from "@ulisesgascon/string-to-array";
usage
const string = "hello,world";
console.log(stringToArray(string)); // ['hello', 'world']
// Use custom separator
const string = "hello+world";
console.log(stringToArray(string, "+")); // ['hello', 'world']
// Remove empty values
const people = "John, Lisa, , , James";
console.log(stringToArray(people)); // ['John', 'Lisa', 'James']
// Ignore blank spaces
const people = " John, Lisa , James ";
console.log(stringToArray(people)); // ['John', 'Lisa', 'James']
// Always return an array
const people = "";
console.log(stringToArray(people)); // []
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Ulises Gascón - Initial work- - @ulisesGascon
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- This project is under development, but you can help us to improve it! We ❤️ FOSS!