commonform-group-series
Advanced tools
Comparing version 0.2.0 to 0.3.0
{ | ||
"name": "commonform-group-series", | ||
"description": "group series within Common Form form content", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"author": { | ||
@@ -11,2 +11,3 @@ "name": "Kyle E. Mitchell", | ||
"dependencies": { | ||
"commonform-predicate": "^0.2.1", | ||
"immutable": "^3.6.2" | ||
@@ -17,2 +18,3 @@ }, | ||
"check-versions": "0.0.1", | ||
"commonform-validate": "^0.3.2", | ||
"istanbul": "^0.3.5", | ||
@@ -19,0 +21,0 @@ "jscs": "^1.8.1", |
var Immutable = require('immutable'); | ||
var predicate = require('commonform-predicate'); | ||
var hasFormProperty = function(argument) { | ||
return ( | ||
Immutable.Map.isMap(argument) && | ||
argument.has('form') | ||
); | ||
}; | ||
var pushToLastContent = function(list, element) { | ||
@@ -21,6 +15,6 @@ return list.update(list.count() - 1, function(lastGroup) { | ||
.reduce(function(listOfGroups, element, index, content) { | ||
// `element` is a sub-form. | ||
if (hasFormProperty(element)) { | ||
// `element` is an inclusion. | ||
if (predicate.inclusion(element)) { | ||
// `element` is part of the previous series. | ||
if (index > 0 && hasFormProperty(content.get(index - 1))) { | ||
if (index > 0 && predicate.inclusion(content.get(index - 1))) { | ||
return pushToLastContent(listOfGroups, element); | ||
@@ -36,6 +30,6 @@ | ||
// `element` is not a sub-form. | ||
// `element` is not an inclusion. | ||
} else { | ||
// `element` is part of the previous paragraph. | ||
if (index > 0 && !hasFormProperty(content.get(index - 1))) { | ||
if (index > 0 && !predicate.inclusion(content.get(index - 1))) { | ||
return pushToLastContent(listOfGroups, element); | ||
@@ -54,2 +48,2 @@ | ||
module.exports.version = '0.2.0'; | ||
module.exports.version = '0.3.0'; |
2783
2
7
40
+ Addedcommonform-predicate@^0.2.1
+ Addedcommonform-predicate@0.2.1(transitive)