Skip to content

Commit 8f9dd71

Browse files
committed
🐢 correct fields for jsdocSymbols(), exportSymbols()
1 parent bb9ebc4 commit 8f9dd71

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "extra-javascript-text",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Utilities for processing JavaScript text.",
55
"main": "index.js",
66
"module": "index.mjs",

src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ const RJSDOCSYMBOL = /(\/\*\*[\s\S]*?\*\/)(?:\s+(?:(export)\s+(?:(default)\s+)?)
227227
/**
228228
* JSDoc symbol match function.
229229
* @param full full jsdoc symbol match
230+
* @param jsdoc jsdoc attached to symbol
230231
* @param name symbol name
231232
* @param kind symbol kind
232233
* @param isExported symbol is exported?
233234
* @param isDefault symbol is default?
234-
* @param jsdoc jsdoc attached to symbol
235235
*/
236-
export type JsdocSymbolMatchFunction = (full: string, name: string, kind: string, isExported: boolean, isDefault: boolean, jsdoc: string) => void;
236+
export type JsdocSymbolMatchFunction = (full: string, jsdoc: string, name: string, kind: string, isExported: boolean, isDefault: boolean) => void;
237237

238238
/**
239239
* Match jsdoc symbols in javascript text.
@@ -243,14 +243,16 @@ export type JsdocSymbolMatchFunction = (full: string, name: string, kind: string
243243
export function forEachJsdocSymbol(txt: string, fn: JsdocSymbolMatchFunction): void {
244244
var txt = replaceStrings(txt, () => '"AUTO_STRING"'), m = null;
245245
while ((m = RJSDOCSYMBOL.exec(txt)) != null)
246-
fn(m[0], m[5] || "", (m[4] || "").replace(/\s+/g, " "), m[2] === "export", m[3] === "default", m[1] || "");
246+
fn(m[0], m[1] || "", m[5] || "", (m[4] || "").replace(/\s+/g, " "), m[2] === "export", m[3] === "default");
247247
}
248248

249249

250250
/** JSDoc symbol. */
251251
export interface JsdocSymbol {
252252
/** Full jsdoc symbol match. */
253253
full: string,
254+
/** JSDoc attached to symbol. */
255+
jsdoc: string,
254256
/** Symbol name. */
255257
name: string,
256258
/** Symbol kind. */
@@ -259,8 +261,6 @@ export interface JsdocSymbol {
259261
isExported: boolean,
260262
/** Symbol is default? */
261263
isDefault: boolean,
262-
/** JSDoc attached to symbol. */
263-
jsdoc: string,
264264
}
265265

266266
/**
@@ -270,8 +270,8 @@ export interface JsdocSymbol {
270270
*/
271271
export function jsdocSymbols(txt: string): JsdocSymbol[] {
272272
var a = [];
273-
forEachJsdocSymbol(txt, (full, name, kind, _export, _default, jsdoc) => {
274-
a.push({full, name, kind, export: _export, default: _default, jsdoc});
273+
forEachJsdocSymbol(txt, (full, jsdoc, name, kind, isExported, isDefault) => {
274+
a.push({full, jsdoc, name, kind, isExported, isDefault});
275275
});
276276
return a;
277277
}
@@ -280,14 +280,14 @@ export function jsdocSymbols(txt: string): JsdocSymbol[] {
280280
/**
281281
* Jsdoc symbol replace function.
282282
* @param full full jsdoc symbol match
283+
* @param jsdoc jsdoc attached to symbol
283284
* @param name symbol name
284285
* @param kind symbol kind
285286
* @param isExported symbol is exported?
286287
* @param isDefault symbol is default?
287-
* @param jsdoc jsdoc attached to symbol
288288
* @returns updated jsdoc symbol
289289
*/
290-
export type JsdocSymbolReplaceFunction = (full: string, name: string, kind: string, isExported: boolean, isDefault: boolean, jsdoc: string) => string;
290+
export type JsdocSymbolReplaceFunction = (full: string, jsdoc: string, name: string, kind: string, isExported: boolean, isDefault: boolean) => string;
291291

292292
/**
293293
* Replace jsdoc symbols in javascript text.
@@ -298,7 +298,7 @@ export type JsdocSymbolReplaceFunction = (full: string, name: string, kind: stri
298298
export function replaceJsdocSymbols(txt: string, fn: JsdocSymbolReplaceFunction): string {
299299
var [txt, tags] = tagStrings(txt);
300300
txt = txt.replace(RJSDOCSYMBOL, (m, p1, p2, p3, p4, p5) => {
301-
return fn(m, p5 || "", (p4 || "").replace(/\s+/g, " "), p2 === "export", p3 === "default", p1 || "");
301+
return fn(m, p1 || "", p5 || "", (p4 || "").replace(/\s+/g, " "), p2 === "export", p3 === "default");
302302
});
303303
return untagStrings(txt, tags);
304304
}
@@ -354,8 +354,8 @@ export interface ExportSymbol {
354354
*/
355355
export function exportSymbols(txt: string): ExportSymbol[] {
356356
var a = [];
357-
forEachExportSymbol(txt, (full, name, kind, _default) => {
358-
a.push({full, name, kind, default: _default});
357+
forEachExportSymbol(txt, (full, name, kind, isDefault) => {
358+
a.push({full, name, kind, isDefault});
359359
});
360360
return a;
361361
}

0 commit comments

Comments
 (0)