mathjs 9.3.2 → 9.4.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 (410) hide show
  1. package/HISTORY.md +22 -0
  2. package/README.md +1 -0
  3. package/bin/cli.js +11 -11
  4. package/docs/expressions/parsing.md +21 -4
  5. package/docs/reference/functions/complex.md +5 -49
  6. package/docs/reference/functions/eigs.md +12 -12
  7. package/docs/reference/functions/flatten.md +1 -0
  8. package/docs/reference/functions/matrixFromColumns.md +1 -1
  9. package/docs/reference/functions/matrixFromFunction.md +12 -0
  10. package/docs/reference/functions/matrixFromRows.md +1 -1
  11. package/docs/reference/functions.md +4 -1
  12. package/examples/advanced/custom_scope_objects.js +115 -0
  13. package/lib/browser/math.js +10 -10
  14. package/lib/browser/math.js.map +1 -1
  15. package/lib/cjs/core/create.js +8 -7
  16. package/lib/cjs/core/function/import.js +9 -7
  17. package/lib/cjs/core/function/typed.js +6 -1
  18. package/lib/cjs/defaultInstance.js +3 -3
  19. package/lib/cjs/entry/allFactoriesAny.js +3 -3
  20. package/lib/cjs/entry/allFactoriesNumber.js +3 -3
  21. package/lib/cjs/entry/configReadonly.js +5 -4
  22. package/lib/cjs/entry/dependenciesAny/dependenciesEigs.generated.js +51 -0
  23. package/lib/cjs/entry/dependenciesAny/dependenciesMatrixFromColumns.generated.js +29 -0
  24. package/lib/cjs/entry/dependenciesAny/dependenciesMatrixFromFunction.generated.js +26 -0
  25. package/lib/cjs/entry/dependenciesAny/dependenciesMatrixFromRows.generated.js +29 -0
  26. package/lib/cjs/entry/dependenciesAny.generated.js +24 -0
  27. package/lib/cjs/entry/impureFunctionsAny.generated.js +22 -17
  28. package/lib/cjs/entry/impureFunctionsNumber.generated.js +11 -9
  29. package/lib/cjs/entry/pureFunctionsAny.generated.js +78 -41
  30. package/lib/cjs/expression/Parser.js +22 -15
  31. package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +9 -0
  32. package/lib/cjs/expression/embeddedDocs/function/matrix/column.js +1 -1
  33. package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromColumns.js +15 -0
  34. package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromFunction.js +15 -0
  35. package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromRows.js +15 -0
  36. package/lib/cjs/expression/embeddedDocs/function/matrix/row.js +1 -1
  37. package/lib/cjs/expression/function/evaluate.js +6 -4
  38. package/lib/cjs/expression/keywords.js +1 -3
  39. package/lib/cjs/expression/node/AccessorNode.js +1 -0
  40. package/lib/cjs/expression/node/AssignmentNode.js +6 -3
  41. package/lib/cjs/expression/node/FunctionAssignmentNode.js +2 -4
  42. package/lib/cjs/expression/node/FunctionNode.js +76 -46
  43. package/lib/cjs/expression/node/IndexNode.js +5 -13
  44. package/lib/cjs/expression/node/Node.js +15 -9
  45. package/lib/cjs/expression/node/ObjectNode.js +5 -3
  46. package/lib/cjs/expression/node/SymbolNode.js +2 -2
  47. package/lib/cjs/expression/node/utils/access.js +5 -3
  48. package/lib/cjs/expression/node/utils/assign.js +5 -3
  49. package/lib/cjs/expression/parse.js +10 -14
  50. package/lib/cjs/expression/transform/utils/compileInlineExpression.js +5 -3
  51. package/lib/cjs/factoriesAny.js +24 -0
  52. package/lib/cjs/function/algebra/decomposition/qr.js +5 -3
  53. package/lib/cjs/function/algebra/simplify/resolve.js +7 -1
  54. package/lib/cjs/function/algebra/simplify.js +20 -14
  55. package/lib/cjs/function/algebra/solver/lsolveAll.js +6 -16
  56. package/lib/cjs/function/algebra/solver/usolveAll.js +6 -16
  57. package/lib/cjs/function/arithmetic/ceil.js +6 -16
  58. package/lib/cjs/function/arithmetic/floor.js +6 -16
  59. package/lib/cjs/function/arithmetic/norm.js +2 -2
  60. package/lib/cjs/function/arithmetic/pow.js +9 -7
  61. package/lib/cjs/function/arithmetic/round.js +7 -5
  62. package/lib/cjs/function/complex/im.js +3 -0
  63. package/lib/cjs/function/complex/re.js +3 -0
  64. package/lib/cjs/function/matrix/eigs/complexEigs.js +631 -0
  65. package/lib/cjs/function/matrix/eigs/realSymetric.js +341 -0
  66. package/lib/cjs/function/matrix/eigs.js +188 -334
  67. package/lib/cjs/function/matrix/flatten.js +1 -0
  68. package/lib/cjs/function/matrix/matrixFromColumns.js +118 -0
  69. package/lib/cjs/function/matrix/matrixFromFunction.js +85 -0
  70. package/lib/cjs/function/matrix/matrixFromRows.js +108 -0
  71. package/lib/cjs/function/probability/pickRandom.js +1 -1
  72. package/lib/cjs/function/probability/util/seededRNG.js +2 -2
  73. package/lib/cjs/function/relational/compareNatural.js +2 -2
  74. package/lib/cjs/header.js +2 -2
  75. package/lib/cjs/plain/bignumber/index.js +2 -2
  76. package/lib/cjs/type/bignumber/BigNumber.js +2 -2
  77. package/lib/cjs/type/complex/Complex.js +5 -5
  78. package/lib/cjs/type/fraction/Fraction.js +2 -2
  79. package/lib/cjs/type/matrix/DenseMatrix.js +138 -0
  80. package/lib/cjs/type/matrix/Matrix.js +10 -0
  81. package/lib/cjs/type/matrix/SparseMatrix.js +77 -3
  82. package/lib/cjs/type/matrix/function/matrix.js +2 -1
  83. package/lib/cjs/type/unit/Unit.js +15 -13
  84. package/lib/cjs/utils/array.js +1 -1
  85. package/lib/cjs/utils/customs.js +18 -4
  86. package/lib/cjs/utils/emitter.js +2 -2
  87. package/lib/cjs/utils/function.js +6 -2
  88. package/lib/cjs/utils/is.js +7 -5
  89. package/lib/cjs/utils/latex.js +2 -2
  90. package/lib/cjs/utils/map.js +197 -0
  91. package/lib/cjs/utils/object.js +6 -5
  92. package/lib/cjs/utils/scope.js +33 -0
  93. package/lib/cjs/utils/snapshot.js +17 -16
  94. package/lib/cjs/utils/string.js +6 -4
  95. package/lib/cjs/version.js +1 -1
  96. package/lib/esm/constants.js +15 -15
  97. package/lib/esm/core/create.js +1 -2
  98. package/lib/esm/core/function/typed.js +5 -1
  99. package/lib/esm/entry/configReadonly.js +1 -2
  100. package/lib/esm/entry/dependenciesAny/dependenciesEigs.generated.js +34 -0
  101. package/lib/esm/entry/dependenciesAny/dependenciesMatrixFromColumns.generated.js +16 -0
  102. package/lib/esm/entry/dependenciesAny/dependenciesMatrixFromFunction.generated.js +14 -0
  103. package/lib/esm/entry/dependenciesAny/dependenciesMatrixFromRows.generated.js +16 -0
  104. package/lib/esm/entry/dependenciesAny.generated.js +3 -0
  105. package/lib/esm/entry/impureFunctionsAny.generated.js +13 -10
  106. package/lib/esm/entry/impureFunctionsNumber.generated.js +1 -1
  107. package/lib/esm/entry/pureFunctionsAny.generated.js +66 -32
  108. package/lib/esm/expression/Help.js +1 -1
  109. package/lib/esm/expression/Parser.js +23 -15
  110. package/lib/esm/expression/embeddedDocs/embeddedDocs.js +6 -0
  111. package/lib/esm/expression/embeddedDocs/function/matrix/column.js +1 -1
  112. package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromColumns.js +8 -0
  113. package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromFunction.js +8 -0
  114. package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromRows.js +8 -0
  115. package/lib/esm/expression/embeddedDocs/function/matrix/row.js +1 -1
  116. package/lib/esm/expression/function/compile.js +1 -1
  117. package/lib/esm/expression/function/evaluate.js +6 -5
  118. package/lib/esm/expression/function/help.js +1 -1
  119. package/lib/esm/expression/function/parser.js +1 -1
  120. package/lib/esm/expression/keywords.js +1 -3
  121. package/lib/esm/expression/node/AccessorNode.js +2 -1
  122. package/lib/esm/expression/node/ArrayNode.js +1 -1
  123. package/lib/esm/expression/node/AssignmentNode.js +7 -4
  124. package/lib/esm/expression/node/BlockNode.js +1 -1
  125. package/lib/esm/expression/node/ConditionalNode.js +1 -1
  126. package/lib/esm/expression/node/ConstantNode.js +1 -1
  127. package/lib/esm/expression/node/FunctionAssignmentNode.js +3 -4
  128. package/lib/esm/expression/node/FunctionNode.js +57 -39
  129. package/lib/esm/expression/node/IndexNode.js +1 -1
  130. package/lib/esm/expression/node/Node.js +7 -8
  131. package/lib/esm/expression/node/ObjectNode.js +1 -1
  132. package/lib/esm/expression/node/OperatorNode.js +1 -1
  133. package/lib/esm/expression/node/ParenthesisNode.js +1 -1
  134. package/lib/esm/expression/node/RangeNode.js +1 -1
  135. package/lib/esm/expression/node/RelationalNode.js +1 -1
  136. package/lib/esm/expression/node/SymbolNode.js +3 -3
  137. package/lib/esm/expression/parse.js +2 -3
  138. package/lib/esm/expression/transform/apply.transform.js +1 -1
  139. package/lib/esm/expression/transform/column.transform.js +1 -1
  140. package/lib/esm/expression/transform/concat.transform.js +1 -1
  141. package/lib/esm/expression/transform/diff.transform.js +1 -1
  142. package/lib/esm/expression/transform/filter.transform.js +1 -1
  143. package/lib/esm/expression/transform/forEach.transform.js +1 -1
  144. package/lib/esm/expression/transform/index.transform.js +1 -1
  145. package/lib/esm/expression/transform/map.transform.js +1 -1
  146. package/lib/esm/expression/transform/max.transform.js +1 -1
  147. package/lib/esm/expression/transform/mean.transform.js +1 -1
  148. package/lib/esm/expression/transform/min.transform.js +1 -1
  149. package/lib/esm/expression/transform/range.transform.js +1 -1
  150. package/lib/esm/expression/transform/row.transform.js +1 -1
  151. package/lib/esm/expression/transform/std.transform.js +1 -1
  152. package/lib/esm/expression/transform/subset.transform.js +1 -1
  153. package/lib/esm/expression/transform/sum.transform.js +1 -1
  154. package/lib/esm/expression/transform/utils/compileInlineExpression.js +4 -3
  155. package/lib/esm/expression/transform/variance.transform.js +1 -1
  156. package/lib/esm/factoriesAny.js +3 -0
  157. package/lib/esm/factoriesNumber.js +1 -1
  158. package/lib/esm/function/algebra/decomposition/lup.js +1 -1
  159. package/lib/esm/function/algebra/decomposition/qr.js +2 -3
  160. package/lib/esm/function/algebra/decomposition/slu.js +1 -1
  161. package/lib/esm/function/algebra/derivative.js +1 -1
  162. package/lib/esm/function/algebra/rationalize.js +1 -1
  163. package/lib/esm/function/algebra/simplify/resolve.js +7 -2
  164. package/lib/esm/function/algebra/simplify/simplifyConstant.js +1 -1
  165. package/lib/esm/function/algebra/simplify/simplifyCore.js +1 -1
  166. package/lib/esm/function/algebra/simplify/util.js +1 -1
  167. package/lib/esm/function/algebra/simplify.js +16 -12
  168. package/lib/esm/function/algebra/solver/lsolve.js +1 -1
  169. package/lib/esm/function/algebra/solver/lsolveAll.js +1 -1
  170. package/lib/esm/function/algebra/solver/lusolve.js +1 -1
  171. package/lib/esm/function/algebra/solver/usolve.js +1 -1
  172. package/lib/esm/function/algebra/solver/usolveAll.js +1 -1
  173. package/lib/esm/function/algebra/sparse/csAmd.js +1 -1
  174. package/lib/esm/function/algebra/sparse/csChol.js +1 -1
  175. package/lib/esm/function/algebra/sparse/csCounts.js +1 -1
  176. package/lib/esm/function/algebra/sparse/csLu.js +1 -1
  177. package/lib/esm/function/algebra/sparse/csSpsolve.js +1 -1
  178. package/lib/esm/function/algebra/sparse/csSqr.js +1 -1
  179. package/lib/esm/function/algebra/sparse/csSymperm.js +1 -1
  180. package/lib/esm/function/arithmetic/abs.js +1 -1
  181. package/lib/esm/function/arithmetic/add.js +1 -1
  182. package/lib/esm/function/arithmetic/addScalar.js +1 -1
  183. package/lib/esm/function/arithmetic/cbrt.js +1 -1
  184. package/lib/esm/function/arithmetic/ceil.js +1 -1
  185. package/lib/esm/function/arithmetic/cube.js +1 -1
  186. package/lib/esm/function/arithmetic/divide.js +1 -1
  187. package/lib/esm/function/arithmetic/divideScalar.js +1 -1
  188. package/lib/esm/function/arithmetic/dotDivide.js +1 -1
  189. package/lib/esm/function/arithmetic/dotMultiply.js +1 -1
  190. package/lib/esm/function/arithmetic/dotPow.js +1 -1
  191. package/lib/esm/function/arithmetic/exp.js +1 -1
  192. package/lib/esm/function/arithmetic/expm1.js +1 -1
  193. package/lib/esm/function/arithmetic/fix.js +1 -1
  194. package/lib/esm/function/arithmetic/floor.js +1 -1
  195. package/lib/esm/function/arithmetic/gcd.js +1 -1
  196. package/lib/esm/function/arithmetic/hypot.js +1 -1
  197. package/lib/esm/function/arithmetic/lcm.js +1 -1
  198. package/lib/esm/function/arithmetic/log.js +1 -1
  199. package/lib/esm/function/arithmetic/log10.js +1 -1
  200. package/lib/esm/function/arithmetic/log1p.js +1 -1
  201. package/lib/esm/function/arithmetic/log2.js +1 -1
  202. package/lib/esm/function/arithmetic/mod.js +1 -1
  203. package/lib/esm/function/arithmetic/multiply.js +1 -1
  204. package/lib/esm/function/arithmetic/multiplyScalar.js +1 -1
  205. package/lib/esm/function/arithmetic/norm.js +3 -3
  206. package/lib/esm/function/arithmetic/nthRoot.js +2 -2
  207. package/lib/esm/function/arithmetic/nthRoots.js +1 -1
  208. package/lib/esm/function/arithmetic/pow.js +10 -8
  209. package/lib/esm/function/arithmetic/round.js +6 -6
  210. package/lib/esm/function/arithmetic/sign.js +1 -1
  211. package/lib/esm/function/arithmetic/sqrt.js +1 -1
  212. package/lib/esm/function/arithmetic/square.js +1 -1
  213. package/lib/esm/function/arithmetic/subtract.js +1 -1
  214. package/lib/esm/function/arithmetic/unaryMinus.js +1 -1
  215. package/lib/esm/function/arithmetic/unaryPlus.js +1 -1
  216. package/lib/esm/function/arithmetic/xgcd.js +1 -1
  217. package/lib/esm/function/bitwise/bitAnd.js +1 -1
  218. package/lib/esm/function/bitwise/bitNot.js +1 -1
  219. package/lib/esm/function/bitwise/bitOr.js +1 -1
  220. package/lib/esm/function/bitwise/bitXor.js +1 -1
  221. package/lib/esm/function/bitwise/leftShift.js +1 -1
  222. package/lib/esm/function/bitwise/rightArithShift.js +1 -1
  223. package/lib/esm/function/bitwise/rightLogShift.js +1 -1
  224. package/lib/esm/function/combinatorics/bellNumbers.js +1 -1
  225. package/lib/esm/function/combinatorics/catalan.js +1 -1
  226. package/lib/esm/function/combinatorics/composition.js +1 -1
  227. package/lib/esm/function/combinatorics/stirlingS2.js +1 -1
  228. package/lib/esm/function/complex/arg.js +1 -1
  229. package/lib/esm/function/complex/conj.js +1 -1
  230. package/lib/esm/function/complex/im.js +4 -1
  231. package/lib/esm/function/complex/re.js +4 -1
  232. package/lib/esm/function/geometry/distance.js +1 -1
  233. package/lib/esm/function/geometry/intersect.js +1 -1
  234. package/lib/esm/function/logical/and.js +1 -1
  235. package/lib/esm/function/logical/not.js +1 -1
  236. package/lib/esm/function/logical/or.js +1 -1
  237. package/lib/esm/function/logical/xor.js +1 -1
  238. package/lib/esm/function/matrix/apply.js +1 -1
  239. package/lib/esm/function/matrix/column.js +1 -1
  240. package/lib/esm/function/matrix/concat.js +1 -1
  241. package/lib/esm/function/matrix/count.js +1 -1
  242. package/lib/esm/function/matrix/cross.js +1 -1
  243. package/lib/esm/function/matrix/ctranspose.js +1 -1
  244. package/lib/esm/function/matrix/det.js +1 -1
  245. package/lib/esm/function/matrix/diag.js +1 -1
  246. package/lib/esm/function/matrix/diff.js +1 -1
  247. package/lib/esm/function/matrix/dot.js +1 -1
  248. package/lib/esm/function/matrix/eigs/complexEigs.js +586 -0
  249. package/lib/esm/function/matrix/eigs/realSymetric.js +335 -0
  250. package/lib/esm/function/matrix/eigs.js +187 -335
  251. package/lib/esm/function/matrix/expm.js +1 -1
  252. package/lib/esm/function/matrix/filter.js +1 -1
  253. package/lib/esm/function/matrix/flatten.js +2 -1
  254. package/lib/esm/function/matrix/forEach.js +1 -1
  255. package/lib/esm/function/matrix/getMatrixDataType.js +1 -1
  256. package/lib/esm/function/matrix/identity.js +1 -1
  257. package/lib/esm/function/matrix/inv.js +1 -1
  258. package/lib/esm/function/matrix/kron.js +1 -1
  259. package/lib/esm/function/matrix/map.js +1 -1
  260. package/lib/esm/function/matrix/matrixFromColumns.js +93 -0
  261. package/lib/esm/function/matrix/matrixFromFunction.js +78 -0
  262. package/lib/esm/function/matrix/matrixFromRows.js +83 -0
  263. package/lib/esm/function/matrix/ones.js +1 -1
  264. package/lib/esm/function/matrix/partitionSelect.js +1 -1
  265. package/lib/esm/function/matrix/range.js +1 -1
  266. package/lib/esm/function/matrix/reshape.js +1 -1
  267. package/lib/esm/function/matrix/resize.js +1 -1
  268. package/lib/esm/function/matrix/rotate.js +1 -1
  269. package/lib/esm/function/matrix/rotationMatrix.js +1 -1
  270. package/lib/esm/function/matrix/row.js +1 -1
  271. package/lib/esm/function/matrix/size.js +1 -1
  272. package/lib/esm/function/matrix/sort.js +1 -1
  273. package/lib/esm/function/matrix/sqrtm.js +1 -1
  274. package/lib/esm/function/matrix/squeeze.js +1 -1
  275. package/lib/esm/function/matrix/subset.js +1 -1
  276. package/lib/esm/function/matrix/trace.js +1 -1
  277. package/lib/esm/function/matrix/transpose.js +1 -1
  278. package/lib/esm/function/matrix/zeros.js +1 -1
  279. package/lib/esm/function/probability/combinations.js +1 -1
  280. package/lib/esm/function/probability/combinationsWithRep.js +1 -1
  281. package/lib/esm/function/probability/factorial.js +1 -1
  282. package/lib/esm/function/probability/gamma.js +1 -1
  283. package/lib/esm/function/probability/kldivergence.js +1 -1
  284. package/lib/esm/function/probability/multinomial.js +1 -1
  285. package/lib/esm/function/probability/permutations.js +1 -1
  286. package/lib/esm/function/probability/pickRandom.js +2 -2
  287. package/lib/esm/function/probability/random.js +2 -2
  288. package/lib/esm/function/probability/randomInt.js +1 -1
  289. package/lib/esm/function/relational/compare.js +2 -2
  290. package/lib/esm/function/relational/compareNatural.js +1 -1
  291. package/lib/esm/function/relational/compareText.js +2 -2
  292. package/lib/esm/function/relational/deepEqual.js +1 -1
  293. package/lib/esm/function/relational/equal.js +2 -2
  294. package/lib/esm/function/relational/equalScalar.js +2 -2
  295. package/lib/esm/function/relational/equalText.js +1 -1
  296. package/lib/esm/function/relational/larger.js +2 -2
  297. package/lib/esm/function/relational/largerEq.js +2 -2
  298. package/lib/esm/function/relational/smaller.js +2 -2
  299. package/lib/esm/function/relational/smallerEq.js +2 -2
  300. package/lib/esm/function/relational/unequal.js +2 -2
  301. package/lib/esm/function/set/setCartesian.js +1 -1
  302. package/lib/esm/function/set/setDifference.js +1 -1
  303. package/lib/esm/function/set/setDistinct.js +1 -1
  304. package/lib/esm/function/set/setIntersect.js +1 -1
  305. package/lib/esm/function/set/setIsSubset.js +1 -1
  306. package/lib/esm/function/set/setMultiplicity.js +1 -1
  307. package/lib/esm/function/set/setPowerset.js +1 -1
  308. package/lib/esm/function/set/setSize.js +1 -1
  309. package/lib/esm/function/set/setSymDifference.js +1 -1
  310. package/lib/esm/function/set/setUnion.js +1 -1
  311. package/lib/esm/function/special/erf.js +1 -1
  312. package/lib/esm/function/statistics/mad.js +1 -1
  313. package/lib/esm/function/statistics/max.js +1 -1
  314. package/lib/esm/function/statistics/mean.js +1 -1
  315. package/lib/esm/function/statistics/median.js +1 -1
  316. package/lib/esm/function/statistics/min.js +1 -1
  317. package/lib/esm/function/statistics/mode.js +1 -1
  318. package/lib/esm/function/statistics/prod.js +1 -1
  319. package/lib/esm/function/statistics/quantileSeq.js +1 -1
  320. package/lib/esm/function/statistics/std.js +1 -1
  321. package/lib/esm/function/statistics/sum.js +1 -1
  322. package/lib/esm/function/statistics/variance.js +1 -1
  323. package/lib/esm/function/string/bin.js +1 -1
  324. package/lib/esm/function/string/format.js +1 -1
  325. package/lib/esm/function/string/hex.js +1 -1
  326. package/lib/esm/function/string/oct.js +1 -1
  327. package/lib/esm/function/string/print.js +1 -1
  328. package/lib/esm/function/trigonometry/acos.js +1 -1
  329. package/lib/esm/function/trigonometry/acosh.js +1 -1
  330. package/lib/esm/function/trigonometry/acot.js +1 -1
  331. package/lib/esm/function/trigonometry/acoth.js +1 -1
  332. package/lib/esm/function/trigonometry/acsc.js +1 -1
  333. package/lib/esm/function/trigonometry/acsch.js +1 -1
  334. package/lib/esm/function/trigonometry/asec.js +1 -1
  335. package/lib/esm/function/trigonometry/asech.js +1 -1
  336. package/lib/esm/function/trigonometry/asin.js +1 -1
  337. package/lib/esm/function/trigonometry/asinh.js +1 -1
  338. package/lib/esm/function/trigonometry/atan.js +1 -1
  339. package/lib/esm/function/trigonometry/atan2.js +1 -1
  340. package/lib/esm/function/trigonometry/atanh.js +1 -1
  341. package/lib/esm/function/trigonometry/cos.js +1 -1
  342. package/lib/esm/function/trigonometry/cosh.js +1 -1
  343. package/lib/esm/function/trigonometry/cot.js +1 -1
  344. package/lib/esm/function/trigonometry/coth.js +1 -1
  345. package/lib/esm/function/trigonometry/csc.js +1 -1
  346. package/lib/esm/function/trigonometry/csch.js +1 -1
  347. package/lib/esm/function/trigonometry/sec.js +1 -1
  348. package/lib/esm/function/trigonometry/sech.js +1 -1
  349. package/lib/esm/function/trigonometry/sin.js +1 -1
  350. package/lib/esm/function/trigonometry/sinh.js +1 -1
  351. package/lib/esm/function/trigonometry/tan.js +1 -1
  352. package/lib/esm/function/trigonometry/tanh.js +1 -1
  353. package/lib/esm/function/unit/to.js +1 -1
  354. package/lib/esm/function/utils/clone.js +1 -1
  355. package/lib/esm/function/utils/hasNumericValue.js +1 -1
  356. package/lib/esm/function/utils/isInteger.js +1 -1
  357. package/lib/esm/function/utils/isNaN.js +1 -1
  358. package/lib/esm/function/utils/isNegative.js +1 -1
  359. package/lib/esm/function/utils/isNumeric.js +1 -1
  360. package/lib/esm/function/utils/isPositive.js +1 -1
  361. package/lib/esm/function/utils/isPrime.js +1 -1
  362. package/lib/esm/function/utils/isZero.js +1 -1
  363. package/lib/esm/function/utils/numeric.js +1 -1
  364. package/lib/esm/function/utils/typeOf.js +1 -1
  365. package/lib/esm/json/reviver.js +1 -1
  366. package/lib/esm/type/bignumber/BigNumber.js +1 -1
  367. package/lib/esm/type/bignumber/function/bignumber.js +1 -1
  368. package/lib/esm/type/boolean.js +1 -1
  369. package/lib/esm/type/chain/Chain.js +1 -1
  370. package/lib/esm/type/chain/function/chain.js +1 -1
  371. package/lib/esm/type/complex/function/complex.js +1 -1
  372. package/lib/esm/type/fraction/function/fraction.js +1 -1
  373. package/lib/esm/type/matrix/DenseMatrix.js +75 -1
  374. package/lib/esm/type/matrix/FibonacciHeap.js +1 -1
  375. package/lib/esm/type/matrix/ImmutableDenseMatrix.js +1 -1
  376. package/lib/esm/type/matrix/Matrix.js +10 -0
  377. package/lib/esm/type/matrix/MatrixIndex.js +1 -1
  378. package/lib/esm/type/matrix/Spa.js +1 -1
  379. package/lib/esm/type/matrix/SparseMatrix.js +37 -3
  380. package/lib/esm/type/matrix/function/index.js +1 -1
  381. package/lib/esm/type/matrix/function/matrix.js +3 -2
  382. package/lib/esm/type/matrix/function/sparse.js +1 -1
  383. package/lib/esm/type/matrix/utils/algorithm01.js +1 -1
  384. package/lib/esm/type/matrix/utils/algorithm02.js +1 -1
  385. package/lib/esm/type/matrix/utils/algorithm03.js +1 -1
  386. package/lib/esm/type/matrix/utils/algorithm04.js +1 -1
  387. package/lib/esm/type/matrix/utils/algorithm05.js +1 -1
  388. package/lib/esm/type/matrix/utils/algorithm06.js +1 -1
  389. package/lib/esm/type/matrix/utils/algorithm07.js +1 -1
  390. package/lib/esm/type/matrix/utils/algorithm08.js +1 -1
  391. package/lib/esm/type/matrix/utils/algorithm09.js +1 -1
  392. package/lib/esm/type/matrix/utils/algorithm10.js +1 -1
  393. package/lib/esm/type/matrix/utils/algorithm11.js +1 -1
  394. package/lib/esm/type/matrix/utils/algorithm12.js +1 -1
  395. package/lib/esm/type/matrix/utils/algorithm13.js +1 -1
  396. package/lib/esm/type/matrix/utils/algorithm14.js +1 -1
  397. package/lib/esm/type/number.js +1 -1
  398. package/lib/esm/type/string.js +1 -1
  399. package/lib/esm/type/unit/Unit.js +4 -5
  400. package/lib/esm/type/unit/function/createUnit.js +1 -1
  401. package/lib/esm/type/unit/function/splitUnit.js +1 -1
  402. package/lib/esm/type/unit/function/unit.js +1 -1
  403. package/lib/esm/type/unit/physicalConstants.js +2 -2
  404. package/lib/esm/utils/array.js +1 -1
  405. package/lib/esm/utils/customs.js +10 -0
  406. package/lib/esm/utils/map.js +135 -0
  407. package/lib/esm/utils/scope.js +26 -0
  408. package/lib/esm/utils/snapshot.js +3 -4
  409. package/lib/esm/version.js +1 -1
  410. package/package.json +18 -9
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.createSparseMatrixClass = void 0;
7
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
8
12
  var _is = require("../../utils/is.js");
