You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{pipe,toLower,split,join,filter}from'ramda';constrandomChars=n=>Math.random().toString(36).split('').slice(-(n)).join('');conststripInvalid=str=>str.replace(/[^a-zA-Z0-9-]/g,'');constremoveDashes=x=>x!=='–'&&x!=='-';constexists=x=>x!==undefined&&x!==null;consttoString=s=>exists(s) ? `${s}` : randomChars(7);/** * toSlug * Takes a string and converts it into a URL-safe string, * replacing spaces with dashes, removing capitalized letters, and * stripping unsafe characters out. * * @param {(string|number)} s A string to slugify * @return {string} A slugified string */consttoSlug=s=>pipe(toString,toLower,split(' '),filter(removeDashes),join('-'),stripInvalid)(s);exportdefaulttoSlug;
I get the following output:
toSlug(s) ⇒ string
toSlug
Takes a string and converts it into a URL-safe string,
replacing spaces with dashes, removing capitalized letters, and
stripping unsafe characters out.
Kind: global function Returns: string - A slugified string
Param
Type
Description
s
string | number
A string to slugify
Clearly, the kind should not be global function because the function is not global. It's scoped within a module. If I add module to the top of the file, it gets worse: Now it assumes it's a method. It's not. It's just a function. Not a global, not a method, not a class. Just a function. If I annotate it with @kind function it still says, Kind: global function.
The text was updated successfully, but these errors were encountered:
jsdoc2md src/lib/to-slug/index.js | sed '/\*\*Kind\*\*/d'
Produces:
toSlug(s) ⇒ string
toSlug takes a string and converts it into a URL-safe string,
replacing spaces with dashes, removing capitalized letters, and
stripping unsafe characters out.
True, that function is module scope, not global. In which case you should have a @module tag defined but as you say, the module-scope function is then described as a "method" which it is not.
I think the "method" text is a legacy thing stemming from the old days when functions were exported by attaching them as a method to the Node.js global exports object. Before ES Modules, functions were literally exported as a method in Node.js.
Given this input:
I get the following output:
toSlug(s) ⇒
string
toSlug
Takes a string and converts it into a URL-safe string,
replacing spaces with dashes, removing capitalized letters, and
stripping unsafe characters out.
Kind: global function
Returns:
string
- A slugified stringstring
|number
Clearly, the
kind
should not beglobal function
because the function is not global. It's scoped within a module. If I add module to the top of the file, it gets worse: Now it assumes it's a method. It's not. It's just a function. Not a global, not a method, not a class. Just a function. If I annotate it with@kind function
it still says,Kind: global function
.The text was updated successfully, but these errors were encountered: