Skip to content

Commit

Permalink
docs: fix error tag in the JSDoc 'throws' definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
M-Scott-Lassiter committed Apr 30, 2022
1 parent bb12de0 commit e7d0ac6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
17 changes: 9 additions & 8 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ console.log(encoder.dictionary) // 'ABCD'
encoder.dictionary = 'ABCDA' // Throws error because the letter 'A' is repeated
```

- Throws **any** Error if setting dictionary to `null`, `undefined` or empty string (i.e. `''`)
- Throws **any** Error if `newDictionary` contains a non-alphanumeric character
- Throws **any** Error if `newDictionary` has a repeating character
- Throws **[Error][13]** if setting dictionary to `null`, `undefined` or empty string (i.e. `''`)
- Throws **[Error][13]** if `newDictionary` contains a non-alphanumeric character
- Throws **[Error][13]** if `newDictionary` has a repeating character

Returns **[string][12]** (If used as getter) The current dictionary in use

Expand All @@ -59,7 +59,7 @@ Takes any number and converts it into a base (dictionary length) letter combo.

#### Parameters

- `integerToEncode` **[number][13]** Base 10 integer. If passed a non-integer number, decimal values are truncated.
- `integerToEncode` **[number][14]** Base 10 integer. If passed a non-integer number, decimal values are truncated.
Passing zero, negative numbers, or non-numbers will return `undefined`.

#### Examples
Expand Down Expand Up @@ -99,7 +99,7 @@ console.log(encoder.encode(null)) // undefined
console.log(encoder.encode(undefined)) // undefined
```

- Throws **any** Error if `integerToEncode` exceeds the maximum safe integer for Javascript (`2^53 - 1 = 9007199254740991`).
- Throws **[Error][13]** if `integerToEncode` exceeds the maximum safe integer for Javascript (`2^53 - 1 = 9007199254740991`).

Returns **[string][12]** Dictionary encoded value

Expand Down Expand Up @@ -137,9 +137,9 @@ console.log(encoder.decode('ADBAC')) // 551
console.log(encoder.decode('ANE')) // undefined
```

- Throws **any** Error if the decoded integer exceeds the maximum safe integer for Javascript (`2^53 - 1 = 9007199254740991`).
- Throws **[Error][13]** if the decoded integer exceeds the maximum safe integer for Javascript (`2^53 - 1 = 9007199254740991`).

Returns **[number][13]** Positive integer representation. If one of the characters is not present in the dictionary, it will return `undefined`.
Returns **[number][14]** Positive integer representation. If one of the characters is not present in the dictionary, it will return `undefined`.

[1]: #alphanumericencoder
[2]: #examples
Expand All @@ -153,4 +153,5 @@ Returns **[number][13]** Positive integer representation. If one of the characte
[10]: #parameters-2
[11]: #examples-3
[12]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
[14]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class AlphanumericEncoder {
* Returns or sets the current dictionary.
*
* @param {string} newDictionary (If setting) String of unique letters and numbers, in order, for the new dictionary
* @throws Error if setting dictionary to `null`, `undefined` or empty string (i.e. `''`)
* @throws Error if `newDictionary` contains a non-alphanumeric character
* @throws Error if `newDictionary` has a repeating character
* @throws {Error} if setting dictionary to `null`, `undefined` or empty string (i.e. `''`)
* @throws {Error} if `newDictionary` contains a non-alphanumeric character
* @throws {Error} if `newDictionary` has a repeating character
* @returns {string} (If used as getter) The current dictionary in use
* @default `ABCDEFGHIJKLMNOPQRSTUVWXYZ`
*
Expand Down Expand Up @@ -75,7 +75,7 @@ class AlphanumericEncoder {
*
* @param {number} integerToEncode Base 10 integer. If passed a non-integer number, decimal values are truncated.
* Passing zero, negative numbers, or non-numbers will return `undefined`.
* @throws Error if `integerToEncode` exceeds the maximum safe integer for Javascript (`2^53 - 1 = 9007199254740991`).
* @throws {Error} if `integerToEncode` exceeds the maximum safe integer for Javascript (`2^53 - 1 = 9007199254740991`).
* @returns {string} Dictionary encoded value
*
* @example
Expand Down Expand Up @@ -154,7 +154,7 @@ class AlphanumericEncoder {
*
* @param {string} stringToDecode If passed a non-integer number, decimal values are truncated.
* Passing an empty string, `null`, or `undefined` will return `undefined`.
* @throws Error if the decoded integer exceeds the maximum safe integer for Javascript (`2^53 - 1 = 9007199254740991`).
* @throws {Error} if the decoded integer exceeds the maximum safe integer for Javascript (`2^53 - 1 = 9007199254740991`).
* @returns {number} Positive integer representation. If one of the characters is not present in the dictionary, it will return `undefined`.
* @example
* const encoder = new AlphanumericEncoder()
Expand Down

0 comments on commit e7d0ac6

Please sign in to comment.