Split Lines is a JavaScript extension that splits strings into arrays by line, with the option to include or remove line break characters. It is as similar as possible to splitlines()
in Python.
Split Lines offers the following features:
- Splits strings into arrays based on line breaks.
- There is an option to include or omit line breaks in the results.
- Can be integrated into TypeScript code.
To install Split Lines locally, follow these installation steps:
npm install @barudakrosul/split-lines
To start using Split Lines, import the module first:
1. CommonJS
require("@barudakrosul/split-lines");
2. ESM (ECMAScript Modules)
import "@barudakrosul/split-lines";
3. TypeScript
import "@barudakrosul/split-lines";
Example of usage:
let text = "List fruit names:\nApple\nBanana\nAvocado\nPapaya\nBlueBerry\netc.";
console.log(text.splitLines());
// Result:
// [
// 'List fruit names:',
// 'Apple',
// 'Banana',
// 'Avocado',
// 'Papaya',
// 'BlueBerry',
// 'etc.'
// ]
Example if the keeplinebreaks
option is set to true
:
let text = "List fruit names:\nApple\nBanana\nAvocado\nPapaya\nBlueBerry\netc.";
console.log(text.splitLines(true));
// Result:
// [
// 'List fruit names:\n',
// 'Apple\n',
// 'Banana\n',
// 'Avocado\n',
// 'Papaya\n',
// 'BlueBerry\n',
// 'etc.'
// ]
Contributions to Split Lines are greatly appreciated! Whether reporting bugs, suggesting new features, or contributing to code improvements.
Split Lines is licensed under the Apache-2.0 License - see the LICENSE file for details.
Split Lines appreciates the support and contributions of the following individuals and open source projects:
- @FajarKim - Lead developer and creator of the application.
- Open source community - For valuable contributions to the tools and libraries used in this project.
We really appreciate your support to continue developing this project. If you find this project useful, you can support us with a donation:
Every donation, no matter the amount, means a lot to us. Thank you for your support! ❤️
Keep up with the latest changes and updates of Split Lines by referring to Changelog.
Thank you for choosing Split Lines! We aim to provide an easy solution to convert strings into arrays based on line breaks.