@gridsheet/react-core 0.12.4-alpha.2 → 0.12.4-beta.0

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 (385) hide show
  1. package/dist/components/Cell.d.ts +8 -0
  2. package/dist/components/Cell.d.ts.map +1 -0
  3. package/dist/components/Cell.js +200 -0
  4. package/dist/components/Cell.js.map +1 -0
  5. package/dist/components/ContextMenu.d.ts +3 -0
  6. package/dist/components/ContextMenu.d.ts.map +1 -0
  7. package/dist/components/ContextMenu.js +207 -0
  8. package/dist/components/ContextMenu.js.map +1 -0
  9. package/dist/components/Editor.d.ts +3 -0
  10. package/dist/components/Editor.d.ts.map +1 -0
  11. package/dist/components/Editor.js +301 -0
  12. package/dist/components/Editor.js.map +1 -0
  13. package/dist/components/Emitter.d.ts +9 -0
  14. package/dist/components/Emitter.d.ts.map +1 -0
  15. package/dist/components/Emitter.js +26 -0
  16. package/dist/components/Emitter.js.map +1 -0
  17. package/dist/components/GridSheet.d.ts +4 -0
  18. package/dist/components/GridSheet.d.ts.map +1 -0
  19. package/dist/components/GridSheet.js +110 -0
  20. package/dist/components/GridSheet.js.map +1 -0
  21. package/dist/components/HeaderLeftCell.d.ts +7 -0
  22. package/dist/components/HeaderLeftCell.d.ts.map +1 -0
  23. package/dist/components/HeaderLeftCell.js +66 -0
  24. package/dist/components/HeaderLeftCell.js.map +1 -0
  25. package/dist/components/HeaderTopCell.d.ts +7 -0
  26. package/dist/components/HeaderTopCell.d.ts.map +1 -0
  27. package/dist/components/HeaderTopCell.js +67 -0
  28. package/dist/components/HeaderTopCell.js.map +1 -0
  29. package/dist/components/Resizer.d.ts +3 -0
  30. package/dist/components/Resizer.d.ts.map +1 -0
  31. package/dist/components/Resizer.js +85 -0
  32. package/dist/components/Resizer.js.map +1 -0
  33. package/dist/components/SearchBox.d.ts +3 -0
  34. package/dist/components/SearchBox.d.ts.map +1 -0
  35. package/dist/components/SearchBox.js +54 -0
  36. package/dist/components/SearchBox.js.map +1 -0
  37. package/dist/components/StoreInitializer.d.ts +4 -0
  38. package/dist/components/StoreInitializer.d.ts.map +1 -0
  39. package/dist/components/StoreInitializer.js +68 -0
  40. package/dist/components/StoreInitializer.js.map +1 -0
  41. package/dist/components/Tabular.d.ts +9 -0
  42. package/dist/components/Tabular.d.ts.map +1 -0
  43. package/dist/components/Tabular.js +84 -0
  44. package/dist/components/Tabular.js.map +1 -0
  45. package/dist/constants.d.ts +18 -0
  46. package/dist/constants.d.ts.map +1 -0
  47. package/dist/constants.js +24 -0
  48. package/dist/constants.js.map +1 -0
  49. package/dist/formula/evaluator.d.ts +91 -0
  50. package/dist/formula/evaluator.d.ts.map +1 -0
  51. package/dist/formula/evaluator.js +541 -0
  52. package/dist/formula/evaluator.js.map +1 -0
  53. package/dist/formula/functions/__base.d.ts +23 -0
  54. package/dist/formula/functions/__base.d.ts.map +1 -0
  55. package/dist/formula/functions/__base.js +16 -0
  56. package/dist/formula/functions/__base.js.map +1 -0
  57. package/dist/formula/functions/__utils.d.ts +6 -0
  58. package/dist/formula/functions/__utils.d.ts.map +1 -0
  59. package/dist/formula/functions/__utils.js +102 -0
  60. package/dist/formula/functions/__utils.js.map +1 -0
  61. package/dist/formula/functions/abs.d.ts +12 -0
  62. package/dist/formula/functions/abs.d.ts.map +1 -0
  63. package/dist/formula/functions/abs.js +21 -0
  64. package/dist/formula/functions/abs.js.map +1 -0
  65. package/dist/formula/functions/abs.spec.d.ts +2 -0
  66. package/dist/formula/functions/abs.spec.d.ts.map +1 -0
  67. package/dist/formula/functions/abs.spec.js +29 -0
  68. package/dist/formula/functions/abs.spec.js.map +1 -0
  69. package/dist/formula/functions/acos.d.ts +12 -0
  70. package/dist/formula/functions/acos.d.ts.map +1 -0
  71. package/dist/formula/functions/acos.js +29 -0
  72. package/dist/formula/functions/acos.js.map +1 -0
  73. package/dist/formula/functions/add.d.ts +13 -0
  74. package/dist/formula/functions/add.d.ts.map +1 -0
  75. package/dist/formula/functions/add.js +50 -0
  76. package/dist/formula/functions/add.js.map +1 -0
  77. package/dist/formula/functions/and.d.ts +19 -0
  78. package/dist/formula/functions/and.d.ts.map +1 -0
  79. package/dist/formula/functions/and.js +28 -0
  80. package/dist/formula/functions/and.js.map +1 -0
  81. package/dist/formula/functions/asin.d.ts +12 -0
  82. package/dist/formula/functions/asin.d.ts.map +1 -0
  83. package/dist/formula/functions/asin.js +29 -0
  84. package/dist/formula/functions/asin.js.map +1 -0
  85. package/dist/formula/functions/atan.d.ts +12 -0
  86. package/dist/formula/functions/atan.d.ts.map +1 -0
  87. package/dist/formula/functions/atan.js +26 -0
  88. package/dist/formula/functions/atan.js.map +1 -0
  89. package/dist/formula/functions/atan2.d.ts +12 -0
  90. package/dist/formula/functions/atan2.d.ts.map +1 -0
  91. package/dist/formula/functions/atan2.js +32 -0
  92. package/dist/formula/functions/atan2.js.map +1 -0
  93. package/dist/formula/functions/average.d.ts +19 -0
  94. package/dist/formula/functions/average.d.ts.map +1 -0
  95. package/dist/formula/functions/average.js +41 -0
  96. package/dist/formula/functions/average.js.map +1 -0
  97. package/dist/formula/functions/col.d.ts +14 -0
  98. package/dist/formula/functions/col.d.ts.map +1 -0
  99. package/dist/formula/functions/col.js +30 -0
  100. package/dist/formula/functions/col.js.map +1 -0
  101. package/dist/formula/functions/concat.d.ts +12 -0
  102. package/dist/formula/functions/concat.d.ts.map +1 -0
  103. package/dist/formula/functions/concat.js +27 -0
  104. package/dist/formula/functions/concat.js.map +1 -0
  105. package/dist/formula/functions/concatenate.d.ts +19 -0
  106. package/dist/formula/functions/concatenate.d.ts.map +1 -0
  107. package/dist/formula/functions/concatenate.js +25 -0
  108. package/dist/formula/functions/concatenate.js.map +1 -0
  109. package/dist/formula/functions/cos.d.ts +12 -0
  110. package/dist/formula/functions/cos.d.ts.map +1 -0
  111. package/dist/formula/functions/cos.js +26 -0
  112. package/dist/formula/functions/cos.js.map +1 -0
  113. package/dist/formula/functions/count.d.ts +19 -0
  114. package/dist/formula/functions/count.d.ts.map +1 -0
  115. package/dist/formula/functions/count.js +35 -0
  116. package/dist/formula/functions/count.js.map +1 -0
  117. package/dist/formula/functions/counta.d.ts +19 -0
  118. package/dist/formula/functions/counta.d.ts.map +1 -0
  119. package/dist/formula/functions/counta.js +35 -0
  120. package/dist/formula/functions/counta.js.map +1 -0
  121. package/dist/formula/functions/countif.d.ts +13 -0
  122. package/dist/formula/functions/countif.d.ts.map +1 -0
  123. package/dist/formula/functions/countif.js +30 -0
  124. package/dist/formula/functions/countif.js.map +1 -0
  125. package/dist/formula/functions/divide.d.ts +12 -0
  126. package/dist/formula/functions/divide.d.ts.map +1 -0
  127. package/dist/formula/functions/divide.js +33 -0
  128. package/dist/formula/functions/divide.js.map +1 -0
  129. package/dist/formula/functions/eq.d.ts +12 -0
  130. package/dist/formula/functions/eq.d.ts.map +1 -0
  131. package/dist/formula/functions/eq.js +25 -0
  132. package/dist/formula/functions/eq.js.map +1 -0
  133. package/dist/formula/functions/exp.d.ts +12 -0
  134. package/dist/formula/functions/exp.d.ts.map +1 -0
  135. package/dist/formula/functions/exp.js +28 -0
  136. package/dist/formula/functions/exp.js.map +1 -0
  137. package/dist/formula/functions/gt.d.ts +12 -0
  138. package/dist/formula/functions/gt.d.ts.map +1 -0
  139. package/dist/formula/functions/gt.js +27 -0
  140. package/dist/formula/functions/gt.js.map +1 -0
  141. package/dist/formula/functions/gte.d.ts +12 -0
  142. package/dist/formula/functions/gte.d.ts.map +1 -0
  143. package/dist/formula/functions/gte.js +27 -0
  144. package/dist/formula/functions/gte.js.map +1 -0
  145. package/dist/formula/functions/hlookup.d.ts +18 -0
  146. package/dist/formula/functions/hlookup.d.ts.map +1 -0
  147. package/dist/formula/functions/hlookup.js +74 -0
  148. package/dist/formula/functions/hlookup.js.map +1 -0
  149. package/dist/formula/functions/if.d.ts +17 -0
  150. package/dist/formula/functions/if.d.ts.map +1 -0
  151. package/dist/formula/functions/if.js +36 -0
  152. package/dist/formula/functions/if.js.map +1 -0
  153. package/dist/formula/functions/iferror.d.ts +20 -0
  154. package/dist/formula/functions/iferror.d.ts.map +1 -0
  155. package/dist/formula/functions/iferror.js +41 -0
  156. package/dist/formula/functions/iferror.js.map +1 -0
  157. package/dist/formula/functions/iferror.spec.d.ts +2 -0
  158. package/dist/formula/functions/iferror.spec.d.ts.map +1 -0
  159. package/dist/formula/functions/iferror.spec.js +61 -0
  160. package/dist/formula/functions/iferror.spec.js.map +1 -0
  161. package/dist/formula/functions/len.d.ts +12 -0
  162. package/dist/formula/functions/len.d.ts.map +1 -0
  163. package/dist/formula/functions/len.js +26 -0
  164. package/dist/formula/functions/len.js.map +1 -0
  165. package/dist/formula/functions/lenb.d.ts +12 -0
  166. package/dist/formula/functions/lenb.d.ts.map +1 -0
  167. package/dist/formula/functions/lenb.js +26 -0
  168. package/dist/formula/functions/lenb.js.map +1 -0
  169. package/dist/formula/functions/ln.d.ts +12 -0
  170. package/dist/formula/functions/ln.d.ts.map +1 -0
  171. package/dist/formula/functions/ln.js +29 -0
  172. package/dist/formula/functions/ln.js.map +1 -0
  173. package/dist/formula/functions/log.d.ts +12 -0
  174. package/dist/formula/functions/log.d.ts.map +1 -0
  175. package/dist/formula/functions/log.js +35 -0
  176. package/dist/formula/functions/log.js.map +1 -0
  177. package/dist/formula/functions/log10.d.ts +12 -0
  178. package/dist/formula/functions/log10.d.ts.map +1 -0
  179. package/dist/formula/functions/log10.js +29 -0
  180. package/dist/formula/functions/log10.js.map +1 -0
  181. package/dist/formula/functions/lt.d.ts +12 -0
  182. package/dist/formula/functions/lt.d.ts.map +1 -0
  183. package/dist/formula/functions/lt.js +27 -0
  184. package/dist/formula/functions/lt.js.map +1 -0
  185. package/dist/formula/functions/lte.d.ts +12 -0
  186. package/dist/formula/functions/lte.d.ts.map +1 -0
  187. package/dist/formula/functions/lte.js +27 -0
  188. package/dist/formula/functions/lte.js.map +1 -0
  189. package/dist/formula/functions/max.d.ts +19 -0
  190. package/dist/formula/functions/max.d.ts.map +1 -0
  191. package/dist/formula/functions/max.js +44 -0
  192. package/dist/formula/functions/max.js.map +1 -0
  193. package/dist/formula/functions/min.d.ts +19 -0
  194. package/dist/formula/functions/min.d.ts.map +1 -0
  195. package/dist/formula/functions/min.js +44 -0
  196. package/dist/formula/functions/min.js.map +1 -0
  197. package/dist/formula/functions/minus.d.ts +13 -0
  198. package/dist/formula/functions/minus.d.ts.map +1 -0
  199. package/dist/formula/functions/minus.js +50 -0
  200. package/dist/formula/functions/minus.js.map +1 -0
  201. package/dist/formula/functions/mod.d.ts +12 -0
  202. package/dist/formula/functions/mod.d.ts.map +1 -0
  203. package/dist/formula/functions/mod.js +31 -0
  204. package/dist/formula/functions/mod.js.map +1 -0
  205. package/dist/formula/functions/mod.spec.d.ts +2 -0
  206. package/dist/formula/functions/mod.spec.d.ts.map +1 -0
  207. package/dist/formula/functions/mod.spec.js +52 -0
  208. package/dist/formula/functions/mod.spec.js.map +1 -0
  209. package/dist/formula/functions/multiply.d.ts +12 -0
  210. package/dist/formula/functions/multiply.d.ts.map +1 -0
  211. package/dist/formula/functions/multiply.js +27 -0
  212. package/dist/formula/functions/multiply.js.map +1 -0
  213. package/dist/formula/functions/ne.d.ts +12 -0
  214. package/dist/formula/functions/ne.d.ts.map +1 -0
  215. package/dist/formula/functions/ne.js +25 -0
  216. package/dist/formula/functions/ne.js.map +1 -0
  217. package/dist/formula/functions/not.d.ts +12 -0
  218. package/dist/formula/functions/not.d.ts.map +1 -0
  219. package/dist/formula/functions/not.js +30 -0
  220. package/dist/formula/functions/not.js.map +1 -0
  221. package/dist/formula/functions/now.d.ts +9 -0
  222. package/dist/formula/functions/now.d.ts.map +1 -0
  223. package/dist/formula/functions/now.js +21 -0
  224. package/dist/formula/functions/now.js.map +1 -0
  225. package/dist/formula/functions/or.d.ts +19 -0
  226. package/dist/formula/functions/or.d.ts.map +1 -0
  227. package/dist/formula/functions/or.js +28 -0
  228. package/dist/formula/functions/or.js.map +1 -0
  229. package/dist/formula/functions/pi.d.ts +9 -0
  230. package/dist/formula/functions/pi.d.ts.map +1 -0
  231. package/dist/formula/functions/pi.js +19 -0
  232. package/dist/formula/functions/pi.js.map +1 -0
  233. package/dist/formula/functions/power.d.ts +12 -0
  234. package/dist/formula/functions/power.d.ts.map +1 -0
  235. package/dist/formula/functions/power.js +24 -0
  236. package/dist/formula/functions/power.js.map +1 -0
  237. package/dist/formula/functions/product.d.ts +19 -0
  238. package/dist/formula/functions/product.d.ts.map +1 -0
  239. package/dist/formula/functions/product.js +37 -0
  240. package/dist/formula/functions/product.js.map +1 -0
  241. package/dist/formula/functions/radians.d.ts +12 -0
  242. package/dist/formula/functions/radians.d.ts.map +1 -0
  243. package/dist/formula/functions/radians.js +26 -0
  244. package/dist/formula/functions/radians.js.map +1 -0
  245. package/dist/formula/functions/rand.d.ts +9 -0
  246. package/dist/formula/functions/rand.d.ts.map +1 -0
  247. package/dist/formula/functions/rand.js +19 -0
  248. package/dist/formula/functions/rand.js.map +1 -0
  249. package/dist/formula/functions/round.d.ts +17 -0
  250. package/dist/formula/functions/round.d.ts.map +1 -0
  251. package/dist/formula/functions/round.js +34 -0
  252. package/dist/formula/functions/round.js.map +1 -0
  253. package/dist/formula/functions/rounddown.d.ts +17 -0
  254. package/dist/formula/functions/rounddown.d.ts.map +1 -0
  255. package/dist/formula/functions/rounddown.js +34 -0
  256. package/dist/formula/functions/rounddown.js.map +1 -0
  257. package/dist/formula/functions/roundup.d.ts +17 -0
  258. package/dist/formula/functions/roundup.d.ts.map +1 -0
  259. package/dist/formula/functions/roundup.js +34 -0
  260. package/dist/formula/functions/roundup.js.map +1 -0
  261. package/dist/formula/functions/row.d.ts +14 -0
  262. package/dist/formula/functions/row.d.ts.map +1 -0
  263. package/dist/formula/functions/row.js +30 -0
  264. package/dist/formula/functions/row.js.map +1 -0
  265. package/dist/formula/functions/sin.d.ts +12 -0
  266. package/dist/formula/functions/sin.d.ts.map +1 -0
  267. package/dist/formula/functions/sin.js +26 -0
  268. package/dist/formula/functions/sin.js.map +1 -0
  269. package/dist/formula/functions/sqrt.d.ts +12 -0
  270. package/dist/formula/functions/sqrt.d.ts.map +1 -0
  271. package/dist/formula/functions/sqrt.js +29 -0
  272. package/dist/formula/functions/sqrt.js.map +1 -0
  273. package/dist/formula/functions/sum.d.ts +19 -0
  274. package/dist/formula/functions/sum.d.ts.map +1 -0
  275. package/dist/formula/functions/sum.js +44 -0
  276. package/dist/formula/functions/sum.js.map +1 -0
  277. package/dist/formula/functions/sum.spec.d.ts +2 -0
  278. package/dist/formula/functions/sum.spec.d.ts.map +1 -0
  279. package/dist/formula/functions/sum.spec.js +40 -0
  280. package/dist/formula/functions/sum.spec.js.map +1 -0
  281. package/dist/formula/functions/sumif.d.ts +18 -0
  282. package/dist/formula/functions/sumif.d.ts.map +1 -0
  283. package/dist/formula/functions/sumif.js +59 -0
  284. package/dist/formula/functions/sumif.js.map +1 -0
  285. package/dist/formula/functions/tan.d.ts +12 -0
  286. package/dist/formula/functions/tan.d.ts.map +1 -0
  287. package/dist/formula/functions/tan.js +26 -0
  288. package/dist/formula/functions/tan.js.map +1 -0
  289. package/dist/formula/functions/uminus.d.ts +12 -0
  290. package/dist/formula/functions/uminus.d.ts.map +1 -0
  291. package/dist/formula/functions/uminus.js +23 -0
  292. package/dist/formula/functions/uminus.js.map +1 -0
  293. package/dist/formula/functions/vlookup.d.ts +18 -0
  294. package/dist/formula/functions/vlookup.d.ts.map +1 -0
  295. package/dist/formula/functions/vlookup.js +74 -0
  296. package/dist/formula/functions/vlookup.js.map +1 -0
  297. package/dist/formula/mapping.d.ts +114 -0
  298. package/dist/formula/mapping.d.ts.map +1 -0
  299. package/dist/formula/mapping.js +114 -0
  300. package/dist/formula/mapping.js.map +1 -0
  301. package/dist/formula/solver.d.ts +12 -0
  302. package/dist/formula/solver.d.ts.map +1 -0
  303. package/dist/formula/solver.js +64 -0
  304. package/dist/formula/solver.js.map +1 -0
  305. package/dist/index.d.ts +12 -0
  306. package/dist/index.d.ts.map +1 -0
  307. package/dist/index.js +11 -5183
  308. package/dist/index.js.map +1 -0
  309. package/dist/lib/autofill.d.ts +17 -0
  310. package/dist/lib/autofill.d.ts.map +1 -0
  311. package/dist/lib/autofill.js +389 -0
  312. package/dist/lib/autofill.js.map +1 -0
  313. package/dist/lib/clipboard.d.ts +3 -0
  314. package/dist/lib/clipboard.d.ts.map +1 -0
  315. package/dist/lib/clipboard.js +45 -0
  316. package/dist/lib/clipboard.js.map +1 -0
  317. package/dist/lib/converters.d.ts +10 -0
  318. package/dist/lib/converters.d.ts.map +1 -0
  319. package/dist/lib/converters.js +127 -0
  320. package/dist/lib/converters.js.map +1 -0
  321. package/dist/lib/hooks.d.ts +1 -0
  322. package/dist/lib/hooks.d.ts.map +1 -0
  323. package/dist/lib/hooks.js +2 -0
  324. package/dist/lib/hooks.js.map +1 -0
  325. package/dist/lib/structs.d.ts +60 -0
  326. package/dist/lib/structs.d.ts.map +1 -0
  327. package/dist/lib/structs.js +251 -0
  328. package/dist/lib/structs.js.map +1 -0
  329. package/dist/lib/table.d.ts +297 -0
  330. package/dist/lib/table.d.ts.map +1 -0
  331. package/dist/lib/table.js +986 -0
  332. package/dist/lib/table.js.map +1 -0
  333. package/dist/lib/time.d.ts +14 -0
  334. package/dist/lib/time.d.ts.map +1 -0
  335. package/dist/lib/time.js +60 -0
  336. package/dist/lib/time.js.map +1 -0
  337. package/dist/lib/virtualization.d.ts +21 -0
  338. package/dist/lib/virtualization.d.ts.map +1 -0
  339. package/dist/lib/virtualization.js +120 -0
  340. package/dist/lib/virtualization.js.map +1 -0
  341. package/dist/parsers/core.d.ts +36 -0
  342. package/dist/parsers/core.d.ts.map +1 -0
  343. package/dist/parsers/core.js +123 -0
  344. package/dist/parsers/core.js.map +1 -0
  345. package/dist/renderers/checkbox.d.ts +5 -0
  346. package/dist/renderers/checkbox.d.ts.map +1 -0
  347. package/dist/renderers/checkbox.js +10 -0
  348. package/dist/renderers/checkbox.js.map +1 -0
  349. package/dist/renderers/core.d.ts +48 -0
  350. package/dist/renderers/core.d.ts.map +1 -0
  351. package/dist/renderers/core.js +143 -0
  352. package/dist/renderers/core.js.map +1 -0
  353. package/dist/renderers/thousand_separator.d.ts +5 -0
  354. package/dist/renderers/thousand_separator.d.ts.map +1 -0
  355. package/dist/renderers/thousand_separator.js +14 -0
  356. package/dist/renderers/thousand_separator.js.map +1 -0
  357. package/dist/store/actions.d.ts +198 -0
  358. package/dist/store/actions.d.ts.map +1 -0
  359. package/dist/store/actions.js +519 -0
  360. package/dist/store/actions.js.map +1 -0
  361. package/dist/store/helpers.d.ts +28 -0
  362. package/dist/store/helpers.d.ts.map +1 -0
  363. package/dist/store/helpers.js +78 -0
  364. package/dist/store/helpers.js.map +1 -0
  365. package/dist/store/index.d.ts +11 -0
  366. package/dist/store/index.d.ts.map +1 -0
  367. package/dist/store/index.js +3 -0
  368. package/dist/store/index.js.map +1 -0
  369. package/dist/styles/embedder.d.ts +2 -0
  370. package/dist/styles/embedder.d.ts.map +1 -0
  371. package/dist/styles/embedder.js +16 -0
  372. package/dist/styles/embedder.js.map +1 -0
  373. package/dist/styles/minified.d.ts +3 -0
  374. package/dist/styles/minified.d.ts.map +1 -0
  375. package/dist/styles/minified.js +4 -0
  376. package/dist/styles/minified.js.map +1 -0
  377. package/dist/types.d.ts +218 -0
  378. package/dist/types.d.ts.map +1 -0
  379. package/dist/types.js +2 -0
  380. package/dist/types.js.map +1 -0
  381. package/dist/utils.d.ts +2 -0
  382. package/dist/utils.d.ts.map +1 -0
  383. package/dist/utils.js +7 -0
  384. package/dist/utils.js.map +1 -0
  385. package/package.json +6 -14