9
13
 
10
14
  var _number = require("../../utils/number.js");
@@ -27,8 +31,9 @@ var createSparseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, depende
27
31
  Matrix = _ref.Matrix;
28
32
 
29
33
  /**
30
- * Sparse Matrix implementation. This type implements a Compressed Column Storage format
31
- * for sparse matrices.
34
+ * Sparse Matrix implementation. This type implements
35
+ * a [Compressed Column Storage](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_(CSC_or_CCS))
36
+ * format for two-dimensional sparse matrices.
32
37
  * @class SparseMatrix
33
38
  */
34
39
  function SparseMatrix(data, datatype) {
@@ -610,6 +615,8 @@ var createSparseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, depende
610
615
  *
611
616
  * @memberof SparseMatrix
612
617
  * @param {number[] | Matrix} size The new size the matrix should have.
618
+ * Since sparse matrices are always two-dimensional,
619
+ * size must be two numbers in either an array or a matrix
613
620
  * @param {*} [defaultValue=0] Default value, filled in on new entries.
614
621
  * If not provided, the matrix elements will
615
622
  * be filled with zeros.
@@ -780,6 +787,8 @@ var createSparseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, depende
780
787
  *
781
788
  * @memberof SparseMatrix
782
789
  * @param {number[]} sizes The new size the matrix should have.
790
+ * Since sparse matrices are always two-dimensional,
791
+ * size must be two numbers in either an array or a matrix
783
792
  * @param {boolean} [copy] Return a reshaped copy of the matrix
784
793
  *
785
794
  * @return {Matrix} The reshaped matrix
@@ -1020,6 +1029,8 @@ var createSparseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, depende
1020
1029
  * parameters: the value of the element, the index
1021
1030
  * of the element, and the Matrix being traversed.
1022
1031
  * @param {boolean} [skipZeros] Invoke callback function for non-zero values only.
1032
+ * If false, the indices are guaranteed to be in order,
1033
+ * if true, the indices can be unordered.
1023
1034
  */
1024
1035
 
1025
1036
 
@@ -1066,13 +1077,76 @@ var createSparseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, depende
1066
1077
  }
