Skip to content

Commit

Permalink
docs: add some basic TSDoc comments for each function
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisalley committed Dec 27, 2024
1 parent 3ca3144 commit f0c787a
Show file tree
Hide file tree
Showing 14 changed files with 206 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
docs
*.local

# Editor directories and files
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"globals": "^15.14.0",
"husky": "^9.1.7",
"prettier": "^3.4.2",
"typedoc": "^0.27.6",
"typescript": "^5.7.2",
"typescript-eslint": "^8.18.2",
"vite": "^6.0.6",
Expand Down
120 changes: 118 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions src/camelise.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/**
* Converts a string of words to remove spaces and capitalise each word except
* for the first (lowerCamelCase). If the uppercaseFirstLetter parameter is set
* to true, then it produces the string in UpperCamelCase, also known as
* PascalCase.
* @param words - an underscore separated string to be converted to camelcase.
* @param uppercaseFirstLetter - if true, the first letter will be uppercase.
* @returns a camelcase version of words.
*/

export default function camelise(
words: string,
uppercaseFirstLetter: boolean = false
Expand Down
6 changes: 6 additions & 0 deletions src/dasherise.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Converts a string of words to a hyphen separated string (kebab-case).
*
* @param words - an underscore separated string to be converted to kebabcase.
* @returns a kebabcase version of words.
*/
export default function dasherise(words: string): string {
return words.replaceAll('_', '-')
}
6 changes: 6 additions & 0 deletions src/downcase-first.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Converts the first word of the string to start with a lowercase character.
*
* @param words - a space separated string.
* @returns a copy of words that starts with a lowercase character.
*/
export default function downcaseFirst(words: string): string {
return words
.split(' ')
Expand Down
10 changes: 10 additions & 0 deletions src/humanise.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* Converts a string of words to display better to end users by being space
* separated. If the uppercaseFirstLetter parameter is set to true, then the
* first letter of each word will also start with an uppercase letter.
*
* @param words - an underscore separated string to be made space separated.
* @param uppercaseFirstLetter - if true, the first letter of each word will be
* uppercase.
* @returns a space separated version of words.
*/
export default function humanise(
words: string,
uppercaseFirstLetter: boolean = false
Expand Down
7 changes: 7 additions & 0 deletions src/ordinal.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Returns the suffix that can be added to a number to indicate the position in
* an ordered sequence, for example 1st, 42nd, or 111th.
*
* @param number - the number to determine the ordinal suffix of.
* @returns - the ordinal suffix that will be st, nd, rd, or th.
*/
export default function ordinal(number: number): string {
switch (number % 10) {
case 1:
Expand Down
Loading

0 comments on commit f0c787a

Please sign in to comment.