@@ -0,0 +1,102 @@
1
+ import { solveTable } from "../solver";
2
+ import { Table } from "../../lib/table";
3
+ import { FormulaError } from "../evaluator";
4
+ export const ensureNumber = (value, alternative) => {
5
+ if (typeof value === "undefined" && typeof alternative !== "undefined") {
6
+ return alternative;
7
+ }
8
+ if (!value) {
9
+ // falsy is 0
10
+ return 0;
11
+ }
12
+ if (value instanceof Table) {
13
+ const v = stripTable(value, 0, 0);
14
+ return ensureNumber(v, alternative);
15
+ }
16
+ const num = parseFloat(value);
17
+ if (isNaN(num)) {
18
+ throw new FormulaError("#VALUE!", `${value} cannot be converted to a number`);
19
+ }
20
+ return num;
21
+ };
22
+ export const ensureString = (value) => {
23
+ if (!value) {
24
+ return "";
25
+ }
26
+ if (value instanceof Table) {
27
+ const v = stripTable(value, 0, 0);
28
+ return ensureString(v);
29
+ }
30
+ switch (value.constructor.name) {
31
+ case "Date":
32
+ if (value.getHours() + value.getMinutes() + value.getSeconds() === 0) {
33
+ return value.toLocaleDateString();
34
+ }
35
+ return value.toLocaleString();
36
+ default:
37
+ return String(value);
38
+ }
39
+ };
40
+ export const ensureBoolean = (value, alternative) => {
41
+ if (typeof value === "undefined" && typeof alternative !== "undefined") {
42
+ return alternative;
43
+ }
44
+ if (value === null) {
45
+ return false;
46
+ }
47
+ if (value instanceof Table) {
48
+ const v = stripTable(value, 0, 0);
49
+ return ensureBoolean(v, alternative);
50
+ }
51
+ if (typeof value === "string" || value instanceof String) {
52
+ const bool = { true: true, false: false }[value.toLowerCase()];
53
+ if (bool == null) {
54
+ throw new FormulaError("#VALUE!", `text '${value}' cannot be converted to a boolean`);
55
+ }
56
+ return bool;
57
+ }
58
+ return Boolean(value);
59
+ };
60
+ export const stripTable = (value, y = 0, x = 0) => {
61
+ if (value instanceof Table) {
62
+ return solveTable({ table: value })[y][x];
63
+ }
64
+ return value;
65
+ };
66
+ const CONDITION_REGEX = /^(?<expr>|<=|>=|<>|>|<|=)?(?<target>.*)$/;
67
+ export const check = (value, condition) => {
68
+ const m = condition.match(CONDITION_REGEX);
69
+ const { expr = "", target = "" } = m === null || m === void 0 ? void 0 : m.groups;
70
+ const comparison = parseFloat(target);
71
+ if (expr === ">" || expr === "<" || expr === ">=" || expr === "<=") {
72
+ if (isNaN(comparison) === (typeof value === "number")) {
73
+ return false;
74
+ }
75
+ switch (expr) {
76
+ case ">":
77
+ return value > target;
78
+ case ">=":
79
+ return value >= target;
80
+ case "<":
81
+ return value < target;
82
+ case "<=":
83
+ return value <= target;
84
+ }
85
+ }
86
+ const equals = expr === "" || expr === "=";
87
+ if (target === "") {
88
+ return !value === equals;
89
+ }
90
+ if (isNaN(comparison) &&
91
+ (typeof value === "string" || value instanceof String)) {
92
+ const replaced = target
93
+ .replace(/~\*/g, "(\\*)")
94
+ .replace(/~\?/g, "(\\?)")
95
+ .replace(/\*/g, "(.*)")
96
+ .replace(/\?/g, "(.?)");
97
+ const regex = RegExp(`^${replaced}$`, "i");
98
+ return regex.test(value) === equals;
99
+ }
100
+ return (value == comparison) === equals;
101
+ };
102
+ //# sourceMappingURL=__utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__utils.js","sourceRoot":"","sources":["../../../src/formula/functions/__utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAU,EAAE,WAAoB,EAAU,EAAE;IACvE,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;QACtE,OAAO,WAAW,CAAC;KACpB;IACD,IAAI,CAAC,KAAK,EAAE;QACV,aAAa;QACb,OAAO,CAAC,CAAC;KACV;IACD,IAAI,KAAK,YAAY,KAAK,EAAE;QAC1B,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAClC,OAAO,YAAY,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;KACrC;IACD,MAAM,GAAG,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,KAAK,CAAC,GAAG,CAAC,EAAE;QACd,MAAM,IAAI,YAAY,CACpB,SAAS,EACT,GAAG,KAAK,kCA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P,OAAO,KAAK,IAAI,MAAM,CAAC;YACzB,KAAK,GAAG;gBACN,OAAO,KAAK,GAAG,MAAM,CAAC;YACxB,KAAK,IAAI;gBACP,OAAO,KAAK,IAAI,MAAM,CAAC;SAC1B;KACF;IAED,MAAM,MAAM,GAAG,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,GAAG,CAAC;IAC3C,IAAI,MAAM,KAAK,EAAE,EAAE;QACjB,OAAO,CAAC,KAAK,KAAK,MAAM,CAAC;KAC1B;IAED,IACE,KAAK,CAAC,UAAU,CAAC;QACjB,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,CAAC,EACtD;QACA,MAAM,QAAQ,GAAG,MAAM;aACpB,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;aACxB,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;aACxB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;aACtB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAC1B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,QAAQ,GAAG,EAAE,GAAG,CAAC,CAAC;QAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAe,CAAC,KAAK,MAAM,CAAC;KAC/C;IACD,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,MAAM,CAAC;AAC1C,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { BaseFunction } from "./__base";
2
+ export declare class AbsFunction extends BaseFunction {
3
+ example: string;
4
+ helpText: string[];
5
+ helpArgs: {
6
+ name: string;
7
+ description: string;
8
+ }[];
9
+ protected validate(): void;
10
+ protected main(value: number): number;
11
+ }
12
+ //# sourceMappingURL=abs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abs.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/abs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,SAAa;IACpB,QAAQ,WAA8C;IACtD,QAAQ;;;QAAqD;IAE7D,SAAS,CAAC,QAAQ;IAUlB,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM;CAG7B"}
@@ -0,0 +1,21 @@
1
+ import { FormulaError } from "../evaluator";
2
+ import { BaseFunction } from "./__base";
3
+ import { ensureNumber } from "./__utils";
4
+ export class AbsFunction extends BaseFunction {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.example = "ABS(-2)";
8
+ this.helpText = ["Returns the absolute value of a number"];
9
+ this.helpArgs = [{ name: "value", description: "target number" }];
10
+ }
11
+ validate() {
12
+ if (this.bareArgs.length !== 1) {
13
+ throw new FormulaError("#N/A", "Number of arguments for ABS is incorrect.");
14
+ }
15
+ this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));
16
+ }
17
+ main(value) {
18
+ return Math.abs(value);
19
+ }
20
+ }
21
+ //# sourceMappingURL=abs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abs.js","sourceRoot":"","sources":["../../../src/formula/functions/abs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QACE,YAAO,GAAG,SAAS,CAAC;QACpB,aAAQ,GAAG,CAAC,wCAAwC,CAAC,CAAC;QACtD,aAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAC,CAAC;IAe/D,CAAC;IAbW,QAAQ;QAChB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,YAAY,CACpB,MAAM,EACN,2CAA2C,CAC5C,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;IAES,IAAI,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=abs.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abs.spec.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/abs.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { AbsFunction } from "./abs";
2
+ import { Table } from "../../lib/table";
3
+ import { FormulaError, Ref, Value } from "../evaluator";
4
+ describe('abs', () => {
5
+ const table = new Table({
6
+ numRows: 2, numCols: 2, cells: { B2: { value: -222 } }
7
+ });
8
+ describe('normal', () => {
9
+ it('negative to positive', () => {
10
+ const f = new AbsFunction({ table, args: [new Value(-111)] });
11
+ expect(f.call()).toBe(111);
12
+ });
13
+ it('refers to a cell', () => {
14
+ const f = new AbsFunction({ table, args: [new Ref('B2')] });
15
+ expect(f.call()).toBe(222);
16
+ });
17
+ it('positive to positive', () => {
18
+ const f = new AbsFunction({ table, args: [new Value(333)] });
19
+ expect(f.call()).toBe(333);
20
+ });
21
+ });
22
+ describe('validation error', () => {
23
+ it('missing argument', () => {
24
+ const f = new AbsFunction({ table, args: [] });
25
+ expect(f.call.bind(f)).toThrow(FormulaError);
26
+ });
27
+ });
28
+ });
29
+ //# sourceMappingURL=abs.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abs.spec.js","sourceRoot":"","sources":["../../../src/formula/functions/abs.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,OAAO,CAAC;AAClC,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,YAAY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C,kBAAkB,EAAE,GAAG,EAAE;QAChC,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;YAC1B,MAAM,CAAC,GAAG,IAAI,WAAW,CAAC,EAAC,KAAK,EAAE,IAAI,EAAE,EAAE,EAAC,CAAC,CAAC;YAC7C,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { BaseFunction } from "./__base";
2
+ export declare class AcosFunction extends BaseFunction {
3
+ example: string;
4
+ helpText: string[];
5
+ helpArgs: {
6
+ name: string;
7
+ description: string;
8
+ }[];
9
+ protected validate(): void;
10
+ protected main(value: number): number;
11
+ }
12
+ //# sourceMappingURL=acos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acos.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/acos.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,YAAa,SAAQ,YAAY;IAC5C,OAAO,SAAa;IACpB,QAAQ,WAAwD;IAChE,QAAQ;;;QAKN;IAEF,SAAS,CAAC,QAAQ;IAalB,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM;CAG7B"}
@@ -0,0 +1,29 @@
1
+ import { FormulaError } from "../evaluator";
2
+ import { BaseFunction } from "./__base";
3
+ import { ensureNumber } from "./__utils";
4
+ export class AcosFunction extends BaseFunction {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.example = "ACOS(0)";
8
+ this.helpText = ["Returns the inverse cos of the value in radians."];
9
+ this.helpArgs = [
10
+ {
11
+ name: "value",
12
+ description: "A value for the inverse cos between -1 and 1.",
13
+ },
14
+ ];
15
+ }
16
+ validate() {
17
+ if (this.bareArgs.length !== 1) {
18
+ throw new FormulaError("#N/A", "Number of arguments for ACOS is incorrect.");
19
+ }
20
+ this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));
21
+ if (-1 > this.bareArgs[0] || this.bareArgs[0] > 1) {
22
+ throw new FormulaError("#NUM!", "value must be between -1 and 1");
23
+ }
24
+ }
25
+ main(value) {
26
+ return Math.acos(value);
27
+ }
28
+ }
29
+ //# sourceMappingURL=acos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acos.js","sourceRoot":"","sources":["../../../src/formula/functions/acos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,OAAO,YAAa,SAAQ,YAAY;IAA9C;;QACE,YAAO,GAAG,SAAS,CAAC;QACpB,aAAQ,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAChE,aAAQ,GAAG;YACT;gBACE,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,+CAA+C;aAC7D;SACF,CAAC;IAkBJ,CAAC;IAhBW,QAAQ;QAChB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,YAAY,CACpB,MAAM,EACN,4CAA4C,CAC7C,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;YACjD,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAC;SACnE;IACH,CAAC;IAES,IAAI,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import { BaseFunction } from "./__base";
2
+ import { TimeDelta } from "../../lib/time";
3
+ export declare class AddFunction extends BaseFunction {
4
+ example: string;
5
+ helpText: string[];
6
+ helpArgs: {
7
+ name: string;
8
+ description: string;
9
+ }[];
10
+ protected validate(): void;
11
+ protected main(v1: number | Date | TimeDelta, v2: number | Date | TimeDelta): number | Date;
12
+ }
13
+ //# sourceMappingURL=add.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/add.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAGzC,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,SAAe;IACtB,QAAQ,WAGN;IACF,QAAQ;;;QAGN;IAEF,SAAS,CAAC,QAAQ;IAelB,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS;CAqB5E"}
@@ -0,0 +1,50 @@
1
+ import { FormulaError } from "../evaluator";
2
+ import { BaseFunction } from "./__base";
3
+ import { ensureNumber, stripTable } from "./__utils";
4
+ import { Table } from "../../lib/table";
5
+ import { TimeDelta } from "../../lib/time";
6
+ import { addSeconds } from "date-fns";
7
+ export class AddFunction extends BaseFunction {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.example = "ADD(2, 3)";
11
+ this.helpText = [
12
+ "Returns the sum of two numbers.",
13
+ "This is the same as the '+' operator.",
14
+ ];
15
+ this.helpArgs = [
16
+ { name: "value1", description: "First additive." },
17
+ { name: "value2", description: "Second additive." },
18
+ ];
19
+ }
20
+ validate() {
21
+ if (this.bareArgs.length !== 2) {
22
+ throw new FormulaError("#N/A", "Number of arguments for ADD is incorrect.");
23
+ }
24
+ this.bareArgs = this.bareArgs.map((arg) => {
25
+ if (arg instanceof Table) {
26
+ arg = stripTable(arg, 0, 0);
27
+ }
28
+ return typeof arg === "object" ? arg : ensureNumber(arg);
29
+ });
30
+ }
31
+ main(v1, v2) {
32
+ if (typeof v1 === "number" && typeof v2 === "number") {
33
+ return v1 + v2;
34
+ }
35
+ if (v1 instanceof Date && v2 instanceof TimeDelta) {
36
+ return v2.add(v1);
37
+ }
38
+ if (v1 instanceof TimeDelta && v2 instanceof Date) {
39
+ return v1.add(v2);
40
+ }
41
+ if (v1 instanceof Date && typeof v2 === "number") {
42
+ return addSeconds(v1, v2);
43
+ }
44
+ if (typeof v1 === "number" && v2 instanceof Date) {
45
+ return addSeconds(v2, v1);
46
+ }
47
+ throw new FormulaError("#VALUE!", "Mismatched types for augend and addend.");
48
+ }
49
+ }
50
+ //# sourceMappingURL=add.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"add.js","sourceRoot":"","sources":["../../../src/formula/functions/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,WAAW,CAAC;AACnD,OAAO,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AACtC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAEpC,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QACE,YAAO,GAAG,WAAW,CAAC;QACtB,aAAQ,GAAG;YACT,iCAAiC;YACjC,uCAAuC;SACxC,CAAC;QACF,aAAQ,GAAG;YACT,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE;YAClD,EAAE,IAAI,EAAE,QAAQ,E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AS,EACT,yCAAyC,CAC1C,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import { BaseFunction } from "./__base";
2
+ export declare class AndFunction extends BaseFunction {
3
+ example: string;
4
+ helpText: string[];
5
+ helpArgs: ({
6
+ name: string;
7
+ description: string;
8
+ optional?: undefined;
9
+ iterable?: undefined;
10
+ } | {
11
+ name: string;
12
+ description: string;
13
+ optional: boolean;
14
+ iterable: boolean;
15
+ })[];
16
+ protected validate(): void;
17
+ protected main(...values: boolean[]): boolean;
18
+ }
19
+ //# sourceMappingURL=and.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/and.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,SAAqB;IAC5B,QAAQ,WAGN;IACF,QAAQ;;;;;;;;;;SAQN;IAEF,SAAS,CAAC,QAAQ;IAIlB,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,EAAE,OAAO,EAAE;CAGpC"}
@@ -0,0 +1,28 @@
1
+ import { BaseFunction } from "./__base";
2
+ import { ensureBoolean } from "./__utils";
3
+ export class AndFunction extends BaseFunction {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.example = "AND(A1=1, A2=2)";
7
+ this.helpText = [
8
+ "Returns TRUE if all arguments are logically TRUE.",
9
+ "Returns FALSE if any argument is logically FALSE.",
10
+ ];
11
+ this.helpArgs = [
12
+ { name: "expression1", description: "First logical expression." },
13
+ {
14
+ name: "expression2",
15
+ description: "Additional expressions",
16
+ optional: true,
17
+ iterable: true,
18
+ },
19
+ ];
20
+ }
21
+ validate() {
22
+ this.bareArgs = this.bareArgs.map((arg) => ensureBoolean(arg));
23
+ }
24
+ main(...values) {
25
+ return values.reduce((a, b) => a && b);
26
+ }
27
+ }
28
+ //# sourceMappingURL=and.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and.js","sourceRoot":"","sources":["../../../src/formula/functions/and.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QACE,YAAO,GAAG,iBAAiB,CAAC;QAC5B,aAAQ,GAAG;YACT,mDAAmD;YACnD,mDAAmD;SACpD,CAAC;QACF,aAAQ,GAAG;YACT,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,2BAA2B,EAAE;YACjE;gBACE,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,wBAAwB;gBACrC,QAAQ,EAAE,IAAI;gBACd,QAAQ,EAAE,IAAI;aACf;SACF,CAAC;IASJ,CAAC;IAPW,QAAQ;QAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,CAAC;IAES,IAAI,CAAC,GAAG,MAAiB;QACjC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { BaseFunction } from "./__base";
2
+ export declare class AsinFunction extends BaseFunction {
3
+ example: string;
4
+ helpText: string[];
5
+ helpArgs: {
6
+ name: string;
7
+ description: string;
8
+ }[];
9
+ protected validate(): void;
10
+ protected main(value: number): number;
11
+ }
12
+ //# sourceMappingURL=asin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asin.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/asin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,YAAa,SAAQ,YAAY;IAC5C,OAAO,SAAa;IACpB,QAAQ,WAAwD;IAChE,QAAQ;;;QAKN;IAEF,SAAS,CAAC,QAAQ;IAalB,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM;CAG7B"}
@@ -0,0 +1,29 @@
1
+ import { FormulaError } from "../evaluator";
2
+ import { BaseFunction } from "./__base";
3
+ import { ensureNumber } from "./__utils";
4
+ export class AsinFunction extends BaseFunction {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.example = "ASIN(0)";
8
+ this.helpText = ["Returns the inverse sin of the value in radians."];
9
+ this.helpArgs = [
10
+ {
11
+ name: "value",
12
+ description: "A value for the inverse sin between -1 and 1.",
13
+ },
14
+ ];
15
+ }
16
+ validate() {
17
+ if (this.bareArgs.length !== 1) {
18
+ throw new FormulaError("#N/A", "Number of arguments for ASIN is incorrect.");
19
+ }
20
+ this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));
21
+ if (-1 > this.bareArgs[0] || this.bareArgs[0] > 1) {
22
+ throw new FormulaError("#NUM!", "value must be between -1 and 1");
23
+ }
24
+ }
25
+ main(value) {
26
+ return Math.asin(value);
27
+ }
28
+ }
29
+ //# sourceMappingURL=asin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asin.js","sourceRoot":"","sources":["../../../src/formula/functions/asin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,OAAO,YAAa,SAAQ,YAAY;IAA9C;;QACE,YAAO,GAAG,SAAS,CAAC;QACpB,aAAQ,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAChE,aAAQ,GAAG;YACT;gBACE,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,+CAA+C;aAC7D;SACF,CAAC;IAkBJ,CAAC;IAhBW,QAAQ;QAChB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,YAAY,CACpB,MAAM,EACN,4CAA4C,CAC7C,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;QAC9D,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE;YACjD,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE,gCAAgC,CAAC,CAAC;SACnE;IACH,CAAC;IAES,IAAI,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { BaseFunction } from "./__base";
2
+ export declare class AtanFunction extends BaseFunction {
3
+ example: string;
4
+ helpText: string[];
5
+ helpArgs: {
6
+ name: string;
7
+ description: string;
8
+ }[];
9
+ protected validate(): void;
10
+ protected main(value: number): number;
11
+ }
12
+ //# sourceMappingURL=atan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atan.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/atan.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,YAAa,SAAQ,YAAY;IAC5C,OAAO,SAAa;IACpB,QAAQ,WAAwD;IAChE,QAAQ;;;QAKN;IAEF,SAAS,CAAC,QAAQ;IAUlB,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM;CAG7B"}
@@ -0,0 +1,26 @@
1
+ import { FormulaError } from "../evaluator";
2
+ import { BaseFunction } from "./__base";
3
+ import { ensureNumber } from "./__utils";
4
+ export class AtanFunction extends BaseFunction {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.example = "ATAN(1)";
8
+ this.helpText = ["Returns the inverse tan of the value in radians."];
9
+ this.helpArgs = [
10
+ {
11
+ name: "value",
12
+ description: "A value for the inverse tan.",
13
+ },
14
+ ];
15
+ }
16
+ validate() {
17
+ if (this.bareArgs.length !== 1) {
18
+ throw new FormulaError("#N/A", "Number of arguments for ATAN is incorrect.");
19
+ }
20
+ this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));
21
+ }
22
+ main(value) {
23
+ return Math.atan(value);
24
+ }
25
+ }
26
+ //# sourceMappingURL=atan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atan.js","sourceRoot":"","sources":["../../../src/formula/functions/atan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,OAAO,YAAa,SAAQ,YAAY;IAA9C;;QACE,YAAO,GAAG,SAAS,CAAC;QACpB,aAAQ,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAChE,aAAQ,GAAG;YACT;gBACE,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,8BAA8B;aAC5C;SACF,CAAC;IAeJ,CAAC;IAbW,QAAQ;QAChB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,YAAY,CACpB,MAAM,EACN,4CAA4C,CAC7C,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;IAES,IAAI,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { BaseFunction } from "./__base";
2
+ export declare class Atan2Function extends BaseFunction {
3
+ example: string;
4
+ helpText: string[];
5
+ helpArgs: {
6
+ name: string;
7
+ description: string;
8
+ }[];
9
+ protected validate(): void;
10
+ protected main(x: number, y: number): number;
11
+ }
12
+ //# sourceMappingURL=atan2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atan2.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/atan2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,aAAc,SAAQ,YAAY;IAC7C,OAAO,SAAgB;IACvB,QAAQ,WAEN;IACF,QAAQ;;;QASN;IAEF,SAAS,CAAC,QAAQ;IAUlB,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;CAGpC"}
@@ -0,0 +1,32 @@
1
+ import { FormulaError } from "../evaluator";
2
+ import { BaseFunction } from "./__base";
3
+ import { ensureNumber } from "./__utils";
4
+ export class Atan2Function extends BaseFunction {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.example = "ATAN2(4,3)";
8
+ this.helpText = [
9
+ "Returns the angle in radians between the x-axis and a line passing from the origin through a given coordinate point (x, y).",
10
+ ];
11
+ this.helpArgs = [
12
+ {
13
+ name: "x",
14
+ description: "x of the point.",
15
+ },
16
+ {
17
+ name: "y",
18
+ description: "y of the point.",
19
+ },
20
+ ];
21
+ }
22
+ validate() {
23
+ if (this.bareArgs.length !== 2) {
24
+ throw new FormulaError("#N/A", "Number of arguments for ATAN2 is incorrect.");
25
+ }
26
+ this.bareArgs = this.bareArgs.map((arg) => ensureNumber(arg));
27
+ }
28
+ main(x, y) {
29
+ return Math.atan2(x, y);
30
+ }
31
+ }
32
+ //# sourceMappingURL=atan2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"atan2.js","sourceRoot":"","sources":["../../../src/formula/functions/atan2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,OAAO,aAAc,SAAQ,YAAY;IAA/C;;QACE,YAAO,GAAG,YAAY,CAAC;QACvB,aAAQ,GAAG;YACT,6HAA6H;SAC9H,CAAC;QACF,aAAQ,GAAG;YACT;gBACE,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,iBAAiB;aAC/B;YACD;gBACE,IAAI,EAAE,GAAG;gBACT,WAAW,EAAE,iBAAiB;aAC/B;SACF,CAAC;IAeJ,CAAC;IAbW,QAAQ;QAChB,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9B,MAAM,IAAI,YAAY,CACpB,MAAM,EACN,6CAA6C,CAC9C,CAAC;SACH;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC;IAChE,CAAC;IAES,IAAI,CAAC,CAAS,EAAE,CAAS;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import { BaseFunction } from "./__base";
2
+ export declare class AverageFunction extends BaseFunction {
3
+ example: string;
4
+ helpText: string[];
5
+ helpArgs: ({
6
+ name: string;
7
+ description: string;
8
+ optional?: undefined;
9
+ iterable?: undefined;
10
+ } | {
11
+ name: string;
12
+ description: string;
13
+ optional: boolean;
14
+ iterable: boolean;
15
+ })[];
16
+ protected validate(): void;
17
+ protected main(...values: number[]): number;
18
+ }
19
+ //# sourceMappingURL=average.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"average.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/average.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAGxC,qBAAa,eAAgB,SAAQ,YAAY;IAC/C,OAAO,SAA2B;IAClC,QAAQ,WAA4D;IACpE,QAAQ;;;;;;;;;;SAQN;IAEF,SAAS,CAAC,QAAQ;IAsBlB,SAAS,CAAC,IAAI,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE;CAGnC"}
@@ -0,0 +1,41 @@
1
+ import { FormulaError } from "../evaluator";
2
+ import { solveTable } from "../solver";
3
+ import { Table } from "../../lib/table";
4
+ import { BaseFunction } from "./__base";
5
+ import { ensureNumber } from "./__utils";
6
+ export class AverageFunction extends BaseFunction {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.example = "AVERAGE(A2:A100, 101)";
10
+ this.helpText = ["Returns the average of a series of numbers or cells."];
11
+ this.helpArgs = [
12
+ { name: "value1", description: "First number or range." },
13
+ {
14
+ name: "value2",
15
+ description: "Additional numbers or ranges",
16
+ optional: true,
17
+ iterable: true,
18
+ },
19
+ ];
20
+ }
21
+ validate() {
22
+ const spreaded = [];
23
+ this.bareArgs.map((arg) => {
24
+ if (arg instanceof Table) {
25
+ spreaded.push(...solveTable({ table: arg })
26
+ .reduce((a, b) => a.concat(b))
27
+ .filter((v) => typeof v === "number"));
28
+ return;
29
+ }
30
+ spreaded.push(ensureNumber(arg));
31
+ });
32
+ if (spreaded.length === 0) {
33
+ throw new FormulaError("#N/A", "Number of arguments must be greater than 0.");
34
+ }
35
+ this.bareArgs = spreaded;
36
+ }
37
+ main(...values) {
38
+ return values.reduce((a, b) => a + b) / values.length;
39
+ }
40
+ }
41
+ //# sourceMappingURL=average.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"average.js","sourceRoot":"","sources":["../../../src/formula/functions/average.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,E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QAChC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxD,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import { Table } from "../../lib/table";
2
+ import { BaseFunction } from "./__base";
3
+ export declare class ColFunction extends BaseFunction {
4
+ example: string;
5
+ helpText: string[];
6
+ helpArgs: {
7
+ name: string;
8
+ description: string;
9
+ option: boolean;
10
+ }[];
11
+ protected validate(): void;
12
+ protected main(trimmed: Table): number;
13
+ }
14
+ //# sourceMappingURL=col.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"col.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/col.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,SAAa;IACpB,QAAQ,WAAmD;IAC3D,QAAQ;;;;QAMN;IAEF,SAAS,CAAC,QAAQ;IAYlB,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK;CAG9B"}