Skip to content

0.21.0

Compare
Choose a tag to compare
@kylef kylef released this 15 Nov 21:39
· 110 commits to master since this release

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 import JSON06Serialiser and other APIs from minim directly.

    const { JSON06Serialiser } = require('minim');
  • flatMap in ArraySlice no longer removes empty items. Instead flatMap 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 method compactMap.

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 a filter 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 to ArrayElement.

Bug Fixes

  • The default content value of an element is undefined. Whereas before the
    default value was null.

  • 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 an ArrayElement 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. The variable 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.