ArrayElement'scontainsmethod has been renamed toincludesto be consistent withArray.includes.ArrayElement.containshas 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
extendAPI 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.
ArrayElementnow conforms to parts of the Fantasy Land 3.5 specification.Functor,Semigroup,Monoid,Filterable,Chain, andFoldableare 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 importJSON06Serialiserand other APIs from minim directly.const { JSON06Serialiser } = require('minim');
-
flatMapinArraySliceno longer removes empty items. InsteadflatMapis aligned withArray.flatMapwhich first maps each element using a mapping function, then flattens the result into a new array.Existing
flatMapbehaviour 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
filteroperation into a new element.const numbers = new ArrayElement([1, 2, 3, 4]) new ArrayElement(numbers.filter((e) => e.toValue() % 2)) -
Adds
compactMapfunctionality 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
flatMaptoArrayElement.
-
The default content value of an element is undefined. Whereas before the default value was
null. -
Setting the
contentproperty 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 anArrayElementconstructor 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
variableattribute in the JSON 0.6 serialisation is updated to reflect API Elements 1.0. Thevariableattribute 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
metadatabecame anObjectElementinstead ofArrayElementas it was in the past.
-
JSON 0.6 deserialiser will now correct deserialise an API Categories
metaattribute intometadata. -
JSON Serialisers will now use elements from the given namespace during serialisation checks and deserialisation.
- JSON 0.6 enum serialisation will now remove
fixedtypeAttributes 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
undefinedif 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
rejectmethod toArrayElement,ObjectElement,ArraySlice, andObjectSlicewhich complements thefiltermethod 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
enumelement 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
toValueorget.
- ArraySlice now provides a
findmethod 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
flatMapallowing you to map and then flatten the results.
- Accessing lazy meta accessors on frozen elements such as
titlewill 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
ObjectElementin 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.childrenandElement.recursiveChildrennow returnArraySliceinstead of anArrayElement.ArrayElement.filterandArrayElement.find*now returnArraySliceinstead of anArrayElement.- The
first,secondandlastmethods onArrayElementare now properties instead of methods. ObjectElement.filternow returns anObjectSliceinstead of anObjectElement.- When providing multiple element names to
Element.findRecursiveyou must callfreezeon the element beforehand so that the element has access to the parent of the element.
- Introduced JSDoc documentation to public interfaces
Elementnow contains afreezemethod 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
dataStructurecontaining 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,filterandforEachnow acceptthisArglike 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. -
ArrayElementchildrenmethod has been replaced by achildrenproperty on all elements. You may now chain children in conjunction withfilterto 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');
-
BaseElementhas been renamed toElement. -
Embedded Refract support has been removed.
- All elements now contain a
childrenandrecursiveChildrenproperties that return an ArrayElement of the respective children elements. - JSON Serialiser will no longer serialise empty
metaandattributesinto 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
nameproperty was removed. There is no longer a name property in Refract specification.
- Elements now provide a
findRecursivemethod allowing you to recursively find matching elements. - Added function for remove key in an Object element and Array element
- New
isEmptyconvenience 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
minimmodule has changed significantly. List of changes:- Removed
toCompactRefractandfromCompactRefract - Improved the default refract serialization such that when an element in
attributeshas 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
metahas its own metadata or attributes defined then it will now be refracted when callingtoRefractortoCompactRefract. - When loading from refract or compact refract, if an item in
metalooks 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
_attributeElementArrayKeysproperty to use this feature. Note: in the future this feature may go away. -
Allow
loadto be used for plugins where a namespace is not being used -
Add an
elementsproperty to theNamespaceclass 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:
ElementRegistryhas been renamed toNamespace.minimhas only one public method, callednamespace, which creates a newNamespaceinstance.minim.convertToElementis nownamespace.toElementminim.convertFromRefractis nownamespace.fromRefractminim.convertFromCompactRefractis nownamespace.fromCompactRefractminim.*Elementare removed (except fornamespace.BaseElement). These should be accessed vianamespace.getElementClass('name')now.- The
Namespacehas a new methodusewhich loads a plugin namespace and is chainable, e.g.namespace.use(plugin1).use(plugin2). - A
Namespacecan be initialized without any default elements by passing an options object withnoDefaultset tofalseto the constructor. They can be initialized later via theuseDefaultmethod.
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
classmetadata 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 ... ofloops 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
#clonemethod. - Add a
#reducemethod. - Fix a serialization bug when initializing using falsey values
(
null,0,false).
- Allow
#setto take an object for Object Elements - Convert
metato be Minim Object Elements - Convert
attributesto be Minim Object Elements - Sync class and method names with Refract 0.2.0 spec
- Add convenience methods for
metaattributes, such asidorclass - Add finder functions, such as
findByElementandfindByClass - Upgrade to use Uptown 0.4.0
- Organize code