@ulisesgascon/string-to-array
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@ulisesgascon/string-to-array

A simple and opinionated way to convert a string to an array

npm version license downloads Known Vulnerabilities

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

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!

Package Sidebar

Install

npm i @ulisesgascon/string-to-array

Weekly Downloads

2

Version

2.0.0

License

MIT

Unpacked Size

6.8 kB

Total Files

9

Last publish

Collaborators

  • ulisesgascon