math-exercises 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/exercise.d.ts +1 -1
- package/lib/exercises/exercise.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineExpressionReading.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/affineExpressionReading.js +1 -0
- package/lib/exercises/math/functions/affines/interceptReading.d.ts.map +1 -1
- package/lib/exercises/math/functions/affines/interceptReading.js +1 -0
- package/lib/exercises/math/percent/findProportion.d.ts +8 -0
- package/lib/exercises/math/percent/findProportion.d.ts.map +1 -0
- package/lib/exercises/math/percent/findProportion.js +48 -0
- package/lib/exercises/math/percent/index.d.ts +1 -0
- package/lib/exercises/math/percent/index.d.ts.map +1 -1
- package/lib/exercises/math/percent/index.js +1 -0
- package/lib/exercises/math/powers/decimalToScientific.js +4 -4
- package/lib/exercises/math/sequences/arithmetic/recognizeArithmeticFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/recognizeArithmeticFromGraph.js +4 -1
- package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromGraph.js +4 -1
- package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.d.ts +8 -0
- package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/atomicStructureOfNucleus.js +58 -0
- package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.d.ts +8 -0
- package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/calculateProtonsNumberFromMass.js +63 -0
- package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.d.ts +5 -0
- package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/calculateVolumetricMass.js +76 -0
- package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.d.ts +10 -0
- package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/findAtomicStructureElement.js +68 -0
- package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.d.ts +8 -0
- package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromElectronicConfiguration.js +58 -0
- package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.d.ts +8 -0
- package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/findValenceElectronsNumberFromTable.js +59 -0
- package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.d.ts +8 -0
- package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/identifyRightElectronicConfiguration.js +101 -0
- package/lib/exercises/pc/chemicalElements/index.d.ts +9 -0
- package/lib/exercises/pc/chemicalElements/index.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/index.js +24 -0
- package/lib/exercises/pc/chemicalElements/weightPercent.d.ts +10 -0
- package/lib/exercises/pc/chemicalElements/weightPercent.d.ts.map +1 -0
- package/lib/exercises/pc/chemicalElements/weightPercent.js +107 -0
- package/lib/exercises/pc/chemicalEquations.js +1 -1
- package/lib/exercises/pc/forces/gravitationalAttractionValue.d.ts +7 -0
- package/lib/exercises/pc/forces/gravitationalAttractionValue.d.ts.map +1 -0
- package/lib/exercises/pc/forces/gravitationalAttractionValue.js +71 -0
- package/lib/exercises/pc/forces/index.d.ts +2 -0
- package/lib/exercises/pc/forces/index.d.ts.map +1 -0
- package/lib/exercises/pc/forces/index.js +17 -0
- package/lib/exercises/pc/index.d.ts +12 -0
- package/lib/exercises/pc/index.d.ts.map +1 -1
- package/lib/exercises/pc/index.js +14 -0
- package/lib/exercises/pc/math/index.d.ts +2 -0
- package/lib/exercises/pc/math/index.d.ts.map +1 -0
- package/lib/exercises/pc/math/index.js +18 -0
- package/lib/exercises/pc/math/isolateVariables.d.ts +8 -0
- package/lib/exercises/pc/math/isolateVariables.d.ts.map +1 -0
- package/lib/exercises/pc/math/isolateVariables.js +304 -0
- package/lib/exercises/pc/math/proportionnalityCoeffFromLine.d.ts +10 -0
- package/lib/exercises/pc/math/proportionnalityCoeffFromLine.d.ts.map +1 -0
- package/lib/exercises/pc/math/proportionnalityCoeffFromLine.js +81 -0
- package/lib/exercises/pc/motion/recognizeFreeFall.d.ts +1 -0
- package/lib/exercises/pc/motion/recognizeFreeFall.d.ts.map +1 -0
- package/lib/exercises/pc/motion/recognizeFreeFall.js +53 -0
- package/lib/exercises/pc/sound/findPeriodFromGraph.d.ts +8 -0
- package/lib/exercises/pc/sound/findPeriodFromGraph.d.ts.map +1 -0
- package/lib/exercises/pc/sound/findPeriodFromGraph.js +80 -0
- package/lib/exercises/pc/sound/findSoundFrequencyFromPeriod.d.ts +7 -0
- package/lib/exercises/pc/sound/findSoundFrequencyFromPeriod.d.ts.map +1 -0
- package/lib/exercises/pc/sound/findSoundFrequencyFromPeriod.js +51 -0
- package/lib/exercises/pc/sound/findSoundPeriodFromFrequency.d.ts +7 -0
- package/lib/exercises/pc/sound/findSoundPeriodFromFrequency.d.ts.map +1 -0
- package/lib/exercises/pc/sound/findSoundPeriodFromFrequency.js +58 -0
- package/lib/exercises/pc/sound/frequencyComparison.d.ts +9 -0
- package/lib/exercises/pc/sound/frequencyComparison.d.ts.map +1 -0
- package/lib/exercises/pc/sound/frequencyComparison.js +51 -0
- package/lib/exercises/pc/sound/index.d.ts +5 -0
- package/lib/exercises/pc/sound/index.d.ts.map +1 -0
- package/lib/exercises/pc/sound/index.js +20 -0
- package/lib/exercises/pc/waves/findDistanceFromEarth.d.ts +7 -0
- package/lib/exercises/pc/waves/findDistanceFromEarth.d.ts.map +1 -0
- package/lib/exercises/pc/waves/findDistanceFromEarth.js +66 -0
- package/lib/exercises/pc/waves/index.d.ts +2 -0
- package/lib/exercises/pc/waves/index.d.ts.map +1 -0
- package/lib/exercises/pc/waves/index.js +17 -0
- package/lib/exercises/pc/weight/index.d.ts +2 -0
- package/lib/exercises/pc/weight/index.d.ts.map +1 -0
- package/lib/exercises/pc/weight/index.js +17 -0
- package/lib/exercises/pc/weight/weightOnTheMoon.d.ts +8 -0
- package/lib/exercises/pc/weight/weightOnTheMoon.d.ts.map +1 -0
- package/lib/exercises/pc/weight/weightOnTheMoon.js +64 -0
- package/lib/exercises/utils/getAtoms.d.ts +2 -0
- package/lib/exercises/utils/getAtoms.d.ts.map +1 -0
- package/lib/exercises/utils/getAtoms.js +11 -0
- package/lib/exercises/utils/getElectronicConfigurationFromShells.d.ts +2 -0
- package/lib/exercises/utils/getElectronicConfigurationFromShells.d.ts.map +1 -0
- package/lib/exercises/utils/getElectronicConfigurationFromShells.js +19 -0
- package/lib/geogebra/geogebraConstructor.d.ts +2 -0
- package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
- package/lib/geogebra/geogebraConstructor.js +2 -0
- package/lib/index.d.ts +126 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -0
- package/lib/math/numbers/decimals/decimal.d.ts +3 -3
- package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
- package/lib/math/numbers/decimals/decimal.js +39 -19
- package/lib/math/utils/random/randfloat.d.ts +1 -1
- package/lib/math/utils/random/randfloat.d.ts.map +1 -1
- package/lib/math/utils/random/randfloat.js +4 -7
- package/lib/math/utils/round.d.ts +2 -1
- package/lib/math/utils/round.d.ts.map +1 -1
- package/lib/math/utils/round.js +10 -3
- package/lib/pc/constants/atoms.d.ts +8 -0
- package/lib/pc/constants/atoms.d.ts.map +1 -0
- package/lib/pc/constants/atoms.js +9 -0
- package/lib/pc/constants/earth.d.ts +9 -0
- package/lib/pc/constants/earth.d.ts.map +1 -0
- package/lib/pc/constants/earth.js +12 -0
- package/lib/pc/constants/gravity.d.ts +10 -0
- package/lib/pc/constants/gravity.d.ts.map +1 -0
- package/lib/pc/constants/gravity.js +16 -0
- package/lib/pc/measure/measure.d.ts +15 -0
- package/lib/pc/measure/measure.d.ts.map +1 -0
- package/lib/pc/measure/measure.js +97 -0
- package/lib/pc/molecularChemistry/atome.d.ts +3 -2
- package/lib/pc/molecularChemistry/atome.d.ts.map +1 -1
- package/lib/pc/molecularChemistry/atome.js +156 -120
- package/lib/pc/molecularChemistry/molecule.d.ts +3 -2
- package/lib/pc/molecularChemistry/molecule.d.ts.map +1 -1
- package/lib/pc/molecularChemistry/molecule.js +11 -0
- package/lib/pc/molecularChemistry/reaction.d.ts +2 -1
- package/lib/pc/molecularChemistry/reaction.d.ts.map +1 -1
- package/lib/pc/molecularChemistry/reaction.js +9 -0
- package/lib/server.d.ts +1 -0
- package/lib/server.d.ts.map +1 -1
- package/lib/server.js +5 -0
- package/lib/tree/nodes/algebraicNode.d.ts +1 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/complex/complexNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.js +0 -1
- package/lib/tree/nodes/functions/cosNode.d.ts.map +1 -1
- package/lib/tree/nodes/node.d.ts +1 -0
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +1 -1
- package/lib/tree/nodes/numbers/piNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts +2 -2
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +6 -5
- package/lib/types/keyIds.d.ts +4 -2
- package/lib/types/keyIds.d.ts.map +1 -1
- package/lib/utils/numberPrototype/toScientific.d.ts +3 -0
- package/lib/utils/numberPrototype/toScientific.d.ts.map +1 -0
- package/lib/utils/numberPrototype/toScientific.js +110 -0
- package/lib/utils/requiresApostropheBefore.d.ts +2 -0
- package/lib/utils/requiresApostropheBefore.d.ts.map +1 -0
- package/lib/utils/requiresApostropheBefore.js +7 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"multiplyNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/operators/multiplyNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EACL,uBAAuB,EACvB,WAAW,EAEZ,MAAM,gBAAgB,CAAC;AAYxB,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAOlE,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,YAAY,CAEzD;AAED,eAAO,MAAM,iBAAiB,QAAS,aAAa,EAAE,SAWrD,CAAC;AACF,qBAAa,YAAa,YAAW,uBAAuB;IAC1D,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,EAAE,EAAE,WAAW,CAAC;IAChB,SAAS,EAAE,aAAa,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBAEjB,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,aAAa,EACzB,IAAI,CAAC,EAAE,WAAW;IAUpB,OAAO,aAGL;IAEF,YAAY,IAAI,MAAM;IAItB,KAAK,CAAC,IAAI,CAAC,EAAE,YAAY,GAAG,MAAM;IAoDlC,SAAS;IAkDT,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,YAAY,EAAE;IAwFrD,cAAc,CAAC,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE;IAQ5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIrC,IAAI;IAGJ,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,aAAa;IAgH/C,MAAM,CAAC,IAAI,EAAE,aAAa;CAU3B"}
|
|
@@ -17,6 +17,7 @@ const oppositeNode_1 = require("../functions/oppositeNode");
|
|
|
17
17
|
const fractionNode_1 = require("./fractionNode");
|
|
18
18
|
const functionNode_1 = require("../functions/functionNode");
|
|
19
19
|
const addNode_1 = require("./addNode");
|
|
20
|
+
const round_1 = require("../../../math/utils/round");
|
|
20
21
|
function isMultiplyNode(a) {
|
|
21
22
|
return (0, operatorNode_1.isOperatorNode)(a) && a.id === operatorNode_1.OperatorIds.multiply;
|
|
22
23
|
}
|
|
@@ -48,13 +49,13 @@ class MultiplyNode {
|
|
|
48
49
|
toMathString() {
|
|
49
50
|
return `(${this.leftChild.toMathString()})*(${this.rightChild.toMathString()})`;
|
|
50
51
|
}
|
|
51
|
-
toTex() {
|
|
52
|
+
toTex(opts) {
|
|
52
53
|
let leftTex = this.leftChild.toTex();
|
|
53
54
|
let rightTex = this.rightChild.toTex();
|
|
54
|
-
if (
|
|
55
|
-
|
|
55
|
+
if ((0, numberNode_1.isNumberNode)(this.leftChild) &&
|
|
56
|
+
this.leftChild.value === 1 &&
|
|
57
|
+
opts?.scientific === undefined) {
|
|
56
58
|
return rightTex;
|
|
57
|
-
// }
|
|
58
59
|
}
|
|
59
60
|
if ((0, operatorNode_1.isOperatorNode)(this.leftChild)) {
|
|
60
61
|
if ([operatorNode_1.OperatorIds.add, operatorNode_1.OperatorIds.substract, operatorNode_1.OperatorIds.divide].includes(this.leftChild.id))
|
|
@@ -265,7 +266,7 @@ class MultiplyNode {
|
|
|
265
266
|
(0, exports.sortMultiplyNodes)(externals);
|
|
266
267
|
const simplifyExternalNodes = (a, b) => {
|
|
267
268
|
if ((0, numberNode_1.isNumberNode)(a) && (0, numberNode_1.isNumberNode)(b)) {
|
|
268
|
-
return new numberNode_1.NumberNode(a.value * b.value);
|
|
269
|
+
return new numberNode_1.NumberNode((0, round_1.round)(a.value * b.value, 12));
|
|
269
270
|
}
|
|
270
271
|
if ((0, sqrtNode_1.isSqrtNode)(a) && (0, sqrtNode_1.isSqrtNode)(b)) {
|
|
271
272
|
return new sqrtNode_1.SqrtNode(new MultiplyNode(a.child, b.child)).simplify(opts);
|
package/lib/types/keyIds.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type KeyId =
|
|
2
|
+
/**quantities */
|
|
3
|
+
"volumeMere" | "volumeFille" | "concentrationMere" | "concentrationFille"
|
|
2
4
|
/**units */
|
|
3
|
-
"cm" | "cm2" | "celsius" | "Hz" | "mol" | "kJ" | "mL" | "minutes" | "hours"
|
|
5
|
+
| "cm" | "cm2" | "celsius" | "Hz" | "mol" | "kJ" | "mL" | "minutes" | "hours" | "timesTenPower"
|
|
4
6
|
/**utility */
|
|
5
7
|
| "custom" | "right" | "left" | "rightarrow" | "del" | "close" | "switch" | "maj"
|
|
6
8
|
/**words */
|
|
@@ -28,5 +30,5 @@ export type KeyId =
|
|
|
28
30
|
/**atoms */
|
|
29
31
|
| "Hydrogène" | "Hélium" | "Lithium" | "Béryllium" | "Bore" | "Carbone" | "Azote" | "Oxygène" | "Fluor" | "Néon" | "Sodium" | "Magnésium" | "Aluminium" | "Silicium" | "Phosphore" | "Soufre" | "Chlore" | "Argon" | "Potassium" | "Calcium" | "Scandium" | "Titane" | "Vanadium" | "Chrome" | "Manganèse" | "Fer" | "Cobalt" | "Nickel" | "Cuivre" | "Zinc" | "Gallium" | "Germanium" | "Arsenic" | "Sélénium" | "Brome" | "Krypton" | "Rubidium" | "Strontium" | "Yttrium" | "Zirconium" | "Niobium" | "Molybdène" | "Technétium" | "Ruthénium" | "Rhodium" | "Palladium" | "Argent" | "Cadmium" | "Indium" | "Étain" | "Antimoine" | "Tellure" | "Iode" | "Xénon" | "Césium" | "Baryum" | "Lanthane" | "Cérium" | "Praséodyme" | "Néodyme" | "Prométhium" | "Samarium" | "Europium" | "Gadolinium" | "Térbium" | "Dysprosium" | "Holmium" | "Erbium" | "Thulium" | "Ytterbium" | "Lutétium" | "Hafnium" | "Tantale" | "Tungstène" | "Rhénium" | "Osmium" | "Iridium" | "Platine" | "Or" | "Mercure" | "Thallium" | "Plomb" | "Bismuth" | "Polonium" | "Astate" | "Radon" | "Francium" | "Radium" | "Actinium" | "Thorium" | "Protactinium" | "Uranium" | "Neptunium" | "Plutonium" | "Américium" | "Curium" | "Berkélium" | "Californium" | "Einsteinium" | "Fermium" | "Mendélévium" | "Nobelium" | "Lawrencium" | "Rutherfordium" | "Dubnium" | "Seaborgium" | "Bohrium" | "Hassium" | "Meitnérium" | "Darmstadtium" | "Roentgenium" | "Copernicium" | "Nihonium" | "Flerovium" | "Moscovium" | "Livermorium" | "Tennessine" | "Oganesson"
|
|
30
32
|
/**Molecules */
|
|
31
|
-
| "
|
|
33
|
+
| "Mol-H2" | "Mol-O2" | "Mol-H2O" | "Mol-CH4" | "Mol-CO2" | "Mol-NH3" | "Mol-SO2" | "Mol-C2H5OH" | "Mol-C6H12O6" | "Mol-CH3OH" | "Mol-C3H8" | "Mol-C4H10" | "Mol-H2SO4" | "Mol-C3H6" | "Mol-C6H6" | "Mol-CH3CN" | "Mol-CH2O" | "Mol-HCOONa" | "Mol-CaCO3" | "Mol-NH42SO4" | "Mol-NH4NO3" | "Mol-Na2CO3" | "Mol-C6H8O6" | "Mol-C9H8O4" | "Mol-C8H10N4O2" | "Mol-C8H9NO2" | "Mol-NaCl" | "Mol-CH3COOH" | "Mol-Mg" | "Mol-MgO" | "Mol-Fe" | "Mol-Fe2O3" | "Mol-C2H6" | "Mol-C2H4" | "Mol-C3H6O" | "Mol-C7H8" | "Mol-C2H6O2" | "Mol-C4H8" | "Mol-C5H10" | "Mol-C6H12" | "Mol-C4H8O2" | "Mol-C3H6O2" | "Mol-C6H12O2" | "Mol-C6H6O" | "Mol-C2H4O" | "Mol-C4H8O" | "Mol-C5H4O2" | "Mol-CH2O2" | "Mol-C12H22O11" | "Mol-HCl" | "Mol-NaOH" | "Mol-AgNO3" | "Mol-AgCl" | "Mol-NaNO3" | "Mol-CaOH2" | "Mol-CaSO4" | "Mol-CuSO4" | "Mol-CuOH2" | "Mol-Na2SO4" | "Mol-Zn" | "Mol-ZnCl2" | "Mol-KOH" | "Mol-K2SO4" | "Mol-H2O2" | "Mol-PbCl2" | "Mol-KI" | "Mol-PbI2" | "Mol-KCl" | "Mol-CH3COONa" | "Mol-S" | "Mol-BaNO32" | "Mol-BaSO4" | "Mol-Cu" | "Mol-CuNO32" | "Mol-Ag" | "Mol-Ca3PO42" | "Mol-KNO3" | "Mol-N2" | "Mol-PbNO32" | "Mol-PbSO4" | "Mol-CaO" | "Mol-CuCl2" | "Mol-FeCl2" | "Mol-Cl2" | "Mol-N2O" | "Mol-N2O4" | "Mol-NO2" | "Mol-KClO3" | "Mol-ZnSO4" | "Mol-H3PO4" | "Mol-Na2O" | "Mol-NO" | "Mol-CO" | "Mol-Fe3O4" | "Mol-Cu2S" | "Mol-Cu2O" | "Mol-H3O+" | "Mol-SO42-" | "Mol-Fe2+" | "Mol-OH-" | "Mol-Ag+" | "Mol-PO43-" | "Mol-Ag3PO4" | "Mol-Cu2+" | "Mol-Ca3PO32" | "Mol-NH4Cl" | "Mol-S8" | "Mol-MgOH2" | "Mol-MgCl2";
|
|
32
34
|
//# sourceMappingURL=keyIds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyIds.d.ts","sourceRoot":"","sources":["../../src/types/keyIds.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK;AACf,WAAW;
|
|
1
|
+
{"version":3,"file":"keyIds.d.ts","sourceRoot":"","sources":["../../src/types/keyIds.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK;AACf,gBAAgB;AACd,YAAY,GACZ,aAAa,GACb,mBAAmB,GACnB,oBAAoB;AACtB,WAAW;GACT,IAAI,GACJ,KAAK,GACL,SAAS,GACT,IAAI,GACJ,KAAK,GACL,IAAI,GACJ,IAAI,GACJ,SAAS,GACT,OAAO,GACP,eAAe;AAEjB,aAAa;GACX,QAAQ,GACR,OAAO,GACP,MAAM,GACN,YAAY,GACZ,KAAK,GACL,OAAO,GACP,QAAQ,GACR,KAAK;AAEP,WAAW;GACT,IAAI,GACJ,IAAI,GACJ,OAAO;AAET,cAAc;GACZ,gBAAgB,GAChB,QAAQ,GACR,SAAS;AAEX,gBAAgB;GACd,MAAM,GACN,OAAO,GACP,OAAO,GACP,MAAM,GACN,QAAQ,GACR,MAAM,GACN,SAAS,GACT,QAAQ,GACR,MAAM,GACN,OAAO,GACP,SAAS,GACT,iBAAiB,GACjB,kBAAkB,GAClB,OAAO,GACP,OAAO,GACP,WAAW,GACX,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,QAAQ,GACR,SAAS,GACT,OAAO;AAET,UAAU;GACR,SAAS,GACT,OAAO,GACP,KAAK,GACL,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,UAAU,GACV,YAAY,GACZ,UAAU,GACV,UAAU,GACV,WAAW,GACX,UAAU,GACV,OAAO,GACP,SAAS,GACT,KAAK,GACL,KAAK,GACL,OAAO,GACP,MAAM,GACN,YAAY,GACZ,gBAAgB,GAChB,OAAO;AAET,UAAU;GACR,KAAK,GACL,IAAI,GACJ,KAAK,GACL,QAAQ,GACR,KAAK,GACL,KAAK,GACL,KAAK,GACL,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,KAAK,GACL,IAAI;AAEN,eAAe;GACb,IAAI,GACJ,SAAS;AAEX,YAAY;GACV,eAAe,GACf,UAAU,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.ts","sourceRoot":"","sources":["../../../src/utils/numberPrototype/toScientific.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAK/D,eAAO,MAAM,YAAY,UAChB,MAAM,aACF,MAAM,KAChB,aA+GF,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toScientific = void 0;
|
|
4
|
+
const round_1 = require("../../math/utils/round");
|
|
5
|
+
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
6
|
+
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
7
|
+
const powerNode_1 = require("../../tree/nodes/operators/powerNode");
|
|
8
|
+
const toScientific = function (value, decimals) {
|
|
9
|
+
if (value === Infinity || value === -Infinity)
|
|
10
|
+
throw Error("can't turn infinty into scientific");
|
|
11
|
+
const [intPart, fracPart] = value.toString().split(".");
|
|
12
|
+
if (!fracPart) {
|
|
13
|
+
let nb = "";
|
|
14
|
+
let power = 0;
|
|
15
|
+
if (value < 0) {
|
|
16
|
+
power = intPart.length - 2;
|
|
17
|
+
nb += "-" + intPart[1] + "." + intPart.slice(2);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
power = intPart.length - 1;
|
|
21
|
+
nb += intPart[0] + "." + intPart.slice(1);
|
|
22
|
+
}
|
|
23
|
+
let nbValue = Number(nb);
|
|
24
|
+
if (decimals !== undefined) {
|
|
25
|
+
nbValue = (0, round_1.round)(nbValue, decimals);
|
|
26
|
+
if (nbValue >= 10) {
|
|
27
|
+
nbValue = 1;
|
|
28
|
+
power++;
|
|
29
|
+
}
|
|
30
|
+
else if (nbValue <= -10) {
|
|
31
|
+
nbValue = -1;
|
|
32
|
+
power++;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (power === 0)
|
|
36
|
+
return nbValue.toTree();
|
|
37
|
+
return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(nbValue, decimals !== undefined
|
|
38
|
+
? (0, round_1.roundSignificant)(nbValue, decimals)
|
|
39
|
+
: undefined), power === 1
|
|
40
|
+
? (10).toTree()
|
|
41
|
+
: new powerNode_1.PowerNode((10).toTree(), power.toTree()));
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (Number(intPart) === 0) {
|
|
45
|
+
const firstSignificantIndex = fracPart
|
|
46
|
+
.split("")
|
|
47
|
+
.findIndex((el) => el !== "0");
|
|
48
|
+
if (firstSignificantIndex === -1)
|
|
49
|
+
return value.toTree();
|
|
50
|
+
const leadingZeros = firstSignificantIndex + 1;
|
|
51
|
+
let power = -leadingZeros;
|
|
52
|
+
let nbValue = Number((value < 0 ? "-" : "") +
|
|
53
|
+
fracPart[firstSignificantIndex] +
|
|
54
|
+
"." +
|
|
55
|
+
fracPart.slice(firstSignificantIndex + 1));
|
|
56
|
+
if (decimals !== undefined) {
|
|
57
|
+
nbValue = (0, round_1.round)(nbValue, decimals);
|
|
58
|
+
}
|
|
59
|
+
if (nbValue >= 10) {
|
|
60
|
+
nbValue = 1;
|
|
61
|
+
power++;
|
|
62
|
+
}
|
|
63
|
+
else if (nbValue <= -10) {
|
|
64
|
+
nbValue = -1;
|
|
65
|
+
power++;
|
|
66
|
+
}
|
|
67
|
+
if (power === 0)
|
|
68
|
+
return nbValue.toTree();
|
|
69
|
+
return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(nbValue, decimals !== undefined
|
|
70
|
+
? (0, round_1.roundSignificant)(nbValue, decimals)
|
|
71
|
+
: undefined), power === 1
|
|
72
|
+
? (10).toTree()
|
|
73
|
+
: new powerNode_1.PowerNode((10).toTree(), power.toTree()));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
let nb = "";
|
|
77
|
+
let power = 0;
|
|
78
|
+
if (value < 0) {
|
|
79
|
+
const remainingIntPart = intPart.slice(2);
|
|
80
|
+
nb += "-" + intPart[1] + "." + remainingIntPart + fracPart;
|
|
81
|
+
power = remainingIntPart.length;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const remainingIntPart = intPart.slice(1);
|
|
85
|
+
nb += intPart[0] + "." + remainingIntPart + fracPart;
|
|
86
|
+
power = remainingIntPart.length;
|
|
87
|
+
}
|
|
88
|
+
let nbValue = Number(nb);
|
|
89
|
+
if (decimals !== undefined) {
|
|
90
|
+
nbValue = (0, round_1.round)(nbValue, decimals);
|
|
91
|
+
}
|
|
92
|
+
if (nbValue >= 10) {
|
|
93
|
+
nbValue = 1;
|
|
94
|
+
power++;
|
|
95
|
+
}
|
|
96
|
+
else if (nbValue <= -10) {
|
|
97
|
+
nbValue = -1;
|
|
98
|
+
power++;
|
|
99
|
+
}
|
|
100
|
+
if (power === 0)
|
|
101
|
+
return nbValue.toTree();
|
|
102
|
+
return new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(nbValue, decimals !== undefined
|
|
103
|
+
? (0, round_1.roundSignificant)(nbValue, decimals)
|
|
104
|
+
: undefined), power === 1
|
|
105
|
+
? (10).toTree()
|
|
106
|
+
: new powerNode_1.PowerNode((10).toTree(), power.toTree()));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
exports.toScientific = toScientific;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiresApostropheBefore.d.ts","sourceRoot":"","sources":["../../src/utils/requiresApostropheBefore.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,WAAY,MAAM,4BAEtD,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requiresApostropheBefore = void 0;
|
|
4
|
+
const requiresApostropheBefore = (string) => {
|
|
5
|
+
return string[0].toLowerCase().match(/[a,e,i,o,u,y,h,é,è]/);
|
|
6
|
+
};
|
|
7
|
+
exports.requiresApostropheBefore = requiresApostropheBefore;
|