1067
1078
  }
1068
1079
  };
1080
+ /**
1081
+ * Iterate over the matrix elements, skipping zeros
1082
+ * @return {Iterable<{ value, index: number[] }>}
1083
+ */
1084
+
1085
+
1086
+ SparseMatrix.prototype[Symbol.iterator] = /*#__PURE__*/_regenerator["default"].mark(function _callee() {
1087
+ var columns, j, k0, k1, k, i;
1088
+ return _regenerator["default"].wrap(function _callee$(_context) {
1089
+ while (1) {
1090
+ switch (_context.prev = _context.next) {
1091
+ case 0:
1092
+ if (this._values) {
1093
+ _context.next = 2;
1094
+ break;
1095
+ }
1096
+
1097
+ throw new Error('Cannot iterate a Pattern only matrix');
1098
+
1099
+ case 2:
1100
+ columns = this._size[1];
1101
+ j = 0;
1102
+
1103
+ case 4:
1104
+ if (!(j < columns)) {
1105
+ _context.next = 18;
1106
+ break;
1107
+ }
1108
+
1109
+ k0 = this._ptr[j];
1110
+ k1 = this._ptr[j + 1];
1111
+ k = k0;
1112
+
1113
+ case 8:
1114
+ if (!(k < k1)) {
1115
+ _context.next = 15;
1116
+ break;
1117
+ }
1118
+
1119
+ // row index
1120
+ i = this._index[k];
1121
+ _context.next = 12;
1122
+ return {
1123
+ value: this._values[k],
1124
+ index: [i, j]
1125
+ };
1126
+
1127
+ case 12:
1128
+ k++;
1129
+ _context.next = 8;
1130
+ break;
1131
+
1132
+ case 15:
1133
+ j++;
1134
+ _context.next = 4;
1135
+ break;
1136
+
1137
+ case 18:
1138
+ case "end":
1139
+ return _context.stop();
1140
+ }
1141
+ }
1142
+ }, _callee, this);
1143
+ });
1069
1144
  /**
1070
1145
  * Create an Array with a copy of the data of the SparseMatrix
1071
1146
  * @memberof SparseMatrix
1072
1147
  * @returns {Array} array
1073
1148
  */
