@odoo/o-spreadsheet 14.0.1 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/o_spreadsheet.cjs.js +17836 -0
- package/dist/o_spreadsheet.d.ts +4102 -0
- package/dist/o_spreadsheet.esm.js +17801 -0
- package/dist/o_spreadsheet.iife.js +17838 -0
- package/dist/o_spreadsheet.iife.min.js +1440 -0
- package/package.json +27 -7
- package/readme.md +10 -0
- package/.eslintrc.json +0 -20
- package/.husky/post-checkout +0 -9
- package/.husky/pre-commit +0 -39
- package/.prettierignore +0 -1
- package/astToFormula.patch +0 -0
- package/demo/data.js +0 -255
- package/demo/index.html +0 -9
- package/demo/libs/Chart.bundle.js +0 -20755
- package/demo/main.js +0 -101
- package/doc/readme.md +0 -46
- package/rollup.config.js +0 -23
- package/src/base_plugin.ts +0 -102
- package/src/components/autofill.ts +0 -146
- package/src/components/bottom_bar.ts +0 -199
- package/src/components/color_picker.ts +0 -150
- package/src/components/composer/autocomplete_dropdown.ts +0 -135
- package/src/components/composer/composer.ts +0 -487
- package/src/components/composer/content_editable_helper.ts +0 -146
- package/src/components/figures/chart.ts +0 -70
- package/src/components/figures/container.ts +0 -268
- package/src/components/figures/text_figure.ts +0 -36
- package/src/components/grid.ts +0 -635
- package/src/components/helpers/dom_helpers.ts +0 -7
- package/src/components/helpers/drag_and_drop.ts +0 -17
- package/src/components/icons.ts +0 -36
- package/src/components/index.ts +0 -1
- package/src/components/menu.ts +0 -288
- package/src/components/overlay.ts +0 -457
- package/src/components/scrollbar.ts +0 -22
- package/src/components/selection_input.ts +0 -168
- package/src/components/side_panel/cell_is_rule_editor.ts +0 -169
- package/src/components/side_panel/chart_panel.ts +0 -104
- package/src/components/side_panel/color_scale_rule_editor.ts +0 -145
- package/src/components/side_panel/conditional_formatting.ts +0 -396
- package/src/components/side_panel/side_panel.ts +0 -127
- package/src/components/side_panel/translations_terms.ts +0 -45
- package/src/components/spreadsheet.ts +0 -198
- package/src/components/top_bar.ts +0 -535
- package/src/constants.ts +0 -26
- package/src/data.ts +0 -149
- package/src/fonts.ts +0 -41
- package/src/formulas/compiler.ts +0 -258
- package/src/formulas/composer_tokenizer.ts +0 -70
- package/src/formulas/index.ts +0 -15
- package/src/formulas/normalize.ts +0 -52
- package/src/formulas/parser.ts +0 -280
- package/src/formulas/range_tokenizer.ts +0 -97
- package/src/formulas/tokenizer.ts +0 -242
- package/src/functions/arguments.ts +0 -114
- package/src/functions/dates.ts +0 -302
- package/src/functions/helpers.ts +0 -592
- package/src/functions/index.ts +0 -52
- package/src/functions/module_database.ts +0 -282
- package/src/functions/module_date.ts +0 -743
- package/src/functions/module_info.ts +0 -69
- package/src/functions/module_logical.ts +0 -208
- package/src/functions/module_lookup.ts +0 -185
- package/src/functions/module_math.ts +0 -1252
- package/src/functions/module_operators.ts +0 -291
- package/src/functions/module_statistical.ts +0 -882
- package/src/functions/module_text.ts +0 -370
- package/src/helpers/color.ts +0 -30
- package/src/helpers/coordinates.ts +0 -71
- package/src/helpers/grid_manipulation.ts +0 -68
- package/src/helpers/index.ts +0 -7
- package/src/helpers/misc.ts +0 -76
- package/src/helpers/numbers.ts +0 -117
- package/src/helpers/uuid.ts +0 -19
- package/src/helpers/zones.ts +0 -263
- package/src/history.ts +0 -186
- package/src/index.ts +0 -84
- package/src/model.ts +0 -261
- package/src/plugins/autofill.ts +0 -412
- package/src/plugins/chart.ts +0 -404
- package/src/plugins/clipboard.ts +0 -461
- package/src/plugins/conditional_format.ts +0 -445
- package/src/plugins/core.ts +0 -1502
- package/src/plugins/edition.ts +0 -157
- package/src/plugins/evaluation.ts +0 -428
- package/src/plugins/figures.ts +0 -123
- package/src/plugins/formatting.ts +0 -630
- package/src/plugins/highlight.ts +0 -187
- package/src/plugins/index.ts +0 -32
- package/src/plugins/merge.ts +0 -524
- package/src/plugins/renderer.ts +0 -571
- package/src/plugins/selection.ts +0 -562
- package/src/plugins/selection_inputs.ts +0 -326
- package/src/registries/autofill_modifiers.ts +0 -76
- package/src/registries/autofill_rules.ts +0 -98
- package/src/registries/figure_registry.ts +0 -30
- package/src/registries/index.ts +0 -7
- package/src/registries/menu_items_registry.ts +0 -110
- package/src/registries/menus/cell_menu_registry.ts +0 -79
- package/src/registries/menus/col_menu_registry.ts +0 -63
- package/src/registries/menus/index.ts +0 -6
- package/src/registries/menus/menu_items_actions.ts +0 -425
- package/src/registries/menus/row_menu_registry.ts +0 -63
- package/src/registries/menus/sheet_menu_registry.ts +0 -75
- package/src/registries/menus/topbar_menu_registry.ts +0 -204
- package/src/registries/side_panel_registry.ts +0 -26
- package/src/registries/topbar_component_registry.ts +0 -12
- package/src/registry.ts +0 -51
- package/src/translation.ts +0 -44
- package/src/types/autofill.ts +0 -48
- package/src/types/chart.ts +0 -26
- package/src/types/commands.ts +0 -716
- package/src/types/conditional_formatting.ts +0 -124
- package/src/types/env.ts +0 -13
- package/src/types/functions.ts +0 -35
- package/src/types/getters.ts +0 -103
- package/src/types/index.ts +0 -20
- package/src/types/misc.ts +0 -143
- package/src/types/rendering.ts +0 -41
- package/src/types/workbook_data.ts +0 -62
- package/tests/__mocks__/uuid.ts +0 -7
- package/tests/canvas.mock.ts +0 -34
- package/tests/components/__mocks__/content_editable_helper.ts +0 -79
- package/tests/components/__mocks__/scrollbar.ts +0 -18
- package/tests/components/__snapshots__/autocomplete_dropdown_test.ts.snap +0 -29
- package/tests/components/__snapshots__/bottom_bar_test.ts.snap +0 -75
- package/tests/components/__snapshots__/context_menu_test.ts.snap +0 -88
- package/tests/components/__snapshots__/grid_test.ts.snap +0 -60
- package/tests/components/__snapshots__/spreadsheet_test.ts.snap +0 -455
- package/tests/components/__snapshots__/top_bar_test.ts.snap +0 -705
- package/tests/components/autocomplete_dropdown_test.ts +0 -315
- package/tests/components/autofill_test.ts +0 -167
- package/tests/components/bottom_bar_test.ts +0 -262
- package/tests/components/chart_side_panel_test.ts +0 -123
- package/tests/components/composer_test.ts +0 -400
- package/tests/components/context_menu_test.ts +0 -825
- package/tests/components/grid_manipulation_test.ts +0 -163
- package/tests/components/grid_test.ts +0 -581
- package/tests/components/overlay_test.ts +0 -541
- package/tests/components/selection_input_test.ts +0 -259
- package/tests/components/side_panel_test.ts +0 -148
- package/tests/components/spreadsheet_test.ts +0 -194
- package/tests/components/top_bar_test.ts +0 -427
- package/tests/data_test.ts +0 -175
- package/tests/dom_helper.ts +0 -42
- package/tests/formulas/__snapshots__/compiler_test.ts.snap +0 -302
- package/tests/formulas/compiler_test.ts +0 -266
- package/tests/formulas/composer_tokenizer_test.ts +0 -137
- package/tests/formulas/expressions_test.ts +0 -57
- package/tests/formulas/formulas_test.ts +0 -80
- package/tests/formulas/normalize_test.ts +0 -82
- package/tests/formulas/parser_test.ts +0 -224
- package/tests/formulas/range_tokenizer_test.ts +0 -187
- package/tests/formulas/tokenizer_test.ts +0 -164
- package/tests/functions/arguments_test.ts +0 -141
- package/tests/functions/dates_test.ts +0 -1081
- package/tests/functions/functions_test.ts +0 -53
- package/tests/functions/helper_test.ts +0 -98
- package/tests/functions/module_database_test.ts +0 -311
- package/tests/functions/module_date_test.ts +0 -941
- package/tests/functions/module_info_test.ts +0 -139
- package/tests/functions/module_logical_test.ts +0 -369
- package/tests/functions/module_lookup_test.ts +0 -541
- package/tests/functions/module_math_test.ts +0 -2482
- package/tests/functions/module_operators_test.ts +0 -955
- package/tests/functions/module_statistical_test.ts +0 -2014
- package/tests/functions/module_text_test.ts +0 -667
- package/tests/helpers/coordinates_test.ts +0 -25
- package/tests/helpers/misc_test.ts +0 -95
- package/tests/helpers/numbers_test.ts +0 -196
- package/tests/helpers/zones_test.ts +0 -97
- package/tests/helpers.ts +0 -384
- package/tests/menu_items_registry_test.ts +0 -540
- package/tests/model/plugins/__snapshots__/chart_test.ts.snap +0 -90
- package/tests/model/plugins/chart_test.ts +0 -562
- package/tests/model_test.ts +0 -82
- package/tests/plugins/__snapshots__/conditional_formatting_test.ts.snap +0 -131
- package/tests/plugins/__snapshots__/renderer_test.ts.snap +0 -371
- package/tests/plugins/autofill_test.ts +0 -457
- package/tests/plugins/borders_test.ts +0 -295
- package/tests/plugins/clipboard_test.ts +0 -1180
- package/tests/plugins/conditional_formatting_test.ts +0 -1253
- package/tests/plugins/core_test.ts +0 -614
- package/tests/plugins/edition_test.ts +0 -100
- package/tests/plugins/evaluation_async_test.ts +0 -332
- package/tests/plugins/evaluation_dates_test.ts +0 -79
- package/tests/plugins/evaluation_test.ts +0 -901
- package/tests/plugins/figures_test.ts +0 -327
- package/tests/plugins/formatting_test.ts +0 -391
- package/tests/plugins/grid_manipulation_test.ts +0 -1366
- package/tests/plugins/highlight_test.ts +0 -413
- package/tests/plugins/history_test.ts +0 -142
- package/tests/plugins/import_export_test.ts +0 -276
- package/tests/plugins/merges_test.ts +0 -490
- package/tests/plugins/navigation_test.ts +0 -181
- package/tests/plugins/plugins/evaluation_test.ts +0 -111
- package/tests/plugins/renderer_test.ts +0 -598
- package/tests/plugins/resizing_test.ts +0 -152
- package/tests/plugins/selection_input_test.ts +0 -409
- package/tests/plugins/selection_test.ts +0 -442
- package/tests/plugins/sheets_test.ts +0 -643
- package/tests/plugins/style_test.ts +0 -90
- package/tsconfig.json +0 -22
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { _lt } from "../translation";
|
|
2
|
-
import { FunctionDescription } from "../types";
|
|
3
|
-
import { args } from "./arguments";
|
|
4
|
-
import { InternalDate } from "./dates";
|
|
5
|
-
import { extractDateValue, numberToJsDate, toNumber, toString } from "./helpers";
|
|
6
|
-
import { POWER } from "./module_math";
|
|
7
|
-
|
|
8
|
-
// -----------------------------------------------------------------------------
|
|
9
|
-
// ADD
|
|
10
|
-
// -----------------------------------------------------------------------------
|
|
11
|
-
export const ADD: FunctionDescription = {
|
|
12
|
-
description: _lt(`Sum of two numbers.`),
|
|
13
|
-
args: args(`
|
|
14
|
-
value1 (number) ${_lt("The first addend.")}
|
|
15
|
-
value2 (number) ${_lt("The second addend.")}
|
|
16
|
-
`),
|
|
17
|
-
returns: ["NUMBER"],
|
|
18
|
-
compute: function (value1: any, value2: any): number | InternalDate {
|
|
19
|
-
if (value1 && value1.value) {
|
|
20
|
-
if (value2 && value2.value) {
|
|
21
|
-
return value1.value + value2.value;
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
value: value1.value + toNumber(value2),
|
|
25
|
-
format: value1.format,
|
|
26
|
-
jsDate: numberToJsDate(value1.value + toNumber(value2)),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
return toNumber(value1) + toNumber(value2);
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
// -----------------------------------------------------------------------------
|
|
34
|
-
// CONCAT
|
|
35
|
-
// -----------------------------------------------------------------------------
|
|
36
|
-
export const CONCAT: FunctionDescription = {
|
|
37
|
-
description: _lt(`Concatenation of two values.`),
|
|
38
|
-
args: args(`
|
|
39
|
-
value1 (string) ${_lt("The value to which value2 will be appended.")}
|
|
40
|
-
value2 (string) ${_lt("The value to append to value1.")}
|
|
41
|
-
`),
|
|
42
|
-
returns: ["STRING"],
|
|
43
|
-
compute: function (value1: any, value2: any): string {
|
|
44
|
-
return toString(value1) + toString(value2);
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// -----------------------------------------------------------------------------
|
|
49
|
-
// DIVIDE
|
|
50
|
-
// -----------------------------------------------------------------------------
|
|
51
|
-
export const DIVIDE: FunctionDescription = {
|
|
52
|
-
description: _lt(`One number divided by another.`),
|
|
53
|
-
args: args(`
|
|
54
|
-
dividend (number) ${_lt("The number to be divided.")}
|
|
55
|
-
divisor (number) ${_lt("The number to divide by.")}
|
|
56
|
-
`),
|
|
57
|
-
returns: ["NUMBER"],
|
|
58
|
-
compute: function (dividend: any, divisor: any): number {
|
|
59
|
-
const _divisor = toNumber(divisor);
|
|
60
|
-
if (_divisor === 0) {
|
|
61
|
-
throw new Error(_lt("Function DIVIDE parameter 2 cannot be zero."));
|
|
62
|
-
}
|
|
63
|
-
return toNumber(dividend) / _divisor;
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// -----------------------------------------------------------------------------
|
|
68
|
-
// EQ
|
|
69
|
-
// -----------------------------------------------------------------------------
|
|
70
|
-
function isEmpty(value: any): boolean {
|
|
71
|
-
return value === null || value === undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const getNeutral = { number: 0, string: "", boolean: false };
|
|
75
|
-
|
|
76
|
-
export const EQ: FunctionDescription = {
|
|
77
|
-
description: _lt(`Equal.`),
|
|
78
|
-
args: args(`
|
|
79
|
-
value1 (any) ${_lt("The first value.")}
|
|
80
|
-
value2 (any) ${_lt("The value to test against value1 for equality.")}
|
|
81
|
-
`),
|
|
82
|
-
returns: ["BOOLEAN"],
|
|
83
|
-
compute: function (value1: any, value2: any): boolean {
|
|
84
|
-
value1 = isEmpty(value1) ? getNeutral[typeof value2] : value1;
|
|
85
|
-
value2 = isEmpty(value2) ? getNeutral[typeof value1] : value2;
|
|
86
|
-
if (typeof value1 === "string") {
|
|
87
|
-
value1 = value1.toUpperCase();
|
|
88
|
-
}
|
|
89
|
-
if (typeof value2 === "string") {
|
|
90
|
-
value2 = value2.toUpperCase();
|
|
91
|
-
}
|
|
92
|
-
value1 = extractDateValue(value1);
|
|
93
|
-
value2 = extractDateValue(value2);
|
|
94
|
-
return value1 === value2;
|
|
95
|
-
},
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// -----------------------------------------------------------------------------
|
|
99
|
-
// GT
|
|
100
|
-
// -----------------------------------------------------------------------------
|
|
101
|
-
function applyRelationalOperator(
|
|
102
|
-
value1: any,
|
|
103
|
-
value2: any,
|
|
104
|
-
cb: (v1: any, v2: any) => boolean
|
|
105
|
-
): boolean {
|
|
106
|
-
value1 = isEmpty(value1) ? getNeutral[typeof value2] : value1;
|
|
107
|
-
value2 = isEmpty(value2) ? getNeutral[typeof value1] : value2;
|
|
108
|
-
value1 = extractDateValue(value1);
|
|
109
|
-
value2 = extractDateValue(value2);
|
|
110
|
-
|
|
111
|
-
if (typeof value1 !== "number") {
|
|
112
|
-
value1 = toString(value1).toUpperCase();
|
|
113
|
-
}
|
|
114
|
-
if (typeof value2 !== "number") {
|
|
115
|
-
value2 = toString(value2).toUpperCase();
|
|
116
|
-
}
|
|
117
|
-
const tV1 = typeof value1;
|
|
118
|
-
const tV2 = typeof value2;
|
|
119
|
-
if (tV1 === "string" && tV2 === "number") {
|
|
120
|
-
return true;
|
|
121
|
-
}
|
|
122
|
-
if (tV2 === "string" && tV1 === "number") {
|
|
123
|
-
return false;
|
|
124
|
-
}
|
|
125
|
-
return cb(value1, value2);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export const GT: FunctionDescription = {
|
|
129
|
-
description: _lt(`Strictly greater than.`),
|
|
130
|
-
args: args(`
|
|
131
|
-
value1 (any) ${_lt("The value to test as being greater than value2.")}
|
|
132
|
-
value2 (any) ${_lt("The second value.")}
|
|
133
|
-
`),
|
|
134
|
-
returns: ["BOOLEAN"],
|
|
135
|
-
compute: function (value1: any, value2: any): boolean {
|
|
136
|
-
return applyRelationalOperator(value1, value2, (v1, v2) => {
|
|
137
|
-
return v1 > v2;
|
|
138
|
-
});
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// -----------------------------------------------------------------------------
|
|
143
|
-
// GTE
|
|
144
|
-
// -----------------------------------------------------------------------------
|
|
145
|
-
export const GTE: FunctionDescription = {
|
|
146
|
-
description: _lt(`Greater than or equal to.`),
|
|
147
|
-
args: args(`
|
|
148
|
-
value1 (any) ${_lt("The value to test as being greater than or equal to value2.")}
|
|
149
|
-
value2 (any) ${_lt("The second value.")}
|
|
150
|
-
`),
|
|
151
|
-
returns: ["BOOLEAN"],
|
|
152
|
-
compute: function (value1: any, value2: any): boolean {
|
|
153
|
-
return applyRelationalOperator(value1, value2, (v1, v2) => {
|
|
154
|
-
return v1 >= v2;
|
|
155
|
-
});
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// -----------------------------------------------------------------------------
|
|
160
|
-
// LT
|
|
161
|
-
// -----------------------------------------------------------------------------
|
|
162
|
-
export const LT: FunctionDescription = {
|
|
163
|
-
description: _lt(`Less than.`),
|
|
164
|
-
args: args(`
|
|
165
|
-
value1 (any) ${_lt("The value to test as being less than value2.")}
|
|
166
|
-
value2 (any) ${_lt("The second value.")}
|
|
167
|
-
`),
|
|
168
|
-
returns: ["BOOLEAN"],
|
|
169
|
-
compute: function (value1: any, value2: any): boolean {
|
|
170
|
-
return !GTE.compute(value1, value2);
|
|
171
|
-
},
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
// -----------------------------------------------------------------------------
|
|
175
|
-
// LTE
|
|
176
|
-
// -----------------------------------------------------------------------------
|
|
177
|
-
export const LTE: FunctionDescription = {
|
|
178
|
-
description: _lt(`Less than or equal to.`),
|
|
179
|
-
args: args(`
|
|
180
|
-
value1 (any) ${_lt("The value to test as being less than or equal to value2.")}
|
|
181
|
-
value2 (any) ${_lt("The second value.")}
|
|
182
|
-
`),
|
|
183
|
-
returns: ["BOOLEAN"],
|
|
184
|
-
compute: function (value1: any, value2: any): boolean {
|
|
185
|
-
return !GT.compute(value1, value2);
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
// -----------------------------------------------------------------------------
|
|
190
|
-
// MINUS
|
|
191
|
-
// -----------------------------------------------------------------------------
|
|
192
|
-
export const MINUS: FunctionDescription = {
|
|
193
|
-
description: _lt(`Difference of two numbers.`),
|
|
194
|
-
args: args(`
|
|
195
|
-
value1 (number) ${_lt("The minuend, or number to be subtracted from.")}
|
|
196
|
-
value2 (number) ${_lt("The subtrahend, or number to subtract from value1.")}
|
|
197
|
-
`),
|
|
198
|
-
returns: ["NUMBER"],
|
|
199
|
-
compute: function (value1: any, value2: any): number {
|
|
200
|
-
return toNumber(value1) - toNumber(value2);
|
|
201
|
-
},
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// -----------------------------------------------------------------------------
|
|
205
|
-
// MULTIPLY
|
|
206
|
-
// -----------------------------------------------------------------------------
|
|
207
|
-
export const MULTIPLY: FunctionDescription = {
|
|
208
|
-
description: _lt(`Product of two numbers`),
|
|
209
|
-
args: args(`
|
|
210
|
-
factor1 (number) ${_lt("The first multiplicand.")}
|
|
211
|
-
factor2 (number) ${_lt("The second multiplicand.")}
|
|
212
|
-
`),
|
|
213
|
-
returns: ["NUMBER"],
|
|
214
|
-
compute: function (factor1: any, factor2: any): number {
|
|
215
|
-
return toNumber(factor1) * toNumber(factor2);
|
|
216
|
-
},
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
// -----------------------------------------------------------------------------
|
|
220
|
-
// NE
|
|
221
|
-
// -----------------------------------------------------------------------------
|
|
222
|
-
export const NE: FunctionDescription = {
|
|
223
|
-
description: _lt(`Not equal.`),
|
|
224
|
-
args: args(`
|
|
225
|
-
value1 (any) ${_lt("The first value.")}
|
|
226
|
-
value2 (any) ${_lt("The value to test against value1 for inequality.")}
|
|
227
|
-
`),
|
|
228
|
-
returns: ["BOOLEAN"],
|
|
229
|
-
compute: function (value1: any, value2: any): boolean {
|
|
230
|
-
return !EQ.compute(value1, value2);
|
|
231
|
-
},
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
// -----------------------------------------------------------------------------
|
|
235
|
-
// POW
|
|
236
|
-
// -----------------------------------------------------------------------------
|
|
237
|
-
export const POW: FunctionDescription = {
|
|
238
|
-
description: _lt(`A number raised to a power.`),
|
|
239
|
-
args: args(`
|
|
240
|
-
base (number) ${_lt("The number to raise to the exponent power.")}
|
|
241
|
-
exponent (number) ${_lt("The exponent to raise base to.")}
|
|
242
|
-
`),
|
|
243
|
-
returns: ["BOOLEAN"],
|
|
244
|
-
compute: function (base: any, exponent: any): number {
|
|
245
|
-
return POWER.compute(base, exponent);
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
// -----------------------------------------------------------------------------
|
|
250
|
-
// UMINUS
|
|
251
|
-
// -----------------------------------------------------------------------------
|
|
252
|
-
export const UMINUS: FunctionDescription = {
|
|
253
|
-
description: _lt(`A number with the sign reversed.`),
|
|
254
|
-
args: args(`
|
|
255
|
-
value (number) ${_lt(
|
|
256
|
-
"The number to have its sign reversed. Equivalently, the number to multiply by -1."
|
|
257
|
-
)}
|
|
258
|
-
`),
|
|
259
|
-
returns: ["NUMBER"],
|
|
260
|
-
compute: function (value: any): number {
|
|
261
|
-
return -toNumber(value);
|
|
262
|
-
},
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
// -----------------------------------------------------------------------------
|
|
266
|
-
// UNARY_PERCENT
|
|
267
|
-
// -----------------------------------------------------------------------------
|
|
268
|
-
export const UNARY_PERCENT: FunctionDescription = {
|
|
269
|
-
description: _lt(`Value interpreted as a percentage.`),
|
|
270
|
-
args: args(`
|
|
271
|
-
percentage (number) ${_lt("The value to interpret as a percentage.")}
|
|
272
|
-
`),
|
|
273
|
-
returns: ["NUMBER"],
|
|
274
|
-
compute: function (percentage: any): number {
|
|
275
|
-
return toNumber(percentage) / 100;
|
|
276
|
-
},
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
// -----------------------------------------------------------------------------
|
|
280
|
-
// UPLUS
|
|
281
|
-
// -----------------------------------------------------------------------------
|
|
282
|
-
export const UPLUS: FunctionDescription = {
|
|
283
|
-
description: _lt(`A specified number, unchanged.`),
|
|
284
|
-
args: args(`
|
|
285
|
-
value (any) ${_lt("The number to return.")}
|
|
286
|
-
`),
|
|
287
|
-
returns: ["ANY"],
|
|
288
|
-
compute: function (value: any): any {
|
|
289
|
-
return value;
|
|
290
|
-
},
|
|
291
|
-
};
|