@mavogel/cdk-vscode-server 0.0.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 (439) hide show
  1. package/.jsii +4351 -0
  2. package/API.md +367 -0
  3. package/CONTRIBUTING.md +59 -0
  4. package/LICENSE +202 -0
  5. package/README.md +183 -0
  6. package/assets/installer/installer.lambda/index.js +112 -0
  7. package/assets/secret-retriever/secret-retriever.lambda/index.js +57 -0
  8. package/docs/img/vscode-server-ui-login-min.png +0 -0
  9. package/docs/img/vscode-server-ui-min.png +0 -0
  10. package/docs/img/vscode-server.drawio +108 -0
  11. package/docs/img/vscode-server.drawio-min.png +0 -0
  12. package/integ-tests/code-server login.html +48 -0
  13. package/integ-tests/functions/login-handler.ts +63 -0
  14. package/integ-tests/integ.al2023.ts +69 -0
  15. package/integ-tests/integ.al2023.ts.snapshot/IntegSetupVSCodeOnAl2023DefaultTestDeployAssert74D8F645.assets.json +32 -0
  16. package/integ-tests/integ.al2023.ts.snapshot/IntegSetupVSCodeOnAl2023DefaultTestDeployAssert74D8F645.template.json +337 -0
  17. package/integ-tests/integ.al2023.ts.snapshot/IntegTestStackAl2023.assets.json +110 -0
  18. package/integ-tests/integ.al2023.ts.snapshot/IntegTestStackAl2023.template.json +2459 -0
  19. package/integ-tests/integ.al2023.ts.snapshot/asset.23732f3d1982f7fb0da3bd6638a8107337bb767fea165b45eae12000a1dd67ce/index.js +6169 -0
  20. package/integ-tests/integ.al2023.ts.snapshot/asset.2819175352ad1ce0dae768e83fc328fb70fb5f10b4a8ff0ccbcb791f02b0716d/index.js +1 -0
  21. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/cfn-response.js +1 -0
  22. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/consts.js +1 -0
  23. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/framework.js +3 -0
  24. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/outbound.js +1 -0
  25. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/util.js +1 -0
  26. package/integ-tests/integ.al2023.ts.snapshot/asset.512cf155ada4793b37a885c1aa6d9bb8f534e88bac6f63c69672d4d73df2decf.lambda/index.js +112 -0
  27. package/integ-tests/integ.al2023.ts.snapshot/asset.781ab0ab74634cdaf61539ab208ab777829ef07097ac21f95b9e15a3b1eedc1b.lambda/index.js +57 -0
  28. package/integ-tests/integ.al2023.ts.snapshot/asset.c504585dae89ce8e394d7744ccae054318e7d1aff14afb545438d173d51dc97d.bundle/index.js +30572 -0
  29. package/integ-tests/integ.al2023.ts.snapshot/asset.ce2f3595a340d6c519a65888ef97e3b9b64f053f83608e32cc28162e22d7d99a/index.js +1 -0
  30. package/integ-tests/integ.al2023.ts.snapshot/asset.ee7de53d64cc9d6248fa6aa550f92358f6c907b5efd6f3298aeab1b5e7ea358a/__entrypoint__.js +1 -0
  31. package/integ-tests/integ.al2023.ts.snapshot/asset.ee7de53d64cc9d6248fa6aa550f92358f6c907b5efd6f3298aeab1b5e7ea358a/index.js +1 -0
  32. package/integ-tests/integ.al2023.ts.snapshot/cdk.out +1 -0
  33. package/integ-tests/integ.al2023.ts.snapshot/integ.json +22 -0
  34. package/integ-tests/integ.al2023.ts.snapshot/manifest.json +510 -0
  35. package/integ-tests/integ.al2023.ts.snapshot/tree.json +2944 -0
  36. package/integ-tests/integ.ubuntu.ts +66 -0
  37. package/integ-tests/integ.ubuntu.ts.snapshot/IntegSetupVSCodeOnUbuntuDefaultTestDeployAssertFF8DF2C5.assets.json +32 -0
  38. package/integ-tests/integ.ubuntu.ts.snapshot/IntegSetupVSCodeOnUbuntuDefaultTestDeployAssertFF8DF2C5.template.json +337 -0
  39. package/integ-tests/integ.ubuntu.ts.snapshot/IntegTestStackUbuntu22.assets.json +110 -0
  40. package/integ-tests/integ.ubuntu.ts.snapshot/IntegTestStackUbuntu22.template.json +2477 -0
  41. package/integ-tests/integ.ubuntu.ts.snapshot/asset.23732f3d1982f7fb0da3bd6638a8107337bb767fea165b45eae12000a1dd67ce/index.js +6169 -0
  42. package/integ-tests/integ.ubuntu.ts.snapshot/asset.2819175352ad1ce0dae768e83fc328fb70fb5f10b4a8ff0ccbcb791f02b0716d/index.js +1 -0
  43. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/cfn-response.js +1 -0
  44. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/consts.js +1 -0
  45. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/framework.js +3 -0
  46. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/outbound.js +1 -0
  47. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/util.js +1 -0
  48. package/integ-tests/integ.ubuntu.ts.snapshot/asset.512cf155ada4793b37a885c1aa6d9bb8f534e88bac6f63c69672d4d73df2decf.lambda/index.js +112 -0
  49. package/integ-tests/integ.ubuntu.ts.snapshot/asset.781ab0ab74634cdaf61539ab208ab777829ef07097ac21f95b9e15a3b1eedc1b.lambda/index.js +57 -0
  50. package/integ-tests/integ.ubuntu.ts.snapshot/asset.c504585dae89ce8e394d7744ccae054318e7d1aff14afb545438d173d51dc97d.bundle/index.js +30572 -0
  51. package/integ-tests/integ.ubuntu.ts.snapshot/asset.ce2f3595a340d6c519a65888ef97e3b9b64f053f83608e32cc28162e22d7d99a/index.js +1 -0
  52. package/integ-tests/integ.ubuntu.ts.snapshot/asset.ee7de53d64cc9d6248fa6aa550f92358f6c907b5efd6f3298aeab1b5e7ea358a/__entrypoint__.js +1 -0
  53. package/integ-tests/integ.ubuntu.ts.snapshot/asset.ee7de53d64cc9d6248fa6aa550f92358f6c907b5efd6f3298aeab1b5e7ea358a/index.js +1 -0
  54. package/integ-tests/integ.ubuntu.ts.snapshot/cdk.out +1 -0
  55. package/integ-tests/integ.ubuntu.ts.snapshot/integ.json +22 -0
  56. package/integ-tests/integ.ubuntu.ts.snapshot/manifest.json +510 -0
  57. package/integ-tests/integ.ubuntu.ts.snapshot/tree.json +2962 -0
  58. package/lib/index.d.ts +1 -0
  59. package/lib/index.js +18 -0
  60. package/lib/installer/installer-function.d.ts +13 -0
  61. package/lib/installer/installer-function.js +23 -0
  62. package/lib/installer/installer.d.ts +64 -0
  63. package/lib/installer/installer.js +707 -0
  64. package/lib/installer/installer.lambda.d.ts +3 -0
  65. package/lib/installer/installer.lambda.js +94 -0
  66. package/lib/mappings.d.ts +2 -0
  67. package/lib/mappings.js +25 -0
  68. package/lib/prefixlist-retriever/prefixlist-retriever.d.ts +16 -0
  69. package/lib/prefixlist-retriever/prefixlist-retriever.js +56 -0
  70. package/lib/secret-retriever/secret-retriever-function.d.ts +13 -0
  71. package/lib/secret-retriever/secret-retriever-function.js +23 -0
  72. package/lib/secret-retriever/secret-retriever.d.ts +33 -0
  73. package/lib/secret-retriever/secret-retriever.js +72 -0
  74. package/lib/secret-retriever/secret-retriever.lambda.d.ts +2 -0
  75. package/lib/secret-retriever/secret-retriever.lambda.js +36 -0
  76. package/lib/vscode-server.d.ts +97 -0
  77. package/lib/vscode-server.js +417 -0
  78. package/node_modules/boolbase/README.md +10 -0
  79. package/node_modules/boolbase/index.js +8 -0
  80. package/node_modules/boolbase/package.json +23 -0
  81. package/node_modules/css-select/LICENSE +11 -0
  82. package/node_modules/css-select/README.md +264 -0
  83. package/node_modules/css-select/lib/attributes.d.ts +7 -0
  84. package/node_modules/css-select/lib/attributes.d.ts.map +1 -0
  85. package/node_modules/css-select/lib/attributes.js +236 -0
  86. package/node_modules/css-select/lib/attributes.js.map +1 -0
  87. package/node_modules/css-select/lib/compile.d.ts +13 -0
  88. package/node_modules/css-select/lib/compile.d.ts.map +1 -0
  89. package/node_modules/css-select/lib/compile.js +151 -0
  90. package/node_modules/css-select/lib/compile.js.map +1 -0
  91. package/node_modules/css-select/lib/esm/attributes.d.ts +7 -0
  92. package/node_modules/css-select/lib/esm/attributes.d.ts.map +1 -0
  93. package/node_modules/css-select/lib/esm/attributes.js +222 -0
  94. package/node_modules/css-select/lib/esm/attributes.js.map +1 -0
  95. package/node_modules/css-select/lib/esm/compile.d.ts +13 -0
  96. package/node_modules/css-select/lib/esm/compile.d.ts.map +1 -0
  97. package/node_modules/css-select/lib/esm/compile.js +115 -0
  98. package/node_modules/css-select/lib/esm/compile.js.map +1 -0
  99. package/node_modules/css-select/lib/esm/general.d.ts +3 -0
  100. package/node_modules/css-select/lib/esm/general.d.ts.map +1 -0
  101. package/node_modules/css-select/lib/esm/general.js +144 -0
  102. package/node_modules/css-select/lib/esm/general.js.map +1 -0
  103. package/node_modules/css-select/lib/esm/index.d.ts +50 -0
  104. package/node_modules/css-select/lib/esm/index.d.ts.map +1 -0
  105. package/node_modules/css-select/lib/esm/index.js +115 -0
  106. package/node_modules/css-select/lib/esm/index.js.map +1 -0
  107. package/node_modules/css-select/lib/esm/package.json +1 -0
  108. package/node_modules/css-select/lib/esm/pseudo-selectors/aliases.d.ts +5 -0
  109. package/node_modules/css-select/lib/esm/pseudo-selectors/aliases.d.ts.map +1 -0
  110. package/node_modules/css-select/lib/esm/pseudo-selectors/aliases.js +35 -0
  111. package/node_modules/css-select/lib/esm/pseudo-selectors/aliases.js.map +1 -0
  112. package/node_modules/css-select/lib/esm/pseudo-selectors/filters.d.ts +4 -0
  113. package/node_modules/css-select/lib/esm/pseudo-selectors/filters.d.ts.map +1 -0
  114. package/node_modules/css-select/lib/esm/pseudo-selectors/filters.js +143 -0
  115. package/node_modules/css-select/lib/esm/pseudo-selectors/filters.js.map +1 -0
  116. package/node_modules/css-select/lib/esm/pseudo-selectors/index.d.ts +8 -0
  117. package/node_modules/css-select/lib/esm/pseudo-selectors/index.d.ts.map +1 -0
  118. package/node_modules/css-select/lib/esm/pseudo-selectors/index.js +40 -0
  119. package/node_modules/css-select/lib/esm/pseudo-selectors/index.js.map +1 -0
  120. package/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.d.ts +6 -0
  121. package/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.d.ts.map +1 -0
  122. package/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js +79 -0
  123. package/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js.map +1 -0
  124. package/node_modules/css-select/lib/esm/pseudo-selectors/subselects.d.ts +9 -0
  125. package/node_modules/css-select/lib/esm/pseudo-selectors/subselects.d.ts.map +1 -0
  126. package/node_modules/css-select/lib/esm/pseudo-selectors/subselects.js +94 -0
  127. package/node_modules/css-select/lib/esm/pseudo-selectors/subselects.js.map +1 -0
  128. package/node_modules/css-select/lib/esm/sort.d.ts +12 -0
  129. package/node_modules/css-select/lib/esm/sort.d.ts.map +1 -0
  130. package/node_modules/css-select/lib/esm/sort.js +79 -0
  131. package/node_modules/css-select/lib/esm/sort.js.map +1 -0
  132. package/node_modules/css-select/lib/esm/types.d.ts +167 -0
  133. package/node_modules/css-select/lib/esm/types.d.ts.map +1 -0
  134. package/node_modules/css-select/lib/esm/types.js +2 -0
  135. package/node_modules/css-select/lib/esm/types.js.map +1 -0
  136. package/node_modules/css-select/lib/general.d.ts +3 -0
  137. package/node_modules/css-select/lib/general.d.ts.map +1 -0
  138. package/node_modules/css-select/lib/general.js +148 -0
  139. package/node_modules/css-select/lib/general.js.map +1 -0
  140. package/node_modules/css-select/lib/index.d.ts +50 -0
  141. package/node_modules/css-select/lib/index.d.ts.map +1 -0
  142. package/node_modules/css-select/lib/index.js +154 -0
  143. package/node_modules/css-select/lib/index.js.map +1 -0
  144. package/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts +5 -0
  145. package/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts.map +1 -0
  146. package/node_modules/css-select/lib/pseudo-selectors/aliases.js +34 -0
  147. package/node_modules/css-select/lib/pseudo-selectors/aliases.js.map +1 -0
  148. package/node_modules/css-select/lib/pseudo-selectors/filters.d.ts +4 -0
  149. package/node_modules/css-select/lib/pseudo-selectors/filters.d.ts.map +1 -0
  150. package/node_modules/css-select/lib/pseudo-selectors/filters.js +157 -0
  151. package/node_modules/css-select/lib/pseudo-selectors/filters.js.map +1 -0
  152. package/node_modules/css-select/lib/pseudo-selectors/index.d.ts +8 -0
  153. package/node_modules/css-select/lib/pseudo-selectors/index.d.ts.map +1 -0
  154. package/node_modules/css-select/lib/pseudo-selectors/index.js +46 -0
  155. package/node_modules/css-select/lib/pseudo-selectors/index.js.map +1 -0
  156. package/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts +6 -0
  157. package/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts.map +1 -0
  158. package/node_modules/css-select/lib/pseudo-selectors/pseudos.js +93 -0
  159. package/node_modules/css-select/lib/pseudo-selectors/pseudos.js.map +1 -0
  160. package/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts +9 -0
  161. package/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts.map +1 -0
  162. package/node_modules/css-select/lib/pseudo-selectors/subselects.js +112 -0
  163. package/node_modules/css-select/lib/pseudo-selectors/subselects.js.map +1 -0
  164. package/node_modules/css-select/lib/sort.d.ts +12 -0
  165. package/node_modules/css-select/lib/sort.d.ts.map +1 -0
  166. package/node_modules/css-select/lib/sort.js +84 -0
  167. package/node_modules/css-select/lib/sort.js.map +1 -0
  168. package/node_modules/css-select/lib/types.d.ts +167 -0
  169. package/node_modules/css-select/lib/types.d.ts.map +1 -0
  170. package/node_modules/css-select/lib/types.js +3 -0
  171. package/node_modules/css-select/lib/types.js.map +1 -0
  172. package/node_modules/css-select/package.json +81 -0
  173. package/node_modules/css-what/LICENSE +11 -0
  174. package/node_modules/css-what/lib/commonjs/index.d.ts +4 -0
  175. package/node_modules/css-what/lib/commonjs/index.d.ts.map +1 -0
  176. package/node_modules/css-what/lib/commonjs/index.js +23 -0
  177. package/node_modules/css-what/lib/commonjs/parse.d.ts +20 -0
  178. package/node_modules/css-what/lib/commonjs/parse.d.ts.map +1 -0
  179. package/node_modules/css-what/lib/commonjs/parse.js +425 -0
  180. package/node_modules/css-what/lib/commonjs/stringify.d.ts +8 -0
  181. package/node_modules/css-what/lib/commonjs/stringify.d.ts.map +1 -0
  182. package/node_modules/css-what/lib/commonjs/stringify.js +138 -0
  183. package/node_modules/css-what/lib/commonjs/types.d.ts +70 -0
  184. package/node_modules/css-what/lib/commonjs/types.d.ts.map +1 -0
  185. package/node_modules/css-what/lib/commonjs/types.js +42 -0
  186. package/node_modules/css-what/lib/es/index.d.ts +4 -0
  187. package/node_modules/css-what/lib/es/index.d.ts.map +1 -0
  188. package/node_modules/css-what/lib/es/index.js +3 -0
  189. package/node_modules/css-what/lib/es/parse.d.ts +20 -0
  190. package/node_modules/css-what/lib/es/parse.d.ts.map +1 -0
  191. package/node_modules/css-what/lib/es/parse.js +420 -0
  192. package/node_modules/css-what/lib/es/stringify.d.ts +8 -0
  193. package/node_modules/css-what/lib/es/stringify.d.ts.map +1 -0
  194. package/node_modules/css-what/lib/es/stringify.js +126 -0
  195. package/node_modules/css-what/lib/es/types.d.ts +70 -0
  196. package/node_modules/css-what/lib/es/types.d.ts.map +1 -0
  197. package/node_modules/css-what/lib/es/types.js +39 -0
  198. package/node_modules/css-what/package.json +59 -0
  199. package/node_modules/css-what/readme.md +69 -0
  200. package/node_modules/dom-serializer/LICENSE +11 -0
  201. package/node_modules/dom-serializer/README.md +109 -0
  202. package/node_modules/dom-serializer/lib/esm/foreignNames.d.ts +3 -0
  203. package/node_modules/dom-serializer/lib/esm/foreignNames.d.ts.map +1 -0
  204. package/node_modules/dom-serializer/lib/esm/foreignNames.js +100 -0
  205. package/node_modules/dom-serializer/lib/esm/index.d.ts +52 -0
  206. package/node_modules/dom-serializer/lib/esm/index.d.ts.map +1 -0
  207. package/node_modules/dom-serializer/lib/esm/index.js +190 -0
  208. package/node_modules/dom-serializer/lib/esm/package.json +1 -0
  209. package/node_modules/dom-serializer/lib/foreignNames.d.ts +3 -0
  210. package/node_modules/dom-serializer/lib/foreignNames.d.ts.map +1 -0
  211. package/node_modules/dom-serializer/lib/foreignNames.js +103 -0
  212. package/node_modules/dom-serializer/lib/index.d.ts +52 -0
  213. package/node_modules/dom-serializer/lib/index.d.ts.map +1 -0
  214. package/node_modules/dom-serializer/lib/index.js +229 -0
  215. package/node_modules/dom-serializer/package.json +69 -0
  216. package/node_modules/domelementtype/LICENSE +11 -0
  217. package/node_modules/domelementtype/lib/esm/index.d.ts +48 -0
  218. package/node_modules/domelementtype/lib/esm/index.d.ts.map +1 -0
  219. package/node_modules/domelementtype/lib/esm/index.js +51 -0
  220. package/node_modules/domelementtype/lib/esm/package.json +1 -0
  221. package/node_modules/domelementtype/lib/index.d.ts +48 -0
  222. package/node_modules/domelementtype/lib/index.d.ts.map +1 -0
  223. package/node_modules/domelementtype/lib/index.js +55 -0
  224. package/node_modules/domelementtype/package.json +54 -0
  225. package/node_modules/domelementtype/readme.md +1 -0
  226. package/node_modules/domhandler/LICENSE +11 -0
  227. package/node_modules/domhandler/lib/esm/index.d.ts +76 -0
  228. package/node_modules/domhandler/lib/esm/index.d.ts.map +1 -0
  229. package/node_modules/domhandler/lib/esm/index.js +146 -0
  230. package/node_modules/domhandler/lib/esm/node.d.ts +245 -0
  231. package/node_modules/domhandler/lib/esm/node.d.ts.map +1 -0
  232. package/node_modules/domhandler/lib/esm/node.js +338 -0
  233. package/node_modules/domhandler/lib/esm/package.json +1 -0
  234. package/node_modules/domhandler/lib/index.d.ts +76 -0
  235. package/node_modules/domhandler/lib/index.d.ts.map +1 -0
  236. package/node_modules/domhandler/lib/index.js +165 -0
  237. package/node_modules/domhandler/lib/node.d.ts +245 -0
  238. package/node_modules/domhandler/lib/node.d.ts.map +1 -0
  239. package/node_modules/domhandler/lib/node.js +474 -0
  240. package/node_modules/domhandler/package.json +73 -0
  241. package/node_modules/domhandler/readme.md +92 -0
  242. package/node_modules/domutils/LICENSE +11 -0
  243. package/node_modules/domutils/lib/esm/feeds.d.ts +71 -0
  244. package/node_modules/domutils/lib/esm/feeds.d.ts.map +1 -0
  245. package/node_modules/domutils/lib/esm/feeds.js +183 -0
  246. package/node_modules/domutils/lib/esm/feeds.js.map +1 -0
  247. package/node_modules/domutils/lib/esm/helpers.d.ts +59 -0
  248. package/node_modules/domutils/lib/esm/helpers.d.ts.map +1 -0
  249. package/node_modules/domutils/lib/esm/helpers.js +136 -0
  250. package/node_modules/domutils/lib/esm/helpers.js.map +1 -0
  251. package/node_modules/domutils/lib/esm/index.d.ts +10 -0
  252. package/node_modules/domutils/lib/esm/index.d.ts.map +1 -0
  253. package/node_modules/domutils/lib/esm/index.js +10 -0
  254. package/node_modules/domutils/lib/esm/index.js.map +1 -0
  255. package/node_modules/domutils/lib/esm/legacy.d.ts +79 -0
  256. package/node_modules/domutils/lib/esm/legacy.d.ts.map +1 -0
  257. package/node_modules/domutils/lib/esm/legacy.js +152 -0
  258. package/node_modules/domutils/lib/esm/legacy.js.map +1 -0
  259. package/node_modules/domutils/lib/esm/manipulation.d.ts +49 -0
  260. package/node_modules/domutils/lib/esm/manipulation.d.ts.map +1 -0
  261. package/node_modules/domutils/lib/esm/manipulation.js +134 -0
  262. package/node_modules/domutils/lib/esm/manipulation.js.map +1 -0
  263. package/node_modules/domutils/lib/esm/package.json +1 -0
  264. package/node_modules/domutils/lib/esm/querying.d.ts +64 -0
  265. package/node_modules/domutils/lib/esm/querying.d.ts.map +1 -0
  266. package/node_modules/domutils/lib/esm/querying.js +142 -0
  267. package/node_modules/domutils/lib/esm/querying.js.map +1 -0
  268. package/node_modules/domutils/lib/esm/stringify.d.ts +46 -0
  269. package/node_modules/domutils/lib/esm/stringify.d.ts.map +1 -0
  270. package/node_modules/domutils/lib/esm/stringify.js +81 -0
  271. package/node_modules/domutils/lib/esm/stringify.js.map +1 -0
  272. package/node_modules/domutils/lib/esm/traversal.d.ts +67 -0
  273. package/node_modules/domutils/lib/esm/traversal.d.ts.map +1 -0
  274. package/node_modules/domutils/lib/esm/traversal.js +112 -0
  275. package/node_modules/domutils/lib/esm/traversal.js.map +1 -0
  276. package/node_modules/domutils/lib/feeds.d.ts +71 -0
  277. package/node_modules/domutils/lib/feeds.d.ts.map +1 -0
  278. package/node_modules/domutils/lib/feeds.js +190 -0
  279. package/node_modules/domutils/lib/feeds.js.map +1 -0
  280. package/node_modules/domutils/lib/helpers.d.ts +59 -0
  281. package/node_modules/domutils/lib/helpers.d.ts.map +1 -0
  282. package/node_modules/domutils/lib/helpers.js +142 -0
  283. package/node_modules/domutils/lib/helpers.js.map +1 -0
  284. package/node_modules/domutils/lib/index.d.ts +10 -0
  285. package/node_modules/domutils/lib/index.d.ts.map +1 -0
  286. package/node_modules/domutils/lib/index.js +33 -0
  287. package/node_modules/domutils/lib/index.js.map +1 -0
  288. package/node_modules/domutils/lib/legacy.d.ts +79 -0
  289. package/node_modules/domutils/lib/legacy.d.ts.map +1 -0
  290. package/node_modules/domutils/lib/legacy.js +168 -0
  291. package/node_modules/domutils/lib/legacy.js.map +1 -0
  292. package/node_modules/domutils/lib/manipulation.d.ts +49 -0
  293. package/node_modules/domutils/lib/manipulation.d.ts.map +1 -0
  294. package/node_modules/domutils/lib/manipulation.js +142 -0
  295. package/node_modules/domutils/lib/manipulation.js.map +1 -0
  296. package/node_modules/domutils/lib/querying.d.ts +64 -0
  297. package/node_modules/domutils/lib/querying.d.ts.map +1 -0
  298. package/node_modules/domutils/lib/querying.js +155 -0
  299. package/node_modules/domutils/lib/querying.js.map +1 -0
  300. package/node_modules/domutils/lib/stringify.d.ts +46 -0
  301. package/node_modules/domutils/lib/stringify.d.ts.map +1 -0
  302. package/node_modules/domutils/lib/stringify.js +91 -0
  303. package/node_modules/domutils/lib/stringify.js.map +1 -0
  304. package/node_modules/domutils/lib/traversal.d.ts +67 -0
  305. package/node_modules/domutils/lib/traversal.d.ts.map +1 -0
  306. package/node_modules/domutils/lib/traversal.js +125 -0
  307. package/node_modules/domutils/lib/traversal.js.map +1 -0
  308. package/node_modules/domutils/package.json +79 -0
  309. package/node_modules/domutils/readme.md +31 -0
  310. package/node_modules/entities/LICENSE +11 -0
  311. package/node_modules/entities/lib/decode.d.ts +211 -0
  312. package/node_modules/entities/lib/decode.d.ts.map +1 -0
  313. package/node_modules/entities/lib/decode.js +536 -0
  314. package/node_modules/entities/lib/decode.js.map +1 -0
  315. package/node_modules/entities/lib/decode_codepoint.d.ts +19 -0
  316. package/node_modules/entities/lib/decode_codepoint.d.ts.map +1 -0
  317. package/node_modules/entities/lib/decode_codepoint.js +76 -0
  318. package/node_modules/entities/lib/decode_codepoint.js.map +1 -0
  319. package/node_modules/entities/lib/encode.d.ts +22 -0
  320. package/node_modules/entities/lib/encode.d.ts.map +1 -0
  321. package/node_modules/entities/lib/encode.js +77 -0
  322. package/node_modules/entities/lib/encode.js.map +1 -0
  323. package/node_modules/entities/lib/escape.d.ts +43 -0
  324. package/node_modules/entities/lib/escape.d.ts.map +1 -0
  325. package/node_modules/entities/lib/escape.js +122 -0
  326. package/node_modules/entities/lib/escape.js.map +1 -0
  327. package/node_modules/entities/lib/esm/decode.d.ts +211 -0
  328. package/node_modules/entities/lib/esm/decode.d.ts.map +1 -0
  329. package/node_modules/entities/lib/esm/decode.js +496 -0
  330. package/node_modules/entities/lib/esm/decode.js.map +1 -0
  331. package/node_modules/entities/lib/esm/decode_codepoint.d.ts +19 -0
  332. package/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +1 -0
  333. package/node_modules/entities/lib/esm/decode_codepoint.js +71 -0
  334. package/node_modules/entities/lib/esm/decode_codepoint.js.map +1 -0
  335. package/node_modules/entities/lib/esm/encode.d.ts +22 -0
  336. package/node_modules/entities/lib/esm/encode.d.ts.map +1 -0
  337. package/node_modules/entities/lib/esm/encode.js +69 -0
  338. package/node_modules/entities/lib/esm/encode.js.map +1 -0
  339. package/node_modules/entities/lib/esm/escape.d.ts +43 -0
  340. package/node_modules/entities/lib/esm/escape.d.ts.map +1 -0
  341. package/node_modules/entities/lib/esm/escape.js +116 -0
  342. package/node_modules/entities/lib/esm/escape.js.map +1 -0
  343. package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +3 -0
  344. package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +1 -0
  345. package/node_modules/entities/lib/esm/generated/decode-data-html.js +7 -0
  346. package/node_modules/entities/lib/esm/generated/decode-data-html.js.map +1 -0
  347. package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +3 -0
  348. package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +1 -0
  349. package/node_modules/entities/lib/esm/generated/decode-data-xml.js +7 -0
  350. package/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +1 -0
  351. package/node_modules/entities/lib/esm/generated/encode-html.d.ts +8 -0
  352. package/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +1 -0
  353. package/node_modules/entities/lib/esm/generated/encode-html.js +10 -0
  354. package/node_modules/entities/lib/esm/generated/encode-html.js.map +1 -0
  355. package/node_modules/entities/lib/esm/index.d.ts +96 -0
  356. package/node_modules/entities/lib/esm/index.d.ts.map +1 -0
  357. package/node_modules/entities/lib/esm/index.js +99 -0
  358. package/node_modules/entities/lib/esm/index.js.map +1 -0
  359. package/node_modules/entities/lib/esm/package.json +1 -0
  360. package/node_modules/entities/lib/generated/decode-data-html.d.ts +3 -0
  361. package/node_modules/entities/lib/generated/decode-data-html.d.ts.map +1 -0
  362. package/node_modules/entities/lib/generated/decode-data-html.js +9 -0
  363. package/node_modules/entities/lib/generated/decode-data-html.js.map +1 -0
  364. package/node_modules/entities/lib/generated/decode-data-xml.d.ts +3 -0
  365. package/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +1 -0
  366. package/node_modules/entities/lib/generated/decode-data-xml.js +9 -0
  367. package/node_modules/entities/lib/generated/decode-data-xml.js.map +1 -0
  368. package/node_modules/entities/lib/generated/encode-html.d.ts +8 -0
  369. package/node_modules/entities/lib/generated/encode-html.d.ts.map +1 -0
  370. package/node_modules/entities/lib/generated/encode-html.js +12 -0
  371. package/node_modules/entities/lib/generated/encode-html.js.map +1 -0
  372. package/node_modules/entities/lib/index.d.ts +96 -0
  373. package/node_modules/entities/lib/index.d.ts.map +1 -0
  374. package/node_modules/entities/lib/index.js +126 -0
  375. package/node_modules/entities/lib/index.js.map +1 -0
  376. package/node_modules/entities/package.json +90 -0
  377. package/node_modules/entities/readme.md +122 -0
  378. package/node_modules/he/LICENSE-MIT.txt +20 -0
  379. package/node_modules/he/README.md +379 -0
  380. package/node_modules/he/bin/he +148 -0
  381. package/node_modules/he/he.js +345 -0
  382. package/node_modules/he/man/he.1 +78 -0
  383. package/node_modules/he/package.json +58 -0
  384. package/node_modules/node-html-parser/CHANGELOG.md +137 -0
  385. package/node_modules/node-html-parser/LICENSE +7 -0
  386. package/node_modules/node-html-parser/README.md +365 -0
  387. package/node_modules/node-html-parser/dist/back.d.ts +1 -0
  388. package/node_modules/node-html-parser/dist/back.js +6 -0
  389. package/node_modules/node-html-parser/dist/index.d.ts +20 -0
  390. package/node_modules/node-html-parser/dist/index.js +32 -0
  391. package/node_modules/node-html-parser/dist/main.js +1646 -0
  392. package/node_modules/node-html-parser/dist/matcher.d.ts +6 -0
  393. package/node_modules/node-html-parser/dist/matcher.js +106 -0
  394. package/node_modules/node-html-parser/dist/nodes/comment.d.ts +20 -0
  395. package/node_modules/node-html-parser/dist/nodes/comment.js +57 -0
  396. package/node_modules/node-html-parser/dist/nodes/html.d.ts +240 -0
  397. package/node_modules/node-html-parser/dist/nodes/html.js +1218 -0
  398. package/node_modules/node-html-parser/dist/nodes/node.d.ts +24 -0
  399. package/node_modules/node-html-parser/dist/nodes/node.js +52 -0
  400. package/node_modules/node-html-parser/dist/nodes/text.d.ts +44 -0
  401. package/node_modules/node-html-parser/dist/nodes/text.js +144 -0
  402. package/node_modules/node-html-parser/dist/nodes/type.d.ts +6 -0
  403. package/node_modules/node-html-parser/dist/nodes/type.js +9 -0
  404. package/node_modules/node-html-parser/dist/parse.d.ts +1 -0
  405. package/node_modules/node-html-parser/dist/parse.js +5 -0
  406. package/node_modules/node-html-parser/dist/valid.d.ts +6 -0
  407. package/node_modules/node-html-parser/dist/valid.js +13 -0
  408. package/node_modules/node-html-parser/dist/void-tag.d.ts +7 -0
  409. package/node_modules/node-html-parser/dist/void-tag.js +29 -0
  410. package/node_modules/node-html-parser/package.json +114 -0
  411. package/node_modules/nth-check/LICENSE +11 -0
  412. package/node_modules/nth-check/README.md +136 -0
  413. package/node_modules/nth-check/lib/compile.d.ts +55 -0
  414. package/node_modules/nth-check/lib/compile.d.ts.map +1 -0
  415. package/node_modules/nth-check/lib/compile.js +121 -0
  416. package/node_modules/nth-check/lib/compile.js.map +1 -0
  417. package/node_modules/nth-check/lib/esm/compile.d.ts +55 -0
  418. package/node_modules/nth-check/lib/esm/compile.d.ts.map +1 -0
  419. package/node_modules/nth-check/lib/esm/compile.js +113 -0
  420. package/node_modules/nth-check/lib/esm/compile.js.map +1 -0
  421. package/node_modules/nth-check/lib/esm/index.d.ts +59 -0
  422. package/node_modules/nth-check/lib/esm/index.d.ts.map +1 -0
  423. package/node_modules/nth-check/lib/esm/index.js +63 -0
  424. package/node_modules/nth-check/lib/esm/index.js.map +1 -0
  425. package/node_modules/nth-check/lib/esm/package.json +1 -0
  426. package/node_modules/nth-check/lib/esm/parse.d.ts +9 -0
  427. package/node_modules/nth-check/lib/esm/parse.d.ts.map +1 -0
  428. package/node_modules/nth-check/lib/esm/parse.js +73 -0
  429. package/node_modules/nth-check/lib/esm/parse.js.map +1 -0
  430. package/node_modules/nth-check/lib/index.d.ts +59 -0
  431. package/node_modules/nth-check/lib/index.d.ts.map +1 -0
  432. package/node_modules/nth-check/lib/index.js +70 -0
  433. package/node_modules/nth-check/lib/index.js.map +1 -0
  434. package/node_modules/nth-check/lib/parse.d.ts +9 -0
  435. package/node_modules/nth-check/lib/parse.d.ts.map +1 -0
  436. package/node_modules/nth-check/lib/parse.js +77 -0
  437. package/node_modules/nth-check/lib/parse.js.map +1 -0
  438. package/node_modules/nth-check/package.json +78 -0
  439. package/package.json +154 -0
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generate = exports.compile = void 0;
7
+ var boolbase_1 = __importDefault(require("boolbase"));
8
+ /**
9
+ * Returns a function that checks if an elements index matches the given rule
10
+ * highly optimized to return the fastest solution.
11
+ *
12
+ * @param parsed A tuple [a, b], as returned by `parse`.
13
+ * @returns A highly optimized function that returns whether an index matches the nth-check.
14
+ * @example
15
+ *
16
+ * ```js
17
+ * const check = nthCheck.compile([2, 3]);
18
+ *
19
+ * check(0); // `false`
20
+ * check(1); // `false`
21
+ * check(2); // `true`
22
+ * check(3); // `false`
23
+ * check(4); // `true`
24
+ * check(5); // `false`
25
+ * check(6); // `true`
26
+ * ```
27
+ */
28
+ function compile(parsed) {
29
+ var a = parsed[0];
30
+ // Subtract 1 from `b`, to convert from one- to zero-indexed.
31
+ var b = parsed[1] - 1;
32
+ /*
33
+ * When `b <= 0`, `a * n` won't be lead to any matches for `a < 0`.
34
+ * Besides, the specification states that no elements are
35
+ * matched when `a` and `b` are 0.
36
+ *
37
+ * `b < 0` here as we subtracted 1 from `b` above.
38
+ */
39
+ if (b < 0 && a <= 0)
40
+ return boolbase_1.default.falseFunc;
41
+ // When `a` is in the range -1..1, it matches any element (so only `b` is checked).
42
+ if (a === -1)
43
+ return function (index) { return index <= b; };
44
+ if (a === 0)
45
+ return function (index) { return index === b; };
46
+ // When `b <= 0` and `a === 1`, they match any element.
47
+ if (a === 1)
48
+ return b < 0 ? boolbase_1.default.trueFunc : function (index) { return index >= b; };
49
+ /*
50
+ * Otherwise, modulo can be used to check if there is a match.
51
+ *
52
+ * Modulo doesn't care about the sign, so let's use `a`s absolute value.
53
+ */
54
+ var absA = Math.abs(a);
55
+ // Get `b mod a`, + a if this is negative.
56
+ var bMod = ((b % absA) + absA) % absA;
57
+ return a > 1
58
+ ? function (index) { return index >= b && index % absA === bMod; }
59
+ : function (index) { return index <= b && index % absA === bMod; };
60
+ }
61
+ exports.compile = compile;
62
+ /**
63
+ * Returns a function that produces a monotonously increasing sequence of indices.
64
+ *
65
+ * If the sequence has an end, the returned function will return `null` after
66
+ * the last index in the sequence.
67
+ *
68
+ * @param parsed A tuple [a, b], as returned by `parse`.
69
+ * @returns A function that produces a sequence of indices.
70
+ * @example <caption>Always increasing (2n+3)</caption>
71
+ *
72
+ * ```js
73
+ * const gen = nthCheck.generate([2, 3])
74
+ *
75
+ * gen() // `1`
76
+ * gen() // `3`
77
+ * gen() // `5`
78
+ * gen() // `8`
79
+ * gen() // `11`
80
+ * ```
81
+ *
82
+ * @example <caption>With end value (-2n+10)</caption>
83
+ *
84
+ * ```js
85
+ *
86
+ * const gen = nthCheck.generate([-2, 5]);
87
+ *
88
+ * gen() // 0
89
+ * gen() // 2
90
+ * gen() // 4
91
+ * gen() // null
92
+ * ```
93
+ */
94
+ function generate(parsed) {
95
+ var a = parsed[0];
96
+ // Subtract 1 from `b`, to convert from one- to zero-indexed.
97
+ var b = parsed[1] - 1;
98
+ var n = 0;
99
+ // Make sure to always return an increasing sequence
100
+ if (a < 0) {
101
+ var aPos_1 = -a;
102
+ // Get `b mod a`
103
+ var minValue_1 = ((b % aPos_1) + aPos_1) % aPos_1;
104
+ return function () {
105
+ var val = minValue_1 + aPos_1 * n++;
106
+ return val > b ? null : val;
107
+ };
108
+ }
109
+ if (a === 0)
110
+ return b < 0
111
+ ? // There are no result — always return `null`
112
+ function () { return null; }
113
+ : // Return `b` exactly once
114
+ function () { return (n++ === 0 ? b : null); };
115
+ if (b < 0) {
116
+ b += a * Math.ceil(-b / a);
117
+ }
118
+ return function () { return a * n++ + b; };
119
+ }
120
+ exports.generate = generate;
121
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["compile.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Returns a function that checks if an elements index matches the given rule
3
+ * highly optimized to return the fastest solution.
4
+ *
5
+ * @param parsed A tuple [a, b], as returned by `parse`.
6
+ * @returns A highly optimized function that returns whether an index matches the nth-check.
7
+ * @example
8
+ *
9
+ * ```js
10
+ * const check = nthCheck.compile([2, 3]);
11
+ *
12
+ * check(0); // `false`
13
+ * check(1); // `false`
14
+ * check(2); // `true`
15
+ * check(3); // `false`
16
+ * check(4); // `true`
17
+ * check(5); // `false`
18
+ * check(6); // `true`
19
+ * ```
20
+ */
21
+ export declare function compile(parsed: [a: number, b: number]): (index: number) => boolean;
22
+ /**
23
+ * Returns a function that produces a monotonously increasing sequence of indices.
24
+ *
25
+ * If the sequence has an end, the returned function will return `null` after
26
+ * the last index in the sequence.
27
+ *
28
+ * @param parsed A tuple [a, b], as returned by `parse`.
29
+ * @returns A function that produces a sequence of indices.
30
+ * @example <caption>Always increasing (2n+3)</caption>
31
+ *
32
+ * ```js
33
+ * const gen = nthCheck.generate([2, 3])
34
+ *
35
+ * gen() // `1`
36
+ * gen() // `3`
37
+ * gen() // `5`
38
+ * gen() // `8`
39
+ * gen() // `11`
40
+ * ```
41
+ *
42
+ * @example <caption>With end value (-2n+10)</caption>
43
+ *
44
+ * ```js
45
+ *
46
+ * const gen = nthCheck.generate([-2, 5]);
47
+ *
48
+ * gen() // 0
49
+ * gen() // 2
50
+ * gen() // 4
51
+ * gen() // null
52
+ * ```
53
+ */
54
+ export declare function generate(parsed: [a: number, b: number]): () => number | null;
55
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["compile.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CACnB,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,GAC/B,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAgC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,MAAM,MAAM,GAAG,IAAI,CA+B5E"}
@@ -0,0 +1,113 @@
1
+ import boolbase from "boolbase";
2
+ /**
3
+ * Returns a function that checks if an elements index matches the given rule
4
+ * highly optimized to return the fastest solution.
5
+ *
6
+ * @param parsed A tuple [a, b], as returned by `parse`.
7
+ * @returns A highly optimized function that returns whether an index matches the nth-check.
8
+ * @example
9
+ *
10
+ * ```js
11
+ * const check = nthCheck.compile([2, 3]);
12
+ *
13
+ * check(0); // `false`
14
+ * check(1); // `false`
15
+ * check(2); // `true`
16
+ * check(3); // `false`
17
+ * check(4); // `true`
18
+ * check(5); // `false`
19
+ * check(6); // `true`
20
+ * ```
21
+ */
22
+ export function compile(parsed) {
23
+ const a = parsed[0];
24
+ // Subtract 1 from `b`, to convert from one- to zero-indexed.
25
+ const b = parsed[1] - 1;
26
+ /*
27
+ * When `b <= 0`, `a * n` won't be lead to any matches for `a < 0`.
28
+ * Besides, the specification states that no elements are
29
+ * matched when `a` and `b` are 0.
30
+ *
31
+ * `b < 0` here as we subtracted 1 from `b` above.
32
+ */
33
+ if (b < 0 && a <= 0)
34
+ return boolbase.falseFunc;
35
+ // When `a` is in the range -1..1, it matches any element (so only `b` is checked).
36
+ if (a === -1)
37
+ return (index) => index <= b;
38
+ if (a === 0)
39
+ return (index) => index === b;
40
+ // When `b <= 0` and `a === 1`, they match any element.
41
+ if (a === 1)
42
+ return b < 0 ? boolbase.trueFunc : (index) => index >= b;
43
+ /*
44
+ * Otherwise, modulo can be used to check if there is a match.
45
+ *
46
+ * Modulo doesn't care about the sign, so let's use `a`s absolute value.
47
+ */
48
+ const absA = Math.abs(a);
49
+ // Get `b mod a`, + a if this is negative.
50
+ const bMod = ((b % absA) + absA) % absA;
51
+ return a > 1
52
+ ? (index) => index >= b && index % absA === bMod
53
+ : (index) => index <= b && index % absA === bMod;
54
+ }
55
+ /**
56
+ * Returns a function that produces a monotonously increasing sequence of indices.
57
+ *
58
+ * If the sequence has an end, the returned function will return `null` after
59
+ * the last index in the sequence.
60
+ *
61
+ * @param parsed A tuple [a, b], as returned by `parse`.
62
+ * @returns A function that produces a sequence of indices.
63
+ * @example <caption>Always increasing (2n+3)</caption>
64
+ *
65
+ * ```js
66
+ * const gen = nthCheck.generate([2, 3])
67
+ *
68
+ * gen() // `1`
69
+ * gen() // `3`
70
+ * gen() // `5`
71
+ * gen() // `8`
72
+ * gen() // `11`
73
+ * ```
74
+ *
75
+ * @example <caption>With end value (-2n+10)</caption>
76
+ *
77
+ * ```js
78
+ *
79
+ * const gen = nthCheck.generate([-2, 5]);
80
+ *
81
+ * gen() // 0
82
+ * gen() // 2
83
+ * gen() // 4
84
+ * gen() // null
85
+ * ```
86
+ */
87
+ export function generate(parsed) {
88
+ const a = parsed[0];
89
+ // Subtract 1 from `b`, to convert from one- to zero-indexed.
90
+ let b = parsed[1] - 1;
91
+ let n = 0;
92
+ // Make sure to always return an increasing sequence
93
+ if (a < 0) {
94
+ const aPos = -a;
95
+ // Get `b mod a`
96
+ const minValue = ((b % aPos) + aPos) % aPos;
97
+ return () => {
98
+ const val = minValue + aPos * n++;
99
+ return val > b ? null : val;
100
+ };
101
+ }
102
+ if (a === 0)
103
+ return b < 0
104
+ ? // There are no result — always return `null`
105
+ () => null
106
+ : // Return `b` exactly once
107
+ () => (n++ === 0 ? b : null);
108
+ if (b < 0) {
109
+ b += a * Math.ceil(-b / a);
110
+ }
111
+ return () => a * n++ + b;
112
+ }
113
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["compile.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,OAAO,CACnB,MAA8B;IAE9B,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,6DAA6D;IAC7D,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAExB;;;;;;OAMG;IACH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAC,SAAS,CAAC;IAE/C,mFAAmF;IACnF,IAAI,CAAC,KAAK,CAAC,CAAC;QAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC;IAC3C,uDAAuD;IACvD,IAAI,CAAC,KAAK,CAAC;QAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;IAEtE;;;;OAIG;IACH,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzB,0CAA0C;IAC1C,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAExC,OAAO,CAAC,GAAG,CAAC;QACR,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,KAAK,IAAI;QAChD,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,KAAK,IAAI,CAAC;AACzD,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,QAAQ,CAAC,MAA8B;IACnD,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACpB,6DAA6D;IAC7D,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEtB,IAAI,CAAC,GAAG,CAAC,CAAC;IAEV,oDAAoD;IACpD,IAAI,CAAC,GAAG,CAAC,EAAE;QACP,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC;QAChB,gBAAgB;QAChB,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;QAC5C,OAAO,GAAG,EAAE;YACR,MAAM,GAAG,GAAG,QAAQ,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;YAElC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;QAChC,CAAC,CAAC;KACL;IAED,IAAI,CAAC,KAAK,CAAC;QACP,OAAO,CAAC,GAAG,CAAC;YACR,CAAC,CAAC,6CAA6C;gBAC7C,GAAG,EAAE,CAAC,IAAI;YACZ,CAAC,CAAC,0BAA0B;gBAC1B,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEvC,IAAI,CAAC,GAAG,CAAC,EAAE;QACP,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;KAC9B;IAED,OAAO,GAAG,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,59 @@
1
+ import { parse } from "./parse.js";
2
+ import { compile, generate } from "./compile.js";
3
+ export { parse, compile, generate };
4
+ /**
5
+ * Parses and compiles a formula to a highly optimized function.
6
+ * Combination of {@link parse} and {@link compile}.
7
+ *
8
+ * If the formula doesn't match any elements,
9
+ * it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
10
+ * Otherwise, a function accepting an _index_ is returned, which returns
11
+ * whether or not the passed _index_ matches the formula.
12
+ *
13
+ * Note: The nth-rule starts counting at `1`, the returned function at `0`.
14
+ *
15
+ * @param formula The formula to compile.
16
+ * @example
17
+ * const check = nthCheck("2n+3");
18
+ *
19
+ * check(0); // `false`
20
+ * check(1); // `false`
21
+ * check(2); // `true`
22
+ * check(3); // `false`
23
+ * check(4); // `true`
24
+ * check(5); // `false`
25
+ * check(6); // `true`
26
+ */
27
+ export default function nthCheck(formula: string): (index: number) => boolean;
28
+ /**
29
+ * Parses and compiles a formula to a generator that produces a sequence of indices.
30
+ * Combination of {@link parse} and {@link generate}.
31
+ *
32
+ * @param formula The formula to compile.
33
+ * @returns A function that produces a sequence of indices.
34
+ * @example <caption>Always increasing</caption>
35
+ *
36
+ * ```js
37
+ * const gen = nthCheck.sequence('2n+3')
38
+ *
39
+ * gen() // `1`
40
+ * gen() // `3`
41
+ * gen() // `5`
42
+ * gen() // `8`
43
+ * gen() // `11`
44
+ * ```
45
+ *
46
+ * @example <caption>With end value</caption>
47
+ *
48
+ * ```js
49
+ *
50
+ * const gen = nthCheck.sequence('-2n+5');
51
+ *
52
+ * gen() // 0
53
+ * gen() // 2
54
+ * gen() // 4
55
+ * gen() // null
56
+ * ```
57
+ */
58
+ export declare function sequence(formula: string): () => number | null;
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAE5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,MAAM,GAAG,IAAI,CAE7D"}
@@ -0,0 +1,63 @@
1
+ import { parse } from "./parse.js";
2
+ import { compile, generate } from "./compile.js";
3
+ export { parse, compile, generate };
4
+ /**
5
+ * Parses and compiles a formula to a highly optimized function.
6
+ * Combination of {@link parse} and {@link compile}.
7
+ *
8
+ * If the formula doesn't match any elements,
9
+ * it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
10
+ * Otherwise, a function accepting an _index_ is returned, which returns
11
+ * whether or not the passed _index_ matches the formula.
12
+ *
13
+ * Note: The nth-rule starts counting at `1`, the returned function at `0`.
14
+ *
15
+ * @param formula The formula to compile.
16
+ * @example
17
+ * const check = nthCheck("2n+3");
18
+ *
19
+ * check(0); // `false`
20
+ * check(1); // `false`
21
+ * check(2); // `true`
22
+ * check(3); // `false`
23
+ * check(4); // `true`
24
+ * check(5); // `false`
25
+ * check(6); // `true`
26
+ */
27
+ export default function nthCheck(formula) {
28
+ return compile(parse(formula));
29
+ }
30
+ /**
31
+ * Parses and compiles a formula to a generator that produces a sequence of indices.
32
+ * Combination of {@link parse} and {@link generate}.
33
+ *
34
+ * @param formula The formula to compile.
35
+ * @returns A function that produces a sequence of indices.
36
+ * @example <caption>Always increasing</caption>
37
+ *
38
+ * ```js
39
+ * const gen = nthCheck.sequence('2n+3')
40
+ *
41
+ * gen() // `1`
42
+ * gen() // `3`
43
+ * gen() // `5`
44
+ * gen() // `8`
45
+ * gen() // `11`
46
+ * ```
47
+ *
48
+ * @example <caption>With end value</caption>
49
+ *
50
+ * ```js
51
+ *
52
+ * const gen = nthCheck.sequence('-2n+5');
53
+ *
54
+ * gen() // 0
55
+ * gen() // 2
56
+ * gen() // 4
57
+ * gen() // null
58
+ * ```
59
+ */
60
+ export function sequence(formula) {
61
+ return generate(parse(formula));
62
+ }
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,OAAe;IAC5C,OAAO,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAe;IACpC,OAAO,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Parses an expression.
3
+ *
4
+ * @throws An `Error` if parsing fails.
5
+ * @returns An array containing the integer step size and the integer offset of the nth rule.
6
+ * @example nthCheck.parse("2n+3"); // returns [2, 3]
7
+ */
8
+ export declare function parse(formula: string): [a: number, b: number];
9
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["parse.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,CA6E7D"}
@@ -0,0 +1,73 @@
1
+ // Following http://www.w3.org/TR/css3-selectors/#nth-child-pseudo
2
+ // Whitespace as per https://www.w3.org/TR/selectors-3/#lex is " \t\r\n\f"
3
+ const whitespace = new Set([9, 10, 12, 13, 32]);
4
+ const ZERO = "0".charCodeAt(0);
5
+ const NINE = "9".charCodeAt(0);
6
+ /**
7
+ * Parses an expression.
8
+ *
9
+ * @throws An `Error` if parsing fails.
10
+ * @returns An array containing the integer step size and the integer offset of the nth rule.
11
+ * @example nthCheck.parse("2n+3"); // returns [2, 3]
12
+ */
13
+ export function parse(formula) {
14
+ formula = formula.trim().toLowerCase();
15
+ if (formula === "even") {
16
+ return [2, 0];
17
+ }
18
+ else if (formula === "odd") {
19
+ return [2, 1];
20
+ }
21
+ // Parse [ ['-'|'+']? INTEGER? {N} [ S* ['-'|'+'] S* INTEGER ]?
22
+ let idx = 0;
23
+ let a = 0;
24
+ let sign = readSign();
25
+ let number = readNumber();
26
+ if (idx < formula.length && formula.charAt(idx) === "n") {
27
+ idx++;
28
+ a = sign * (number !== null && number !== void 0 ? number : 1);
29
+ skipWhitespace();
30
+ if (idx < formula.length) {
31
+ sign = readSign();
32
+ skipWhitespace();
33
+ number = readNumber();
34
+ }
35
+ else {
36
+ sign = number = 0;
37
+ }
38
+ }
39
+ // Throw if there is anything else
40
+ if (number === null || idx < formula.length) {
41
+ throw new Error(`n-th rule couldn't be parsed ('${formula}')`);
42
+ }
43
+ return [a, sign * number];
44
+ function readSign() {
45
+ if (formula.charAt(idx) === "-") {
46
+ idx++;
47
+ return -1;
48
+ }
49
+ if (formula.charAt(idx) === "+") {
50
+ idx++;
51
+ }
52
+ return 1;
53
+ }
54
+ function readNumber() {
55
+ const start = idx;
56
+ let value = 0;
57
+ while (idx < formula.length &&
58
+ formula.charCodeAt(idx) >= ZERO &&
59
+ formula.charCodeAt(idx) <= NINE) {
60
+ value = value * 10 + (formula.charCodeAt(idx) - ZERO);
61
+ idx++;
62
+ }
63
+ // Return `null` if we didn't read anything.
64
+ return idx === start ? null : value;
65
+ }
66
+ function skipWhitespace() {
67
+ while (idx < formula.length &&
68
+ whitespace.has(formula.charCodeAt(idx))) {
69
+ idx++;
70
+ }
71
+ }
72
+ }
73
+ //# sourceMappingURL=parse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.js","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["parse.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,59 @@
1
+ import { parse } from "./parse.js";
2
+ import { compile, generate } from "./compile.js";
3
+ export { parse, compile, generate };
4
+ /**
5
+ * Parses and compiles a formula to a highly optimized function.
6
+ * Combination of {@link parse} and {@link compile}.
7
+ *
8
+ * If the formula doesn't match any elements,
9
+ * it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
10
+ * Otherwise, a function accepting an _index_ is returned, which returns
11
+ * whether or not the passed _index_ matches the formula.
12
+ *
13
+ * Note: The nth-rule starts counting at `1`, the returned function at `0`.
14
+ *
15
+ * @param formula The formula to compile.
16
+ * @example
17
+ * const check = nthCheck("2n+3");
18
+ *
19
+ * check(0); // `false`
20
+ * check(1); // `false`
21
+ * check(2); // `true`
22
+ * check(3); // `false`
23
+ * check(4); // `true`
24
+ * check(5); // `false`
25
+ * check(6); // `true`
26
+ */
27
+ export default function nthCheck(formula: string): (index: number) => boolean;
28
+ /**
29
+ * Parses and compiles a formula to a generator that produces a sequence of indices.
30
+ * Combination of {@link parse} and {@link generate}.
31
+ *
32
+ * @param formula The formula to compile.
33
+ * @returns A function that produces a sequence of indices.
34
+ * @example <caption>Always increasing</caption>
35
+ *
36
+ * ```js
37
+ * const gen = nthCheck.sequence('2n+3')
38
+ *
39
+ * gen() // `1`
40
+ * gen() // `3`
41
+ * gen() // `5`
42
+ * gen() // `8`
43
+ * gen() // `11`
44
+ * ```
45
+ *
46
+ * @example <caption>With end value</caption>
47
+ *
48
+ * ```js
49
+ *
50
+ * const gen = nthCheck.sequence('-2n+5');
51
+ *
52
+ * gen() // 0
53
+ * gen() // 2
54
+ * gen() // 4
55
+ * gen() // null
56
+ * ```
57
+ */
58
+ export declare function sequence(formula: string): () => number | null;
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAE5E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,MAAM,GAAG,IAAI,CAE7D"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sequence = exports.generate = exports.compile = exports.parse = void 0;
4
+ var parse_js_1 = require("./parse.js");
5
+ Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return parse_js_1.parse; } });
6
+ var compile_js_1 = require("./compile.js");
7
+ Object.defineProperty(exports, "compile", { enumerable: true, get: function () { return compile_js_1.compile; } });
8
+ Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return compile_js_1.generate; } });
9
+ /**
10
+ * Parses and compiles a formula to a highly optimized function.
11
+ * Combination of {@link parse} and {@link compile}.
12
+ *
13
+ * If the formula doesn't match any elements,
14
+ * it returns [`boolbase`](https://github.com/fb55/boolbase)'s `falseFunc`.
15
+ * Otherwise, a function accepting an _index_ is returned, which returns
16
+ * whether or not the passed _index_ matches the formula.
17
+ *
18
+ * Note: The nth-rule starts counting at `1`, the returned function at `0`.
19
+ *
20
+ * @param formula The formula to compile.
21
+ * @example
22
+ * const check = nthCheck("2n+3");
23
+ *
24
+ * check(0); // `false`
25
+ * check(1); // `false`
26
+ * check(2); // `true`
27
+ * check(3); // `false`
28
+ * check(4); // `true`
29
+ * check(5); // `false`
30
+ * check(6); // `true`
31
+ */
32
+ function nthCheck(formula) {
33
+ return (0, compile_js_1.compile)((0, parse_js_1.parse)(formula));
34
+ }
35
+ exports.default = nthCheck;
36
+ /**
37
+ * Parses and compiles a formula to a generator that produces a sequence of indices.
38
+ * Combination of {@link parse} and {@link generate}.
39
+ *
40
+ * @param formula The formula to compile.
41
+ * @returns A function that produces a sequence of indices.
42
+ * @example <caption>Always increasing</caption>
43
+ *
44
+ * ```js
45
+ * const gen = nthCheck.sequence('2n+3')
46
+ *
47
+ * gen() // `1`
48
+ * gen() // `3`
49
+ * gen() // `5`
50
+ * gen() // `8`
51
+ * gen() // `11`
52
+ * ```
53
+ *
54
+ * @example <caption>With end value</caption>
55
+ *
56
+ * ```js
57
+ *
58
+ * const gen = nthCheck.sequence('-2n+5');
59
+ *
60
+ * gen() // 0
61
+ * gen() // 2
62
+ * gen() // 4
63
+ * gen() // null
64
+ * ```
65
+ */
66
+ function sequence(formula) {
67
+ return (0, compile_js_1.generate)((0, parse_js_1.parse)(formula));
68
+ }
69
+ exports.sequence = sequence;
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"https://raw.githubusercontent.com/fb55/nth-check/639fd2a4000b69f82350aad8c34cb43f77e483ba/src/","sources":["index.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AAG1B,sFAHA,gBAAK,OAGA;AAFd,2CAAiD;AAEjC,wFAFP,oBAAO,OAEO;AAAE,yFAFP,qBAAQ,OAEO;AAEjC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAwB,QAAQ,CAAC,OAAe;IAC5C,OAAO,IAAA,oBAAO,EAAC,IAAA,gBAAK,EAAC,OAAO,CAAC,CAAC,CAAC;AACnC,CAAC;AAFD,2BAEC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,QAAQ,CAAC,OAAe;IACpC,OAAO,IAAA,qBAAQ,EAAC,IAAA,gBAAK,EAAC,OAAO,CAAC,CAAC,CAAC;AACpC,CAAC;AAFD,4BAEC"}