1074
1149
 
1075
-
1076
1150
  SparseMatrix.prototype.toArray = function () {
1077
1151
  return _toArray(this._values, this._index, this._ptr, this._size, true);
1078
1152
  };
@@ -43,7 +43,8 @@ var createMatrix = /* #__PURE__ */(0, _factory.factory)(name, dependencies, func
43
43
  * bignumber, boolean, complex, index, number, string, unit, sparse
44
44
  *
45
45
  * @param {Array | Matrix} [data] A multi dimensional array
46
- * @param {string} [format] The Matrix storage format
46
+ * @param {string} [format] The Matrix storage format, either `'dense'` or `'sparse'`
47
+ * @param {string} [datatype] Type of the values
47
48
  *
48
49
  * @return {Matrix} The created matrix
49
50
  */
@@ -1,10 +1,18 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.createUnitClass = void 0;
7
9
 
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
8
16
  var _is = require("../../utils/is.js");
9
17
 
10
18
  var _factory = require("../../utils/factory.js");
@@ -17,15 +25,9 @@ var _object = require("../../utils/object.js");
17
25
 
18
26
  var _constants = require("../../utils/bignumber/constants.js");
19
27
 
20
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
21
-
22
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
28
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
27
29
 
28
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
29
31
 
30
32
  var name = 'Unit';
31
33
  var dependencies = ['?on', 'config', 'addScalar', 'subtract', 'multiplyScalar', 'divideScalar', 'pow', 'abs', 'fix', 'round', 'equal', 'isNumeric', 'format', 'number', 'Complex', 'BigNumber', 'Fraction'];
@@ -1949,9 +1951,9 @@ var createUnitClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
1949
1951
  }
