ArrayElement
'scontains
method has been renamed toincludes
to be consistent withArray.includes
.ArrayElement.contains
has been deprecated, and remains for compatibility.
- Prevent throwing an error when calling
toValue()
on an element with a key value pair which does not have a value.
- Prevents the JSON serializer from serializing an empty object (
{}
) under meta and attributes under the case where none of the meta or attribute member's have a value. This prevents{}
from being present under meta or attributes when setting a member with an undefined key.
- Fixes a JSON 0.6 serialisation bug where httpRequest and similar array-based elements with undefined content would be serialised with undefined content instead of an empty array as content.
This release brings some performance improvements, namely to serialising with the JSON serialisers.
- Fixes serialisation of default values in enumerations in Refract JSON 0.6 serialisation.
- Added support for IE11 in the included web distribution of minim
(
dist/minim.js
).
- Fixes serialisation of array and object sample values in enumerations in Refract JSON 0.6 serialisation.
- Restores documentation coverage for all elements, some was unintentionally removed in 0.23.0.
- Support for Node 4 has been removed. Minim now supports Node >= 6.
- Minim no longer uses uptown and thus the
extend
API has been removed.
- Calling
.freeze()
on a frozen element is now supported. Previously you may see an error thrown while freeze was trying to attach parents to any child elements.
- Fixes serialising an element with an undefined meta or attributes value. For
example if a meta value (
id
) was set toundefined
, then it should not be serialised. Previously the serialiser would throw an exception that undefined was not an element.
ArrayElement
now conforms to parts of the Fantasy Land 3.5 specification.Functor
,Semigroup
,Monoid
,Filterable
,Chain
, andFoldable
are now supported.
- Empty parseResult and link arrays are serialised in JSON 06 Serialiser, a regression of 0.21.0 caused these to not be serialised.
-
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 withArray.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
.
-
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
toArrayElement
.
-
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 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.
- Fixes a regression from 0.20.6 where
metadata
became anObjectElement
instead ofArrayElement
as it was in the past.
-
JSON 0.6 deserialiser will now correct deserialise an API Categories
meta
attribute intometadata
. -
JSON Serialisers will now use elements from the given namespace during serialisation checks and deserialisation.
- JSON 0.6 enum serialisation will now remove
fixed
typeAttributes which are now present in API Elements 1.0 enumerations. These are removed for consistent serialisation of the 0.6 serialiser.
- Further performance improvements have been made to JSON Serialisation. The serialiser can now deserialise deep structures substantially faster.
- Minim NPM package now contains a browser distribution in
dist/minim.js
. - Performance improvements have been made to JSON Serialisation. The serialiser can now serialise deep structures a little faster.
- The JSON 0.6 serialiser will now serialise empty content arrays. A regression caused in 0.20.1 because of the logic was applied to both Refract JSON 1.0 and 0.6 serialisers.
- Prevent de-serialising
undefined
if the default element's content is not null. - No longer serialise an empty array in the JSON serialisers, instead the content can be removed for consistency with other tools.
- Adds a
reject
method toArrayElement
,ObjectElement
,ArraySlice
, andObjectSlice
which complements thefilter
method providing the ability to exclude vs filter matched elements.
- The Refract JSON 0.6 serialiser will de-serialise enum elements into the form
in the API Elements 1.0 specification. This is a breaking change on the
layout of the enum. Default and sample values will now be an
enum
element themselves.
- JSON deserialisers will now prevent overriding default element content
values with undefined. This could cause problems where internal state of
array or object element would have undefined as content and thus cause other
Element methods to later fail such as
toValue
orget
.
- ArraySlice now provides a
find
method allowing you to find the first element satisfying the given value. - ArraySlice.filter now accepts element names or element classes to filter.
- ArraySlice now provides
flatMap
allowing you to map and then flatten the results.
- Accessing lazy meta accessors on frozen elements such as
title
will now return a frozen default value. Previously this would raise an exception trying to mutate the element.
- Serialisers will now throw TypeError with straight forward messages when you try to serialise a non-element type.
-
While accessing meta or attributes of a frozen element that does not contain meta or attributes, an exception was raised because these accessors would lazy load and attempt to mutate the element.
These accessors will now return an empty frozen
ObjectElement
in these cases now to prevent mutation. -
Fixes JSON 0.6 Deserialiser to correct deserialise enum elements.
- When multiple sample values were present additional values were being discarded.
- Deserialised enum content contained duplicate enumeration values.
- Updated enum serialization/deserialization in the JSON 0.6 serializer to match apiaryio/api-elements#28
Element.children
andElement.recursiveChildren
now returnArraySlice
instead of anArrayElement
.ArrayElement.filter
andArrayElement.find*
now returnArraySlice
instead of anArrayElement
.- The
first
,second
andlast
methods onArrayElement
are now properties instead of methods. ObjectElement.filter
now returns anObjectSlice
instead of anObjectElement
.- When providing multiple element names to
Element.findRecursive
you must callfreeze
on the element beforehand so that the element has access to the parent of the element.
- Introduced JSDoc documentation to public interfaces
Element
now contains afreeze
method to freeze and prevent an element from being mutated, this also adds a parent property on all child elements.
- Handle serializing key-value pair without value
- Deserialize
dataStructure
containing an array correctly
- Prevent JSON Serialisers from throwing exception when serialising a key value pair without any value.
-
JSON Serialisation now follows the JSON Refract serialisation rules defined at https://github.com/refractproject/refract-spec/blob/master/formats/json-refract.md.
Existing serialiser is available during a transition period to aid migration to the new format.
const JSONSerialiser = require('minim/serialisers/json-0.6'); const serialiser = new JSONSerialiser(); const element = serialiser.deserialise('Hello'); serialiser.serialise(element);
- ArrayElement high-order functions,
map
,filter
andforEach
now acceptthisArg
like the equivalent functionality inArray
.
- Initialising an Element with given meta or attributes as ObjectElement is now supported.
- When converting JavaScript values to Refract, objects are now supported.
- Adds a special case to serialise sourceMap elements as values.
-
Element.toRefract()
andElement.fromRefract()
have been removed. JSON Serialisation is now decoupled from the Element model. A minim namespace provides a conveniencetoRefract(element)
andfromRefract(object)
methods. -
ArrayElement
children
method has been replaced by achildren
property on all elements. You may now chain children in conjunction withfilter
to get the existing behaviour.Before:
const numbers = doc.children((element) => element.element == 'number');
After:
const numbers = doc.children.filter((element) => element.element == 'number');
OR
const numbers = doc.children.findByElement('number');
-
BaseElement
has been renamed toElement
. -
Embedded Refract support has been removed.
- All elements now contain a
children
andrecursiveChildren
properties that return an ArrayElement of the respective children elements. - JSON Serialiser will no longer serialise empty
meta
andattributes
into JSON objects. - Minim now contains a
RefElement
. - Element now contains a
toRef()
function to create a ref element referencing the element.
- Node 0.10 and 0.12 are no longer supported.
- Elements
name
property was removed. There is no longer a name property in Refract specification.
- Elements now provide a
findRecursive
method allowing you to recursively find matching elements. - Added function for remove key in an Object element and Array element
- New
isEmpty
convenience property for determining if an array is empty.
- Getters of link element will now return an element
- Meta convenience methods will now return an element
- Update Lodash version
- Update Uptown to 0.4.1
-
BREAKING The public interface of the
minim
module has changed significantly. List of changes:- Removed
toCompactRefract
andfromCompactRefract
- Improved the default refract serialization such that when an element in
attributes
has its own metadata or attributes defined then it will now be refracted when callingtoRefract
- Removed
- Added support for hyperlinks per RFC 0008
- Upgraded Lodash to 3.10.1
- Refract elements will be automatically parsed when found in arrays in
meta
- When an element in
meta
has its own metadata or attributes defined then it will now be refracted when callingtoRefract
ortoCompactRefract
. - When loading from refract or compact refract, if an item in
meta
looks like an element it will be loaded as such. This may cause false positives.
- Fix a bug related to setting the default key names that should be treated as refracted elements in element attributes. This is now accomplished via the namespace:
namespace._elementAttributeKeys.push('my-value');
. This fixes bugs related to overwriting thenamespace.BaseElement
.
- Fix a bug when loading refracted attributes from compact refract.
-
Provide a way for elements to mark attributes as unrefracted arrays of refracted elements. Subclassed elements can push onto the
_attributeElementArrayKeys
property to use this feature. Note: in the future this feature may go away. -
Allow
load
to be used for plugins where a namespace is not being used -
Add an
elements
property to theNamespace
class which returns an object of PascalCased element name keys to registered element class values. This allows for ES6 use cases like:const {StringElement, ArrayElement, ObjectElement} = namespace.elements;
-
Add functionality for Embedded Refract
The public interface of the minim
module has changed significantly. List of changes:
ElementRegistry
has been renamed toNamespace
.minim
has only one public method, callednamespace
, which creates a newNamespace
instance.minim.convertToElement
is nownamespace.toElement
minim.convertFromRefract
is nownamespace.fromRefract
minim.convertFromCompactRefract
is nownamespace.fromCompactRefract
minim.*Element
are removed (except fornamespace.BaseElement
). These should be accessed vianamespace.getElementClass('name')
now.- The
Namespace
has a new methoduse
which loads a plugin namespace and is chainable, e.g.namespace.use(plugin1).use(plugin2)
. - A
Namespace
can be initialized without any default elements by passing an options object withnoDefault
set tofalse
to the constructor. They can be initialized later via theuseDefault
method.
Before:
var minim = require('minim');
minim.convertToElement([1, 2, 3]);
After:
var minim = require('minim');
var namespace = minim.namespace();
namespace.toElement([1, 2, 3]);
- Add a
.toValue()
method to member elements which returns a hash with the key and value and their respective values.
- Rename the
class
metadata property toclasses
. The convenience property is also now calledclasses
, e.g.element.classes.contains('abc')
.
- Allow the iterator protocol to be used with arrays and objects if the runtime
supports it. This enables using
for ... of
loops on elements as well as rest operators, destructuring,yield*
, etc. - Convenience properties for simple types now return the value result. Instead
of
element.title.toValue()
you now useelement.title
. - Add array indexes to
#forEach
. - Add a
#clone
method. - Add a
#reduce
method. - Fix a serialization bug when initializing using falsey values
(
null
,0
,false
).
- Allow
#set
to take an object for Object Elements - Convert
meta
to be Minim Object Elements - Convert
attributes
to be Minim Object Elements - Sync class and method names with Refract 0.2.0 spec
- Add convenience methods for
meta
attributes, such asid
orclass
- Add finder functions, such as
findByElement
andfindByClass
- Upgrade to use Uptown 0.4.0
- Organize code