|
1 | | -Utilities for processing JavaScript text. |
| 1 | +Utilities for processing JavaScript text.<br> |
| 2 | +📦 [Node.js](https://www.npmjs.com/package/extra-javascript-text), |
| 3 | +🌐 [Web](https://www.npmjs.com/package/extra-javascript-text.web), |
| 4 | +📜 [Files](https://unpkg.com/extra-javascript-text/), |
| 5 | +📰 [Docs](https://nodef.github.io/extra-javascript-text/). |
| 6 | + |
| 7 | +This package is available in both *Node.js* and *Web* formats. The web format |
| 8 | +is exposed as `extra_javascript_text` standalone variable and can be loaded from |
| 9 | +[jsDelivr CDN]. |
| 10 | + |
| 11 | +> Stability: [Experimental](https://www.youtube.com/watch?v=L1j93RnIxEo). |
| 12 | +
|
| 13 | +[jsDelivr CDN]: https://cdn.jsdelivr.net/npm/extra-javascript-text.web/index.js |
| 14 | + |
| 15 | +<br> |
| 16 | + |
| 17 | +```javascript |
| 18 | +const fs = require('fs'); |
| 19 | +const javascript = require('extra-javascript-text'); |
| 20 | + |
| 21 | + |
| 22 | +function main() { |
| 23 | + var txt = fs.readFileSync('src/index.ts', 'utf8').replace(/\r?\n/, '\n'); |
| 24 | + |
| 25 | + javascript.importSymbols(txt); |
| 26 | + // [] |
| 27 | + |
| 28 | + javascript.exportSymbols(txt); |
| 29 | + // [ |
| 30 | + // { |
| 31 | + // full: 'export function tagStrings', |
| 32 | + // name: 'tagStrings', |
| 33 | + // kind: 'function', |
| 34 | + // isDefault: false |
| 35 | + // }, |
| 36 | + // { |
| 37 | + // full: 'export function untagStrings', |
| 38 | + // name: 'untagStrings', |
| 39 | + // kind: 'function', |
| 40 | + // isDefault: false |
| 41 | + // }, |
| 42 | + // ... |
| 43 | + // ] |
| 44 | + |
| 45 | + javascript.jsdocSymbols(txt); |
| 46 | + // [ |
| 47 | + // { |
| 48 | + // full: '/**\r\n' + |
| 49 | + // ' * Get index of string end.\r\n' + |
| 50 | + // ' * @param txt javascript text\r\n' + |
| 51 | + // ' * @param i index of string begin\r\n' + |
| 52 | + // ' */\r\n' + |
| 53 | + // ' function indexOfClosingString', |
| 54 | + // jsdoc: '/**\r\n' + |
| 55 | + // ' * Get index of string end.\r\n' + |
| 56 | + // ' * @param txt javascript text\r\n' + |
| 57 | + // ' * @param i index of string begin\r\n' + |
| 58 | + // ' */', |
| 59 | + // name: 'indexOfClosingString', |
| 60 | + // kind: 'function', |
| 61 | + // isExported: false, |
| 62 | + // isDefault: false |
| 63 | + // }, |
| 64 | + // { |
| 65 | + // full: '/**\r\n' + |
| 66 | + // ' * Tag strings in javascript text and remove them.\r\n' + |
| 67 | + // ' * @param txt javascript text\r\n' + |
| 68 | + // ' * @returns [updated javascript text, tags]\r\n' + |
| 69 | + // ' */\r\n' + |
| 70 | + // 'export function tagStrings', |
| 71 | + // jsdoc: '/**\r\n' + |
| 72 | + // ' * Tag strings in javascript text and remove them.\r\n' + |
| 73 | + // ' * @param txt javascript text\r\n' + |
| 74 | + // ' * @returns [updated javascript text, tags]\r\n' + |
| 75 | + // ' */', |
| 76 | + // name: 'tagStrings', |
| 77 | + // kind: 'function', |
| 78 | + // isExported: true, |
| 79 | + // isDefault: false |
| 80 | + // }, |
| 81 | + // ... |
| 82 | + // ] |
| 83 | +} |
| 84 | +main(); |
| 85 | +``` |
| 86 | + |
| 87 | +<br> |
| 88 | +<br> |
| 89 | + |
| 90 | + |
| 91 | +## Index |
| 92 | + |
| 93 | +| Property | Description | |
| 94 | +| ---- | ---- | |
| 95 | +| [tagStrings] | Tag strings in javascript text and remove them. | |
| 96 | +| [untagStrings] | Untag strings in javascript text by adding them back. | |
| 97 | +| [forEachComment] | Match links in javascript text. | |
| 98 | +| [comments] | Get comments in javascript text. | |
| 99 | +| [replaceComments] | Replace comments in javascript text. | |
| 100 | +| [tagComments] | Tag comments in javascript text and remove them. | |
| 101 | +| [untagComments] | Untag comments in javascript text by adding them back. | |
| 102 | +| [uncomment] | Remove comments from javascript text. | |
| 103 | +| [forEachJsdocSymbol] | Match jsdoc symbols in javascript text. | |
| 104 | +| [jsdocSymbols] | Get jsdoc symbols in javascript text. | |
| 105 | +| [replaceJsdocSymbols] | Replace jsdoc symbols in javascript text. | |
| 106 | +| [forEachExportSymbol] | Match export symbols in javascript text. | |
| 107 | +| [exportSymbols] | Get export symbols in javascript text. | |
| 108 | +| [replaceExportSymbols] | Replace export symbols in javascript text. | |
| 109 | +| [forEachImportSymbol] | Match import symbols in javascript text. | |
| 110 | +| [importSymbols] | Get import symbols in javascript text. | |
| 111 | +| [replaceImportSymbols] | Replace import symbols in javascript text. | |
| 112 | +| [correctDeclarations] | Correct type declarations after generation. | |
| 113 | + |
| 114 | +<br> |
| 115 | +<br> |
| 116 | + |
| 117 | +[](https://www.youtube.com/watch?v=rJYcZX8na_Q) |
| 118 | + |
| 119 | +[tagStrings]: https://nodef.github.io/extra-javascript-text/modules.html#tagStrings |
| 120 | +[untagStrings]: https://nodef.github.io/extra-javascript-text/modules.html#untagStrings |
| 121 | +[forEachComment]: https://nodef.github.io/extra-javascript-text/modules.html#forEachComment |
| 122 | +[comments]: https://nodef.github.io/extra-javascript-text/modules.html#comments |
| 123 | +[replaceComments]: https://nodef.github.io/extra-javascript-text/modules.html#replaceComments |
| 124 | +[tagComments]: https://nodef.github.io/extra-javascript-text/modules.html#tagComments |
| 125 | +[untagComments]: https://nodef.github.io/extra-javascript-text/modules.html#untagComments |
| 126 | +[uncomment]: https://nodef.github.io/extra-javascript-text/modules.html#uncomment |
| 127 | +[forEachJsdocSymbol]: https://nodef.github.io/extra-javascript-text/modules.html#forEachJsdocSymbol |
| 128 | +[jsdocSymbols]: https://nodef.github.io/extra-javascript-text/modules.html#jsdocSymbols |
| 129 | +[replaceJsdocSymbols]: https://nodef.github.io/extra-javascript-text/modules.html#replaceJsdocSymbols |
| 130 | +[forEachExportSymbol]: https://nodef.github.io/extra-javascript-text/modules.html#forEachExportSymbol |
| 131 | +[exportSymbols]: https://nodef.github.io/extra-javascript-text/modules.html#exportSymbols |
| 132 | +[replaceExportSymbols]: https://nodef.github.io/extra-javascript-text/modules.html#replaceExportSymbols |
| 133 | +[forEachImportSymbol]: https://nodef.github.io/extra-javascript-text/modules.html#forEachImportSymbol |
| 134 | +[importSymbols]: https://nodef.github.io/extra-javascript-text/modules.html#importSymbols |
| 135 | +[replaceImportSymbols]: https://nodef.github.io/extra-javascript-text/modules.html#replaceImportSymbols |
| 136 | +[correctDeclarations]: https://nodef.github.io/extra-javascript-text/modules.html#correctDeclarations |
0 commit comments