1950
1952
  }
1951
1953
  };
1952
- PREFIXES.SHORTLONG = _extends({}, PREFIXES.SHORT, PREFIXES.LONG);
1953
- PREFIXES.BINARY_SHORT = _extends({}, PREFIXES.BINARY_SHORT_SI, PREFIXES.BINARY_SHORT_IEC);
1954
- PREFIXES.BINARY_LONG = _extends({}, PREFIXES.BINARY_LONG_SI, PREFIXES.BINARY_LONG_IEC);
1954
+ PREFIXES.SHORTLONG = (0, _extends2["default"])({}, PREFIXES.SHORT, PREFIXES.LONG);
1955
+ PREFIXES.BINARY_SHORT = (0, _extends2["default"])({}, PREFIXES.BINARY_SHORT_SI, PREFIXES.BINARY_SHORT_IEC);
1956
+ PREFIXES.BINARY_LONG = (0, _extends2["default"])({}, PREFIXES.BINARY_LONG_SI, PREFIXES.BINARY_LONG_IEC);
1955
1957
  /* Internally, each unit is represented by a value and a dimension array. The elements of the dimensions array have the following meaning:
1956
1958
  * Index Dimension
1957
1959
  * ----- ---------
@@ -3743,7 +3745,7 @@ var createUnitClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
3743
3745
 
3744
3746
 
3745
3747
  Unit.createUnit = function (obj, options) {
3746
- if (_typeof(obj) !== 'object') {
3748
+ if ((0, _typeof2["default"])(obj) !== 'object') {
3747
3749
  throw new TypeError("createUnit expects first parameter to be of type 'Object'");
3748
3750
  } // Remove all units and aliases we are overriding
3749
3751
 
@@ -3833,7 +3835,7 @@ var createUnitClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
3833
3835
  if (obj !== '') {
3834
3836
  definition = obj;
3835
3837
  }
3836
- } else if (_typeof(obj) === 'object') {
3838
+ } else if ((0, _typeof2["default"])(obj) === 'object') {
3837
3839
  definition = obj.definition;
3838
3840
  prefixes = obj.prefixes;
3839
3841
  offset = obj.offset;
@@ -616,7 +616,7 @@ function generalize(a) {
616
616
  * This method does not validate Array Matrix shape
617
617
  * @param {Array} array
618
618
  * @param {function} typeOf Callback function to use to determine the type of a value
619
- * @return string
619
+ * @return {string}
620
620
  */
