string-to
v0.0.1
Published
Convert string to any type of array.
Downloads
15
Maintainers
Readme
string-to
Convert string to any type of array.
🚀 Features
- ✨ Type-safe - Full TypeScript support with generics
- 🪶 Lightweight - Zero dependencies
- 🎯 Simple API - Easy to use, intuitive interface
- 🔧 Flexible - Support for nested keys and custom key functions
- 📦 Tree-shakeable - ESM support for optimal bundle size
📦 Installation
npm install string-toor
yarn add string-to🔨 Usage
Basic Usage
import { toArrayNumber, toArrayString } from 'string-to';
const array_str = '1,2,3,4,5'
const separator = ','
const array_number = toArrayNumber(array_str, separator)
console.log(array_number) // [1,2,3,4,5]
const array_str = 'Alice,Bob,Charlie,David,Emma'
const separator = ','
const array_string = toArrayString(array_str, separator)
console.log(array_string) // ['Alice','Bob','Charlie','David','Emma']With Custom Separator
import { toArrayNumber, toArrayString } from 'string-to';
const array_str = 'ids=1&ids=2&ids=3&ids=4'
const separator = '&ids='
const array_number = toArrayNumber(array_str, separator)
console.log(array_number) // [1,2,3,4]🏗️ Development
# Install dependencies
yarn install
# Run in development mode
yarn dev
# Build the package
yarn build
# Run tests
yarn test🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the ISC License - see the LICENSE file for details.
👤 Author
andreyalth
Made with ❤️ using TypeScript
