formula: add indexOf (#431)
This commit is contained in:
parent
ed8f14d573
commit
bb532a62cd
3 changed files with 4 additions and 0 deletions
|
|
@ -5,6 +5,8 @@
|
|||
- bug fixes
|
||||
- meter's properties not accessible (overridden with fader's properties)
|
||||
- `--read-only` option not properly working
|
||||
- widgets
|
||||
- formulas: added `indexOf` function
|
||||
- mobile
|
||||
- button for preventing device sleep
|
||||
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ Where FORMULA is a valid [MathJS](http://mathjs.org/docs/expressions/syntax.html
|
|||
|
||||
Additionnal functions:
|
||||
|
||||
- `indexOf(a, x)`: returns index of item `x` in array `a`
|
||||
- `unpack(x)`: remove an array's brackets (`unpack([1,2])` returns `"1, 2"`)
|
||||
- `pad(x, padding)`: add leading zeros if the length the integer part of `x` is smaller than `padding` (`pad(1,2)` returns `"01"`)
|
||||
- `length(x)`: returns the length of an array or string
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ module.exports = {
|
|||
})
|
||||
math.import({
|
||||
unpack: function(a) { return Array.isArray(a) ? a.toString() : a },
|
||||
indexOf: function(a, x) { return a.indexOf(x) },
|
||||
pad: function(x, padding) {
|
||||
var str = String(x),
|
||||
[int, dec] = str.split('.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue