Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds jsDoc comments and cleans up JS logic #74

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

tif-calin
Copy link

Summary

  • adds jsDoc comments. If you've used TypeScript before it's essentially that but as simple JS comments. IDEs pick up on it and use it to provide type information and additional comments (see screenshots)
  • cleans up JS logic. This is a bit subjective but I found parts of it hard to parse and tried to update it to make more sense and be in line with professional js style guides like airbnb's JS linter
  • updates the package-lock.json. The old one was generated with an older version of npm and it was recommended to update it

Screenshots

IDE picks up comments and parameter types

image

IDE provides autocomplete for available config properties

image

IDE provides typehints for available config properties

image

*
* @param {number[] | number[][]} series - if an array of numbers is passed in, it will be transformed into an array of a single series
* @param {Config} [cfg={}] - configuration object
* @returns {string}
Copy link
Author

@tif-calin tif-calin Nov 20, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS we could also add @example like

/**
 * @example  
 * ```
 * const arr = [34, 58, 12, 29, 2];
 * 
 * asciichart.plot(arr, {
 *   format: x => `${Math.round(x) / 100}%`
 * });
 * 
 * @example plot('foobar'.split('').map(c => c.charCodeAt(0))
 * ```
 */

Wow GitHub even has syntax highlighting for jsDoc comments. Wild

@kroitor kroitor self-assigned this Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants