comment-parser 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +50 -2
  2. package/es6/parser/tokenizers/name.js +11 -3
  3. package/es6/parser/tokenizers/tag.js +3 -0
  4. package/es6/parser/tokenizers/type.d.ts +1 -1
  5. package/es6/parser/tokenizers/type.js +15 -3
  6. package/es6/primitives.js +1 -1
  7. package/jest.config.cjs +5 -7
  8. package/package.json +14 -10
  9. package/src/parser/tokenizers/name.ts +13 -3
  10. package/src/parser/tokenizers/tag.ts +4 -0
  11. package/src/parser/tokenizers/type.ts +16 -3
  12. package/tests/unit/parser.spec.ts +234 -0
  13. package/tests/unit/spec-tag-tokenizer.spec.ts +30 -0
  14. package/tsconfig.node.json +0 -1
  15. package/browser/index.js +0 -650
  16. package/lib/index.cjs +0 -88
  17. package/lib/index.cjs.map +0 -1
  18. package/lib/index.d.ts +0 -32
  19. package/lib/parser/block-parser.cjs +0 -44
  20. package/lib/parser/block-parser.cjs.map +0 -1
  21. package/lib/parser/block-parser.d.ts +0 -24
  22. package/lib/parser/index.cjs +0 -65
  23. package/lib/parser/index.cjs.map +0 -1
  24. package/lib/parser/index.d.ts +0 -11
  25. package/lib/parser/source-parser.cjs +0 -68
  26. package/lib/parser/source-parser.cjs.map +0 -1
  27. package/lib/parser/source-parser.d.ts +0 -7
  28. package/lib/parser/spec-parser.cjs +0 -29
  29. package/lib/parser/spec-parser.cjs.map +0 -1
  30. package/lib/parser/spec-parser.d.ts +0 -7
  31. package/lib/parser/tokenizers/description.cjs +0 -62
  32. package/lib/parser/tokenizers/description.cjs.map +0 -1
  33. package/lib/parser/tokenizers/description.d.ts +0 -20
  34. package/lib/parser/tokenizers/index.cjs +0 -6
  35. package/lib/parser/tokenizers/index.cjs.map +0 -1
  36. package/lib/parser/tokenizers/index.d.ts +0 -7
  37. package/lib/parser/tokenizers/name.cjs +0 -109
  38. package/lib/parser/tokenizers/name.cjs.map +0 -1
  39. package/lib/parser/tokenizers/name.d.ts +0 -6
  40. package/lib/parser/tokenizers/tag.cjs +0 -37
  41. package/lib/parser/tokenizers/tag.cjs.map +0 -1
  42. package/lib/parser/tokenizers/tag.d.ts +0 -6
  43. package/lib/parser/tokenizers/type.cjs +0 -79
  44. package/lib/parser/tokenizers/type.cjs.map +0 -1
  45. package/lib/parser/tokenizers/type.d.ts +0 -27
  46. package/lib/primitives.cjs +0 -17
  47. package/lib/primitives.cjs.map +0 -1
  48. package/lib/primitives.d.ts +0 -54
  49. package/lib/stringifier/index.cjs +0 -18
  50. package/lib/stringifier/index.cjs.map +0 -1
  51. package/lib/stringifier/index.d.ts +0 -3
  52. package/lib/stringifier/inspect.cjs +0 -72
  53. package/lib/stringifier/inspect.cjs.map +0 -1
  54. package/lib/stringifier/inspect.d.ts +0 -2
  55. package/lib/transforms/align.cjs +0 -127
  56. package/lib/transforms/align.cjs.map +0 -1
  57. package/lib/transforms/align.d.ts +0 -3
  58. package/lib/transforms/crlf.cjs +0 -44
  59. package/lib/transforms/crlf.cjs.map +0 -1
  60. package/lib/transforms/crlf.d.ts +0 -3
  61. package/lib/transforms/indent.cjs +0 -58
  62. package/lib/transforms/indent.cjs.map +0 -1
  63. package/lib/transforms/indent.d.ts +0 -2
  64. package/lib/transforms/index.cjs +0 -13
  65. package/lib/transforms/index.cjs.map +0 -1
  66. package/lib/transforms/index.d.ts +0 -3
  67. package/lib/util.cjs +0 -113
  68. package/lib/util.cjs.map +0 -1
  69. package/lib/util.d.ts +0 -21
@@ -1,44 +0,0 @@
1
- "use strict";
2
-
3
- var __rest = this && this.__rest || function (s, e) {
4
- var t = {};
5
-
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
7
-
8
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
-
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
-
18
- const util_js_1 = require("../util.cjs");
19
-
20
- const order = ['end', 'description', 'postType', 'type', 'postName', 'name', 'postTag', 'tag', 'postDelimiter', 'delimiter', 'start'];
21
-
22
- function crlf(ending) {
23
- function update(line) {
24
- return Object.assign(Object.assign({}, line), {
25
- tokens: Object.assign(Object.assign({}, line.tokens), {
26
- lineEnd: ending === 'LF' ? '' : '\r'
27
- })
28
- });
29
- }
30
-
31
- return _a => {
32
- var {
33
- source
34
- } = _a,
35
- fields = __rest(_a, ["source"]);
36
-
37
- return (0, util_js_1.rewireSource)(Object.assign(Object.assign({}, fields), {
38
- source: source.map(update)
39
- }));
40
- };
41
- }
42
-
43
- exports.default = crlf;
44
- //# sourceMappingURL=crlf.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["crlf.js"],"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","defineProperty","exports","value","util_js_1","require","order","crlf","ending","update","line","assign","tokens","lineEnd","_a","source","fields","rewireSource","map","default"],"mappings":"AAAA;;AACA,IAAIA,MAAM,GAAI,QAAQ,KAAKA,MAAd,IAAyB,UAAUC,CAAV,EAAaC,CAAb,EAAgB;AAClD,MAAIC,CAAC,GAAG,EAAR;;AACA,OAAK,IAAIC,CAAT,IAAcH,CAAd,EAAiB,IAAII,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCP,CAArC,EAAwCG,CAAxC,KAA8CF,CAAC,CAACO,OAAF,CAAUL,CAAV,IAAe,CAAjE,EACbD,CAAC,CAACC,CAAD,CAAD,GAAOH,CAAC,CAACG,CAAD,CAAR;;AACJ,MAAIH,CAAC,IAAI,IAAL,IAAa,OAAOI,MAAM,CAACK,qBAAd,KAAwC,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AAQ;AACX,QAAI;AAAEC,MAAAA;AAAF,QAAaD,EAAjB;AAAA,QAAqBE,MAAM,GAAG7B,MAAM,CAAC2B,EAAD,EAAK,CAAC,QAAD,CAAL,CAApC;;AACA,WAAO,CAAC,GAAGV,SAAS,CAACa,YAAd,EAA4BzB,MAAM,CAACmB,MAAP,CAAcnB,MAAM,CAACmB,MAAP,CAAc,EAAd,EAAkBK,MAAlB,CAAd,EAAyC;AAAED,MAAAA,MAAM,EAAEA,MAAM,CAACG,GAAP,CAAWT,MAAX;AAAV,KAAzC,CAA5B,CAAP;AACH,GAHD;AAIH;;AACDP,OAAO,CAACiB,OAAR,GAAkBZ,IAAlB","sourcesContent":["\"use strict\";\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst util_js_1 = require(\"../util.js\");\nconst order = [\n 'end',\n 'description',\n 'postType',\n 'type',\n 'postName',\n 'name',\n 'postTag',\n 'tag',\n 'postDelimiter',\n 'delimiter',\n 'start',\n];\nfunction crlf(ending) {\n function update(line) {\n return Object.assign(Object.assign({}, line), { tokens: Object.assign(Object.assign({}, line.tokens), { lineEnd: ending === 'LF' ? '' : '\\r' }) });\n }\n return (_a) => {\n var { source } = _a, fields = __rest(_a, [\"source\"]);\n return (0, util_js_1.rewireSource)(Object.assign(Object.assign({}, fields), { source: source.map(update) }));\n };\n}\nexports.default = crlf;\n"],"file":"crlf.cjs"}
@@ -1,3 +0,0 @@
1
- import { Transform } from './index.js';
2
- export type Ending = 'LF' | 'CRLF';
3
- export default function crlf(ending: Ending): Transform;
@@ -1,58 +0,0 @@
1
- "use strict";
2
-
3
- var __rest = this && this.__rest || function (s, e) {
4
- var t = {};
5
-
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
7
-
8
- if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
9
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
-
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
-
18
- const util_js_1 = require("../util.cjs");
19
-
20
- const pull = offset => str => str.slice(offset);
21
-
22
- const push = offset => {
23
- const space = ''.padStart(offset, ' ');
24
- return str => str + space;
25
- };
26
-
27
- function indent(pos) {
28
- let shift;
29
-
30
- const pad = start => {
31
- if (shift === undefined) {
32
- const offset = pos - start.length;
33
- shift = offset > 0 ? push(offset) : pull(-offset);
34
- }
35
-
36
- return shift(start);
37
- };
38
-
39
- const update = line => Object.assign(Object.assign({}, line), {
40
- tokens: Object.assign(Object.assign({}, line.tokens), {
41
- start: pad(line.tokens.start)
42
- })
43
- });
44
-
45
- return _a => {
46
- var {
47
- source
48
- } = _a,
49
- fields = __rest(_a, ["source"]);
50
-
51
- return (0, util_js_1.rewireSource)(Object.assign(Object.assign({}, fields), {
52
- source: source.map(update)
53
- }));
54
- };
55
- }
56
-
57
- exports.default = indent;
58
- //# sourceMappingURL=indent.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["indent.js"],"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","defineProperty","exports","value","util_js_1","require","pull","offset","str","slice","push","space","padStart","indent","pos","shift","pad","start","undefined","update","line","assign","tokens","_a","source","fields","rewireSource","map","default"],"mappings":"AAAA;;AACA,IAAIA,MAAM,GAAI,QAAQ,KAAKA,MAAd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AlB","sourcesContent":["\"use strict\";\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst util_js_1 = require(\"../util.js\");\nconst pull = (offset) => (str) => str.slice(offset);\nconst push = (offset) => {\n const space = ''.padStart(offset, ' ');\n return (str) => str + space;\n};\nfunction indent(pos) {\n let shift;\n const pad = (start) => {\n if (shift === undefined) {\n const offset = pos - start.length;\n shift = offset > 0 ? push(offset) : pull(-offset);\n }\n return shift(start);\n };\n const update = (line) => (Object.assign(Object.assign({}, line), { tokens: Object.assign(Object.assign({}, line.tokens), { start: pad(line.tokens.start) }) }));\n return (_a) => {\n var { source } = _a, fields = __rest(_a, [\"source\"]);\n return (0, util_js_1.rewireSource)(Object.assign(Object.assign({}, fields), { source: source.map(update) }));\n };\n}\nexports.default = indent;\n"],"file":"indent.cjs"}
@@ -1,2 +0,0 @@
1
- import { Transform } from './index.js';
2
- export default function indent(pos: number): Transform;
@@ -1,13 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.flow = void 0;
7
-
8
- function flow(...transforms) {
9
- return block => transforms.reduce((block, t) => t(block), block);
10
- }
11
-
12
- exports.flow = flow;
13
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["index.js"],"names":["Object","defineProperty","exports","value","flow","transforms","block","reduce","t"],"mappings":"AAAA;;AACAA,MAAM,CAACC,cAAP,CAAsBC,OAAtB,EAA+B,YAA/B,EAA6C;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAA7C;AACAD,OAAO,CAACE,IAAR,GAAe,KAAK,CAApB;;AACA,SAASA,IAAT,CAAc,GAAGC,UAAjB,EAA6B;AACzB,SAAQC,KAAD,IAAWD,UAAU,CAACE,MAAX,CAAkB,CAACD,KAAD,EAAQE,CAAR,KAAcA,CAAC,CAACF,KAAD,CAAjC,EAA0CA,KAA1C,CAAlB;AACH;;AACDJ,OAAO,CAACE,IAAR,GAAeA,IAAf","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.flow = void 0;\nfunction flow(...transforms) {\n return (block) => transforms.reduce((block, t) => t(block), block);\n}\nexports.flow = flow;\n"],"file":"index.cjs"}
@@ -1,3 +0,0 @@
1
- import { Block } from '../primitives.js';
2
- export type Transform = (Block: Block) => Block;
3
- export declare function flow(...transforms: Transform[]): Transform;
package/lib/util.cjs DELETED
@@ -1,113 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.rewireSpecs = exports.rewireSource = exports.seedTokens = exports.seedSpec = exports.seedBlock = exports.splitLines = exports.splitSpace = exports.splitCR = exports.hasCR = exports.isSpace = void 0;
7
-
8
- function isSpace(source) {
9
- return /^\s+$/.test(source);
10
- }
11
-
12
- exports.isSpace = isSpace;
13
-
14
- function hasCR(source) {
15
- return /\r$/.test(source);
16
- }
17
-
18
- exports.hasCR = hasCR;
19
-
20
- function splitCR(source) {
21
- const matches = source.match(/\r+$/);
22
- return matches == null ? ['', source] : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)];
23
- }
24
-
25
- exports.splitCR = splitCR;
26
-
27
- function splitSpace(source) {
28
- const matches = source.match(/^\s+/);
29
- return matches == null ? ['', source] : [source.slice(0, matches[0].length), source.slice(matches[0].length)];
30
- }
31
-
32
- exports.splitSpace = splitSpace;
33
-
34
- function splitLines(source) {
35
- return source.split(/\n/);
36
- }
37
-
38
- exports.splitLines = splitLines;
39
-
40
- function seedBlock(block = {}) {
41
- return Object.assign({
42
- description: '',
43
- tags: [],
44
- source: [],
45
- problems: []
46
- }, block);
47
- }
48
-
49
- exports.seedBlock = seedBlock;
50
-
51
- function seedSpec(spec = {}) {
52
- return Object.assign({
53
- tag: '',
54
- name: '',
55
- type: '',
56
- optional: false,
57
- description: '',
58
- problems: [],
59
- source: []
60
- }, spec);
61
- }
62
-
63
- exports.seedSpec = seedSpec;
64
-
65
- function seedTokens(tokens = {}) {
66
- return Object.assign({
67
- start: '',
68
- delimiter: '',
69
- postDelimiter: '',
70
- tag: '',
71
- postTag: '',
72
- name: '',
73
- postName: '',
74
- type: '',
75
- postType: '',
76
- description: '',
77
- end: '',
78
- lineEnd: ''
79
- }, tokens);
80
- }
81
-
82
- exports.seedTokens = seedTokens;
83
- /**
84
- * Assures Block.tags[].source contains references to the Block.source items,
85
- * using Block.source as a source of truth. This is a counterpart of rewireSpecs
86
- * @param block parsed coments block
87
- */
88
-
89
- function rewireSource(block) {
90
- const source = block.source.reduce((acc, line) => acc.set(line.number, line), new Map());
91
-
92
- for (const spec of block.tags) {
93
- spec.source = spec.source.map(line => source.get(line.number));
94
- }
95
-
96
- return block;
97
- }
98
-
99
- exports.rewireSource = rewireSource;
100
- /**
101
- * Assures Block.source contains references to the Block.tags[].source items,
102
- * using Block.tags[].source as a source of truth. This is a counterpart of rewireSource
103
- * @param block parsed coments block
104
- */
105
-
106
- function rewireSpecs(block) {
107
- const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map());
108
- block.source = block.source.map(line => source.get(line.number) || line);
109
- return block;
110
- }
111
-
112
- exports.rewireSpecs = rewireSpecs;
113
- //# sourceMappingURL=util.cjs.map
package/lib/util.cjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["util.js"],"names":["Object","defineProperty","exports","value","rewireSpecs","rewireSource","seedTokens","seedSpec","seedBlock","splitLines","splitSpace","splitCR","hasCR","isSpace","source","test","matches","match","slice","length","split","block","assign","description","tags","problems","spec","tag","name","type","optional","tokens","start","delimiter","postDelimiter","postTag","postName","postType","end","lineEnd","reduce","acc","line","set","number","Map","map","get"],"mappings":"AAAA;;AACAA,MAAM,CAACC,cAAP,CAAsBC,OAAtB,EAA+B,YAA/B,EAA6C;AAAEC,EAAAA,KAAK,EAAE;AAAT,CAA7C;AACAD,OAAO,CAACE,WAAR,GAAsBF,OAAO,CAACG,YAAR,GAAuBH,OAAO,CAACI,UAAR,GAAqBJ,OAAO,CAACK,QAAR,GAAmBL,OAAO,CAACM,SAAR,GAAoBN,OAAO,CAACO,UAAR,GAAqBP,OAAO,CAACQ,UAAR,GAAqBR,OAAO,CAACS,OAAR,GAAkBT,OAAO,CAACU,KAAR,GAAgBV,OAAO,CAACW,OAAR,GAAkB,KAAK,CAA5M;;AACA,SAASA,OAAT,CAAiBC,MAAjB,EAAyB;AACrB,SAAO,QAAQC,IAAR,CAAaD,MAAb,CAAP;AACH;;AACDZ,OAAO,CAACW,OAAR,GAAkBA,OAAlB;;AACA,SAASD,KAAT,CAAeE,MAAf,EAAuB;AACnB,SAAO,MAAMC,IAAN,CAAWD,MAAX,CAAP;AACH;;AACDZ,OAAO,CAACU,KAAR,GAAgBA,KAAhB;;AACA,SAASD,OAAT,CAAiBG,MAAjB,EAAyB;AACrB,QAAME,OAAO,GAAGF,MAAM,CAACG,KAAP,CAAa,MAAb,CAAhB;AACA,SAAOD,OAAO,IAAI,IAAX,GACD,CAAC,EAAD,EAAKF,MAAL,CADC,GAED,CAACA,MAAM,CAACI,KAAP,CAAa,CAACF,OAAO,CAAC,CAAD,CAAP,CAAWG,MAAzB,CAAD,EAAmCL,MAAM,CAACI,KAAP,CAAa,CAAb,EAAgB,CAACF,OAAO,CAAC,CAAD,CAAP,CAAWG,MAA5B,CAAnC,CAFN;AAGH;;AACDjB,OAAO,CAACS,OAAR,GAAkBA,OAAlB;;AACA,SAASD,UAAT,CAAoBI,MAApB,EAA4B;AACxB,QAAME,OAAO,GAAGF,MAAM,CAACG,K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,IAAN,KAAeA,IAAI,CAACZ,MAAL,CAAY0B,MAAZ,CAAmB,CAACC,GAAD,EAAMC,IAAN,KAAeD,GAAG,CAACE,GAAJ,CAAQD,IAAI,CAACE,MAAb,EAAqBF,IAArB,CAAlC,EAA8DD,GAA9D,CAAjC,EAAqG,IAAII,GAAJ,EAArG,CAAf;AACAxB,EAAAA,KAAK,CAACP,MAAN,GAAeO,KAAK,CAACP,MAAN,CAAagC,GAAb,CAAkBJ,IAAD,IAAU5B,MAAM,CAACiC,GAAP,CAAWL,IAAI,CAACE,MAAhB,KAA2BF,IAAtD,CAAf;AACA,SAAOrB,KAAP;AACH;;AACDnB,OAAO,CAACE,WAAR,GAAsBA,WAAtB","sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.rewireSpecs = exports.rewireSource = exports.seedTokens = exports.seedSpec = exports.seedBlock = exports.splitLines = exports.splitSpace = exports.splitCR = exports.hasCR = exports.isSpace = void 0;\nfunction isSpace(source) {\n return /^\\s+$/.test(source);\n}\nexports.isSpace = isSpace;\nfunction hasCR(source) {\n return /\\r$/.test(source);\n}\nexports.hasCR = hasCR;\nfunction splitCR(source) {\n const matches = source.match(/\\r+$/);\n return matches == null\n ? ['', source]\n : [source.slice(-matches[0].length), source.slice(0, -matches[0].length)];\n}\nexports.splitCR = splitCR;\nfunction splitSpace(source) {\n const matches = source.match(/^\\s+/);\n return matches == null\n ? ['', source]\n : [source.slice(0, matches[0].length), source.slice(matches[0].length)];\n}\nexports.splitSpace = splitSpace;\nfunction splitLines(source) {\n return source.split(/\\n/);\n}\nexports.splitLines = splitLines;\nfunction seedBlock(block = {}) {\n return Object.assign({ description: '', tags: [], source: [], problems: [] }, block);\n}\nexports.seedBlock = seedBlock;\nfunction seedSpec(spec = {}) {\n return Object.assign({ tag: '', name: '', type: '', optional: false, description: '', problems: [], source: [] }, spec);\n}\nexports.seedSpec = seedSpec;\nfunction seedTokens(tokens = {}) {\n return Object.assign({ start: '', delimiter: '', postDelimiter: '', tag: '', postTag: '', name: '', postName: '', type: '', postType: '', description: '', end: '', lineEnd: '' }, tokens);\n}\nexports.seedTokens = seedTokens;\n/**\n * Assures Block.tags[].source contains references to the Block.source items,\n * using Block.source as a source of truth. This is a counterpart of rewireSpecs\n * @param block parsed coments block\n */\nfunction rewireSource(block) {\n const source = block.source.reduce((acc, line) => acc.set(line.number, line), new Map());\n for (const spec of block.tags) {\n spec.source = spec.source.map((line) => source.get(line.number));\n }\n return block;\n}\nexports.rewireSource = rewireSource;\n/**\n * Assures Block.source contains references to the Block.tags[].source items,\n * using Block.tags[].source as a source of truth. This is a counterpart of rewireSource\n * @param block parsed coments block\n */\nfunction rewireSpecs(block) {\n const source = block.tags.reduce((acc, spec) => spec.source.reduce((acc, line) => acc.set(line.number, line), acc), new Map());\n block.source = block.source.map((line) => source.get(line.number) || line);\n return block;\n}\nexports.rewireSpecs = rewireSpecs;\n"],"file":"util.cjs"}
package/lib/util.d.ts DELETED
@@ -1,21 +0,0 @@
1
- import { Block, Tokens, Spec } from './primitives.js';
2
- export declare function isSpace(source: string): boolean;
3
- export declare function hasCR(source: string): boolean;
4
- export declare function splitCR(source: string): [string, string];
5
- export declare function splitSpace(source: string): [string, string];
6
- export declare function splitLines(source: string): string[];
7
- export declare function seedBlock(block?: Partial<Block>): Block;
8
- export declare function seedSpec(spec?: Partial<Spec>): Spec;
9
- export declare function seedTokens(tokens?: Partial<Tokens>): Tokens;
10
- /**
11
- * Assures Block.tags[].source contains references to the Block.source items,
12
- * using Block.source as a source of truth. This is a counterpart of rewireSpecs
13
- * @param block parsed coments block
14
- */
15
- export declare function rewireSource(block: Block): Block;
16
- /**
17
- * Assures Block.source contains references to the Block.tags[].source items,
18
- * using Block.tags[].source as a source of truth. This is a counterpart of rewireSource
19
- * @param block parsed coments block
20
- */
21
- export declare function rewireSpecs(block: Block): Block;