From 8b381de70cfcb4e7b502918be030b8be9a4ddd7b Mon Sep 17 00:00:00 2001 From: leejooy96 Date: Mon, 16 Sep 2024 14:32:02 +0900 Subject: [PATCH] docs: add `dart` methods --- docs/src/en/dart/api/string.md | 183 ++++++++++++++++++++++++++++++++- docs/src/ko/dart/api/string.md | 183 ++++++++++++++++++++++++++++++++- 2 files changed, 358 insertions(+), 8 deletions(-) diff --git a/docs/src/en/dart/api/string.md b/docs/src/en/dart/api/string.md index 6510dcf..f7b279f 100644 --- a/docs/src/en/dart/api/string.md +++ b/docs/src/en/dart/api/string.md @@ -5,6 +5,89 @@ order: 3 # API: String +## `trim` + +Removes all whitespace before and after a string. Unlike JavaScript's `trim` function, it converts two or more spaces between sentences into a single space. + +### Parameters + +- `str::string` + +### Returns + +> string + +### Examples + +```dart +trim(' Hello Wor ld '); // Returns 'Hello Wor ld' +trim('H e l l o World'); // Returns 'H e l l o World' +``` + +## `removeSpecialChar` + +Returns after removing all special characters, including spaces. If you want to allow any special characters as exceptions, list them in the second argument value without delimiters. For example, if you want to allow spaces and the symbols `&` and `*`, the second argument value would be ' &\*'. + +### Parameters + +- `str::string` (Positional) +- Named: `exceptionCharacters::string?` + +### Returns + +> string + +### Examples + +```dart +removeSpecialChar('Hello-qsu, World!'); // Returns 'HelloqsuWorld' +removeSpecialChar('Hello-qsu, World!', exceptionCharacters: ' -'); // Returns 'Hello-qsu World' +``` + +## `removeNewLine` + +Removes `\n`, `\r` characters or replaces them with specified characters. + +### Parameters + +- `str::string` +- Named: `replaceTo::string || ''` + +### Returns + +> string + +### Examples + +```dart +removeNewLine('ab\ncd'); // Returns 'abcd' +removeNewLine('ab\r\ncd', replaceTo: '-'); // Returns 'ab-cd' +``` + +## `replaceBetween` + +Replaces text within a range starting and ending with a specific character in a given string with another string. For example, given the string `abcghi`, to change `` to `def`, use `replaceBetween('abcghi', '<', '>', 'def')`. The result would be `abcdefghi`. + +Deletes strings in the range if `replaceWith` is not specified. + +### Parameters + +- `str::string` +- `startChar::string` +- `endChar::string` +- `replaceWith::string || ''` + +### Returns + +> string + +### Examples + +```dart +replaceBetween('ab[c]d[e]f', '[', ']'); // Returns 'abdf' +replaceBetween('abcd:replace:', ':', ':', 'e'); // Returns 'abcde' +``` + ## `capitalizeFirst` Converts the first letter of the entire string to uppercase and returns. @@ -23,18 +106,110 @@ Converts the first letter of the entire string to uppercase and returns. capitalizeFirst('abcd'); // Returns 'Abcd' ``` -## `truncate` +## `capitalizeEverySentence` -Truncates a long string to a specified length, optionally appending an ellipsis after the string. +Capitalize the first letter of every sentence. Typically, the `.` characters to separate sentences, but this can be customized via the value of the `splitChar` argument. + +### Parameters + +- `str::string` +- Named: `splitChar::string` + +### Returns + +> string + +### Examples + +```dart +capitalizeEverySentence('hello. world. hi.'); // Returns 'Hello. World. Hi.' +capitalizeEverySentence('hello!world', splitChar: '!'); // Returns 'Hello!World' +``` + +## `capitalizeEachWords` + +Converts every word with spaces to uppercase. If the naturally argument is true, only some special cases (such as prepositions) are kept lowercase. + +### Parameters + +- `str::string` +- Named: `natural::boolean || false` + +### Returns + +> string + +### Examples + +```dart +capitalizeEachWords('abcd'); // Returns 'Abcd' +``` + +## `strCount` + +Returns the number of times the second String argument is contained in the first String argument. + +### Parameters + +- `str::string` +- `search::string` + +### Returns + +> number + +### Examples + +```dart +strCount('abcabc', 'a'); // Returns 2 +``` + +## `strShuffle` + +Randomly shuffles the received string and returns it. ### Parameters - `str::string` + +### Returns + +> string + +### Examples + +```dart +strShuffle('abcdefg'); // Returns 'bgafced' +``` + +## `strRandom` + +Returns a random String containing numbers or uppercase and lowercase letters of the given length. The default return length is 12. + +### Parameters + - `length::number` +- Named: `additionalCharacters::string?` + +### Returns + +> string -### Optional Parameters +### Examples + +```dart +strRandom(5); // Returns 'CHy2M' +``` -- `ellipsis::string || ''` +## `truncate` + +Truncates a long string to a specified length, optionally appending an ellipsis after the string. + +### Parameters + +- `str::string` +- `length::number` +- Named: `ellipsis::string || ''` ### Returns diff --git a/docs/src/ko/dart/api/string.md b/docs/src/ko/dart/api/string.md index 6510dcf..f7b279f 100644 --- a/docs/src/ko/dart/api/string.md +++ b/docs/src/ko/dart/api/string.md @@ -5,6 +5,89 @@ order: 3 # API: String +## `trim` + +Removes all whitespace before and after a string. Unlike JavaScript's `trim` function, it converts two or more spaces between sentences into a single space. + +### Parameters + +- `str::string` + +### Returns + +> string + +### Examples + +```dart +trim(' Hello Wor ld '); // Returns 'Hello Wor ld' +trim('H e l l o World'); // Returns 'H e l l o World' +``` + +## `removeSpecialChar` + +Returns after removing all special characters, including spaces. If you want to allow any special characters as exceptions, list them in the second argument value without delimiters. For example, if you want to allow spaces and the symbols `&` and `*`, the second argument value would be ' &\*'. + +### Parameters + +- `str::string` (Positional) +- Named: `exceptionCharacters::string?` + +### Returns + +> string + +### Examples + +```dart +removeSpecialChar('Hello-qsu, World!'); // Returns 'HelloqsuWorld' +removeSpecialChar('Hello-qsu, World!', exceptionCharacters: ' -'); // Returns 'Hello-qsu World' +``` + +## `removeNewLine` + +Removes `\n`, `\r` characters or replaces them with specified characters. + +### Parameters + +- `str::string` +- Named: `replaceTo::string || ''` + +### Returns + +> string + +### Examples + +```dart +removeNewLine('ab\ncd'); // Returns 'abcd' +removeNewLine('ab\r\ncd', replaceTo: '-'); // Returns 'ab-cd' +``` + +## `replaceBetween` + +Replaces text within a range starting and ending with a specific character in a given string with another string. For example, given the string `abcghi`, to change `` to `def`, use `replaceBetween('abcghi', '<', '>', 'def')`. The result would be `abcdefghi`. + +Deletes strings in the range if `replaceWith` is not specified. + +### Parameters + +- `str::string` +- `startChar::string` +- `endChar::string` +- `replaceWith::string || ''` + +### Returns + +> string + +### Examples + +```dart +replaceBetween('ab[c]d[e]f', '[', ']'); // Returns 'abdf' +replaceBetween('abcd:replace:', ':', ':', 'e'); // Returns 'abcde' +``` + ## `capitalizeFirst` Converts the first letter of the entire string to uppercase and returns. @@ -23,18 +106,110 @@ Converts the first letter of the entire string to uppercase and returns. capitalizeFirst('abcd'); // Returns 'Abcd' ``` -## `truncate` +## `capitalizeEverySentence` -Truncates a long string to a specified length, optionally appending an ellipsis after the string. +Capitalize the first letter of every sentence. Typically, the `.` characters to separate sentences, but this can be customized via the value of the `splitChar` argument. + +### Parameters + +- `str::string` +- Named: `splitChar::string` + +### Returns + +> string + +### Examples + +```dart +capitalizeEverySentence('hello. world. hi.'); // Returns 'Hello. World. Hi.' +capitalizeEverySentence('hello!world', splitChar: '!'); // Returns 'Hello!World' +``` + +## `capitalizeEachWords` + +Converts every word with spaces to uppercase. If the naturally argument is true, only some special cases (such as prepositions) are kept lowercase. + +### Parameters + +- `str::string` +- Named: `natural::boolean || false` + +### Returns + +> string + +### Examples + +```dart +capitalizeEachWords('abcd'); // Returns 'Abcd' +``` + +## `strCount` + +Returns the number of times the second String argument is contained in the first String argument. + +### Parameters + +- `str::string` +- `search::string` + +### Returns + +> number + +### Examples + +```dart +strCount('abcabc', 'a'); // Returns 2 +``` + +## `strShuffle` + +Randomly shuffles the received string and returns it. ### Parameters - `str::string` + +### Returns + +> string + +### Examples + +```dart +strShuffle('abcdefg'); // Returns 'bgafced' +``` + +## `strRandom` + +Returns a random String containing numbers or uppercase and lowercase letters of the given length. The default return length is 12. + +### Parameters + - `length::number` +- Named: `additionalCharacters::string?` + +### Returns + +> string -### Optional Parameters +### Examples + +```dart +strRandom(5); // Returns 'CHy2M' +``` -- `ellipsis::string || ''` +## `truncate` + +Truncates a long string to a specified length, optionally appending an ellipsis after the string. + +### Parameters + +- `str::string` +- `length::number` +- Named: `ellipsis::string || ''` ### Returns