621
621
 
622
622
 
@@ -1,18 +1,22 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.getSafeProperty = getSafeProperty;
7
9
  exports.setSafeProperty = setSafeProperty;
8
10
  exports.isSafeProperty = isSafeProperty;
11
+ exports.hasSafeProperty = hasSafeProperty;
12
+ exports.getSafeProperties = getSafeProperties;
9
13
  exports.validateSafeMethod = validateSafeMethod;
10
14
  exports.isSafeMethod = isSafeMethod;
11
15
  exports.isPlainObject = isPlainObject;
12
16
 
13
- var _object = require("./object.js");
17
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
14
18
 
15
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
19
+ var _object = require("./object.js");
16
20
 
17
21
  /**
18
22
  * Get a property of a plain object
@@ -55,6 +59,16 @@ function setSafeProperty(object, prop, value) {
55
59
 
56
60
  throw new Error('No access to property "' + prop + '"');
57
61
  }
62
+
63
+ function getSafeProperties(object) {
64
+ return Object.keys(object).filter(function (prop) {
65
+ return (0, _object.hasOwnProperty)(object, prop);
66
+ });
67
+ }
68
+
69
+ function hasSafeProperty(object, prop) {
70
+ return prop in object;
71
+ }
58
72
  /**
59
73
  * Test whether a property is safe to use for an object.
60
74
  * For example .toString and .constructor are not safe
@@ -64,7 +78,7 @@ function setSafeProperty(object, prop, value) {
64
78
 
65
79
 
66
80
  function isSafeProperty(object, prop) {
67
- if (!object || _typeof(object) !== 'object') {
81
+ if (!object || (0, _typeof2["default"])(object) !== 'object') {
68
82
  return false;
69
83
  } // SAFE: whitelisted
70
84
  // e.g length
@@ -157,7 +171,7 @@ function isSafeMethod(object, method) {
157
171
  }
158
172
 
159
173
  function isPlainObject(object) {
160
- return _typeof(object) === 'object' && object && object.constructor === Object;
174
+ return (0, _typeof2["default"])(object) === 'object' && object && object.constructor === Object;
161
175
  }
162
176
 
163
177
  var safeNativeProperties = {
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -7,8 +9,6 @@ exports.mixin = mixin;
7
9
 
8
10
  var _tinyEmitter = _interopRequireDefault(require("tiny-emitter"));
9
11
 
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
-
12
12
  /**
13
13
  * Extend given object with emitter functions `on`, `off`, `once`, `emit`
14
14
  * @param {Object} obj
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -7,9 +9,11 @@ exports.memoize = memoize;
7
9
  exports.memoizeCompare = memoizeCompare;
8
10
  exports.maxArgumentCount = maxArgumentCount;
9
11
 
12
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
13
+
10
14
  var _lruQueue = require("./lruQueue.js");
11
15
 
12
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
16
+ // function utils
13
17
 
14
18
  /**
15
19
  * Memoize a given function by caching the computed result.
@@ -34,7 +38,7 @@ function memoize(fn) {
34
38
  limit = limit == null ? Number.POSITIVE_INFINITY : limit;
35
39
  hasher = hasher == null ? JSON.stringify : hasher;
36
40
  return function memoize() {
37
- if (_typeof(memoize.cache) !== 'object') {
41
+ if ((0, _typeof2["default"])(memoize.cache) !== 'object') {
38
42
  memoize.cache = {
39
43
  values: new Map(),
40
44
  lru: (0, _lruQueue.lruQueue)(limit || Number.POSITIVE_INFINITY)
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -43,7 +45,7 @@ exports.isChain = isChain;
43
45
  exports.typeOf = typeOf;
44
46
  exports.isArray = void 0;
45
47
 
46
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
48
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
47
49
 
48
50
  // type checks for all known types
49
51
  //
@@ -67,11 +69,11 @@ function isBigNumber(x) {
67
69
  }
68
70
 
69
71
  function isComplex(x) {
70
- return x && _typeof(x) === 'object' && Object.getPrototypeOf(x).isComplex === true || false;
72
+ return x && (0, _typeof2["default"])(x) === 'object' && Object.getPrototypeOf(x).isComplex === true || false;
71
73
  }
72
74
 
73
75
  function isFraction(x) {
74
- return x && _typeof(x) === 'object' && Object.getPrototypeOf(x).isFraction === true || false;
76
+ return x && (0, _typeof2["default"])(x) === 'object' && Object.getPrototypeOf(x).isFraction === true || false;
75
77
  }
76
78
 
77
79
  function isUnit(x) {
@@ -140,7 +142,7 @@ function isRegExp(x) {
140
142
  }
141
143
 
142
144
  function isObject(x) {
143
- return !!(x && _typeof(x) === 'object' && x.constructor === Object && !isComplex(x) && !isFraction(x));
145
+ return !!(x && (0, _typeof2["default"])(x) === 'object' && x.constructor === Object && !isComplex(x) && !isFraction(x));
144
146
  }
145
147
 
146
148
  function isNull(x) {
@@ -216,7 +218,7 @@ function isChain(x) {
216
218
  }
217
219
 
218
220
  function typeOf(x) {
219
- var t = _typeof(x);
221
+ var t = (0, _typeof2["default"])(x);
220
222
 
221
223
  if (t === 'object') {
222
224
  // JavaScript types
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -11,8 +13,6 @@ var _escapeLatex = _interopRequireDefault(require("escape-latex"));
11
13
 
12
14
  var _object = require("./object.js");
13
15
 
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
-
16
16
  /* eslint no-template-curly-in-string: "off" */
