Skip to content

This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.

PERCENTAGE_PACKAGE

const PERCENTAGE_PACKAGE: IEnginePackage;

Defined in: packages/engine/src/packages/percentage/PercentagePackage.ts:35

Percentage syntax: 50%, 50% of 200, 100 to 150 (percentage change), increase 100 by 10%/decrease 100 by 10% (prefix form), the 100 increase by 10%/100 decrease by 10% infix form (fused from the “increase by”/“decrease by” phrases by the built-in normalizer. See BuiltinNormalizerRules.BUILTIN_PHRASES), and 5% of what is 6 (solve for the base value. See OfWhatIsParselet.ts’s doc comment). “of what is” is phrase-fused (not a bare “what” keyword) for the same variable-name-collision reason “total”/“average”/etc. are fused elsewhere in this codebase, “what” is common enough to be worth protecting as a :variableName.

Successive change is 120 up 10% then down 10% (118.80, not 120), 50 up 20%, 80 down 15% and the repeat form 100 up 10% three times. up/down are retyped from a bare IDENT only when a percentage follows (percentUpDownNormalizerRule), so prose keeps the words. See UpDownParselet.ts.