maths: add extend(x, y) for merging two objects (#387)

This commit is contained in:
jean-emmanuel 2018-10-15 22:50:19 +02:00
parent 65f9dbb011
commit 87dc9e98dd
3 changed files with 4 additions and 0 deletions

View file

@ -18,6 +18,8 @@
- added keyboard shortcut `mod + shift + a` for cancelling selection
- added multi widget selection with mouse when `shift` is pressed
- right-click doesn't modify current selection when `mod` or `shift` is pressed
- formulas
- added `extend(x, y)` function for merging two objects
## 0.37.4

View file

@ -85,6 +85,7 @@ Additionnal functions:
- `length(x)`: returns the length of an array or string
- `keys(x)`: returns an array of a given object's property names (from [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys))
- `values(x)`: returns an array of a given object's own enumerable property values (from [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/values))
- `extend(x, y)`: merges two objects into one
!!! tip ""
A single widget property can contain multiple formulas. Variables and functions declared in a formula are available to subsequent formulas in the same property definition.

View file

@ -88,6 +88,7 @@ module.exports = {
length: function(x) { return x.length },
values: function(x) { return Object.values(x) },
keys: function(x) { return Object.keys(x) },
extend: function(x, y) { return Object.assign(x, y) },
timestamp: function() { return Date.now() },
// basic relationnal to keep alphabetical string comparison (v4 change)
equal: function(a, b) { return a == b },