0.21.0
Breaking
-
Minim no longer supports importing files directly from the minim package.
Importing the JSON 0.6 serialiser via
require('minim/lib/serialisers/json-0.6')
is not supported, it is now
recommended to importJSON06Serialiser
and other APIs from minim directly.const { JSON06Serialiser } = require('minim');
-
flatMap
inArraySlice
no longer removes empty items. InsteadflatMap
is
aligned with
Array.flatMap
which first maps each element using a mapping function, then flattens the
result into a new array.Existing
flatMap
behaviour is now available under the methodcompactMap
.
Enhancements
-
Object Element can now be created with an array of member elements.
-
You can now create an element from an ArraySlice or ObjectSlice, for example,
passing the result of afilter
operation into a new element.const numbers = new ArrayElement([1, 2, 3, 4]) new ArrayElement(numbers.filter((e) => e.toValue() % 2))
-
Adds
compactMap
functionality to Array and Object elements allowing you to
returns an array containing the truthy results of calling the given
transformation with each element of this sequence. -
Added
flatMap
toArrayElement
.
Bug Fixes
-
The default content value of an element is undefined. Whereas before the
default value wasnull
. -
Setting the
content
property on an Element now behaves the same as passing
content in to the constructor. For example, the following two elements are
identical:new ArrayElement([1]) const element = new ArrayElement() element.content = [1]
Passing
[1]
to anArrayElement
constructor would produce an array of
number elements, whereas setting the content to[1]
resulted in setting the
content to be an array of non-elements which is invalid. -
The serialisation of the
variable
attribute in the JSON 0.6 serialisation
is updated to reflect API Elements 1.0. Thevariable
attribute is now
present on a member element instead of the key of a member element. -
Empty arrays are no longer serialised in JSON 06 Serialiser.