Divider is a powerful utility for dividing strings or string arrays using predetermined indexes or delimiters. It provides an easy-to-use interface for seamless integration with NPM, Deno, and Bun, making it versatile and accessible across various JavaScript environments. Perfect for developers seeking a straightforward solution to string manipulation.
The Divider is a versatile utility designed to split strings or arrays of strings using specified index positions or custom delimiters. This straightforward tool simplifies the process of dividing text data, making it ideal for various applications such as data parsing, formatting, and manipulation.
dividerFirst() and dividerLast() to easily access first or last elements from the divided results.dividerLoop() for chunked division of strings into specified sizes.dividerNumberString() function allows for separating numbers and letters within strings.import { divider } from '@nyaomaru/divider';
// Divide a string by index positions
const helloArray = divider('hello', 1, 3);
// Result: ['h', 'el', 'lo']
// Divide a string using a character separator
const divideWithString = divider('hello', 'e');
// Result: ['h', 'llo']
// Mixed usage of indexes and characters
const complexDivide = divider('hello world', 3, 'o');
// Result: ['hel', 'l', ' w', 'rld']
// Flattening nested results
const flatArray = divider(['hello', 'new world'], ' ', 2, { flatten: true });
// Result: ['he', 'llo', 'ne', 'w', 'wor', 'ld']
Divider also includes several presets for common tasks:
emailDivider: Splits emails into local-part and domain.csvDivider: Handles comma-separated values with consideration for quoted fields.pathDivider: Splits file paths by / or \.To integrate the Divider into a project, it is available for installation via popular package managers:
npm install @nyaomaru/dividerpnpm install @nyaomaru/divideryarn add @nyaomaru/dividerFor detailed documentation and API references, visit the official Divider Docs or the API Reference.
No comments yet.
Sign in to be the first to comment.