17
17
  var latexSymbols = {
18
18
  // GREEK LETTERS
@@ -0,0 +1,197 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createEmptyMap = createEmptyMap;
9
+ exports.createMap = createMap;
10
+ exports.toObject = toObject;
11
+ exports.isMap = isMap;
12
+ exports.assign = assign;
13
+ exports.ObjectWrappingMap = void 0;
14
+
15
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
16
+
17
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
18
+
19
+ var _customs = require("./customs.js");
20
+
21
+ var _is = require("./is.js");
22
+
23
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
24
+
25
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
26
+
27
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
28
+
29
+ /**
30
+ * A map facade on a bare object.
31
+ *
32
+ * The small number of methods needed to implement a scope,
33
+ * forwarding on to the SafeProperty functions. Over time, the codebase
34
+ * will stop using this method, as all objects will be Maps, rather than
35
+ * more security prone objects.
36
+ */
37
+ var ObjectWrappingMap = /*#__PURE__*/function () {
38
+ function ObjectWrappingMap(object) {
39
+ (0, _classCallCheck2["default"])(this, ObjectWrappingMap);
40
+ this.wrappedObject = object;
41
+ }
42
+
43
+ (0, _createClass2["default"])(ObjectWrappingMap, [{
44
+ key: "keys",
45
+ value: function keys() {
46
+ return Object.keys(this.wrappedObject);
47
+ }
48
+ }, {
49
+ key: "get",
50
+ value: function get(key) {
51
+ return (0, _customs.getSafeProperty)(this.wrappedObject, key);
52
+ }
53
+ }, {
54
+ key: "set",
55
+ value: function set(key, value) {
56
+ (0, _customs.setSafeProperty)(this.wrappedObject, key, value);
57
+ return this;
58
+ }
59
+ }, {
60
+ key: "has",
61
+ value: function has(key) {
62
+ return (0, _customs.hasSafeProperty)(this.wrappedObject, key);
63
+ }
64
+ }]);
65
+ return ObjectWrappingMap;
66
+ }();
67
+ /**
68
+ * Creates an empty map, or whatever your platform's polyfill is.
69
+ *
70
+ * @returns an empty Map or Map like object.
71
+ */
72
+
73
+
74
+ exports.ObjectWrappingMap = ObjectWrappingMap;
75
+
76
+ function createEmptyMap() {
77
+ return new Map();
78
+ }
79
+ /**
80
+ * Creates a Map from the given object.
81
+ *
82
+ * @param { Map | { [key: string]: unknown } | undefined } mapOrObject
83
+ * @returns
84
+ */
85
+
86
+
87
+ function createMap(mapOrObject) {
88
+ if (!mapOrObject) {
89
+ return createEmptyMap();
90
+ }
91
+
92
+ if (isMap(mapOrObject)) {
93
+ return mapOrObject;
94
+ }
95
+
96
+ if ((0, _is.isObject)(mapOrObject)) {
97
+ return new ObjectWrappingMap(mapOrObject);
98
+ }
99
+
100
+ throw new Error('createMap can create maps from objects or Maps');
101
+ }
102
+ /**
103
+ * Unwraps a map into an object.
104
+ *
105
+ * @param {Map} map
106
+ * @returns { [key: string]: unknown }
107
+ */
108
+
109
+
110
+ function toObject(map) {
111
+ if (map instanceof ObjectWrappingMap) {
112
+ return map.wrappedObject;
113
+ }
114
+
115
+ var object = {};
116
+
117
+ var _iterator = _createForOfIteratorHelper(map.keys()),
118
+ _step;
119
+
120
+ try {
121
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
122
+ var key = _step.value;
123
+ var value = map.get(key);
124
+ (0, _customs.setSafeProperty)(object, key, value);
125
+ }
126
+ } catch (err) {
127
+ _iterator.e(err);
128
+ } finally {
129
+ _iterator.f();
130
+ }
131
+
132
+ return object;
133
+ }
134
+ /**
135
+ * Returns `true` if the passed object appears to be a Map (i.e. duck typing).
136
+ *
137
+ * Methods looked for are `get`, `set`, `keys` and `has`.
138
+ *
139
+ * @param {Map | object} object
140
+ * @returns
141
+ */
142
+
143
+
144
+ function isMap(object) {
145
+ // We can use the fast instanceof, or a slower duck typing check.
146
+ // The duck typing method needs to cover enough methods to not be confused with DenseMatrix.
147
+ if (!object) {
148
+ return false;
149
+ }
150
+
151
+ return object instanceof Map || object instanceof ObjectWrappingMap || typeof object.set === 'function' && typeof object.get === 'function' && typeof object.keys === 'function' && typeof object.has === 'function';
152
+ }
153
+ /**
154
+ * Copies the contents of key-value pairs from each `objects` in to `map`.
155
+ *
156
+ * Object is `objects` can be a `Map` or object.
157
+ *
158
+ * This is the `Map` analog to `Object.assign`.
159
+ */
160
+
161
+
162
+ function assign(map) {
163
+ for (var _len = arguments.length, objects = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
164
+ objects[_key - 1] = arguments[_key];
165
+ }
166
+
167
+ for (var _i = 0, _objects = objects; _i < _objects.length; _i++) {
168
+ var args = _objects[_i];
169
+
170
+ if (!args) {
171
+ continue;
172
+ }
173
+
174
+ if (isMap(args)) {
175
+ var _iterator2 = _createForOfIteratorHelper(args.keys()),
176
+ _step2;
177
+
178
+ try {
179
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
180
+ var key = _step2.value;
181
+ map.set(key, args.get(key));
182
+ }
183
+ } catch (err) {
184
+ _iterator2.e(err);
185
+ } finally {
186
+ _iterator2.f();
187
+ }
188
+ } else if ((0, _is.isObject)(args)) {
189
+ for (var _i2 = 0, _Object$keys = Object.keys(args); _i2 < _Object$keys.length; _i2++) {
190
+ var _key2 = _Object$keys[_i2];
191
+ map.set(_key2, args[_key2]);
192
+ }
193
+ }
194
+ }
195
+
196
+ return map;
197
+ }
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
@@ -20,9 +22,9 @@ exports.pick = pick;
20
22
  exports.pickShallow = pickShallow;
