UNPKG

@azizbecha/strkit

Version:

strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.

16 lines (15 loc) 516 B
/** * Compares two strings and returns an array of differences * * @param str1 - First string * @param str2 - Second string * @returns Array of difference objects * * @example * diffStrings('hello world', 'hello there'); // [{ type: 'equal', value: 'hello ' }, { type: 'removed', value: 'world' }, { type: 'added', value: 'there' }] */ export interface StringDiff { type: 'equal' | 'added' | 'removed'; value: string; } export default function diffStrings(str1: string, str2: string): StringDiff[];