21
23
  exports.values = values;
22
24
 
23
- var _is = require("./is.js");
25
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
24
26
 
25
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
27
+ var _is = require("./is.js");
26
28
 
27
29
  /**
28
30
  * Clone an object
@@ -36,8 +38,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
36
38
  * @return {*} clone
37
39
  */
38
40
  function clone(x) {
39
- var type = _typeof(x); // immutable primitive types
40
-
41
+ var type = (0, _typeof2["default"])(x); // immutable primitive types
41
42
 
42
43
  if (type === 'number' || type === 'string' || type === 'boolean' || x === null || x === undefined) {
43
44
  return x;
@@ -212,7 +213,7 @@ function _deepFlatten(nestedObject, flattenedObject) {
212
213
  if (hasOwnProperty(nestedObject, prop)) {
213
214
  var value = nestedObject[prop];
214
215
 
215
- if (_typeof(value) === 'object' && value !== null) {
216
+ if ((0, _typeof2["default"])(value) === 'object' && value !== null) {
216
217
  _deepFlatten(value, flattenedObject);
217
218
  } else {
218
219
  flattenedObject[prop] = value;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createSubScope = createSubScope;
7
+
8
+ var _map = require("./map.js");
9
+
10
+ /**
11
+ * Create a new scope which can access the parent scope,
12
+ * but does not affect it when written. This is suitable for variable definitions
13
+ * within a block node, or function definition.
14
+ *
15
+ * If parent scope has a createSubScope method, it delegates to that. Otherwise,
16
+ * creates an empty map, and copies the parent scope to it, adding in
17
+ * the remaining `args`.
18
+ *
19
+ * @param {Map} parentScope
20
+ * @param {...any} args
21
+ * @returns {Map}
22
+ */
23
+ function createSubScope(parentScope) {
24
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
25
+ args[_key - 1] = arguments[_key];
26
+ }
27
+
28
+ if (typeof parentScope.createSubScope === 'function') {
29
+ return _map.assign.apply(void 0, [parentScope.createSubScope()].concat(args));
30
+ }
31
+
32
+ return _map.assign.apply(void 0, [(0, _map.createEmptyMap)(), parentScope].concat(args));
33
+ }