New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

commonform-flatten

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commonform-flatten - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

84

index.js

@@ -1,51 +0,43 @@

var clone = require('clone');
var resolve = require('commonform-resolve');
var clone = require('clone')
var resolve = require('commonform-resolve')
var flatten = function(form, list, depth) {
return form.content.reduce(function(list, element) {
var newContainer;
if (element.hasOwnProperty('form')) {
newContainer = {
depth: depth + 1,
content: [],
numbering: element.numbering
};
if (element.hasOwnProperty('heading')) {
newContainer.heading = element.heading;
}
if (element.form.hasOwnProperty('conspicuous')) {
newContainer.conspicuous = element.form.conspicuous;
}
list.push(newContainer);
return flatten(element.form, list, depth + 1);
} else {
var listLength = list.length;
var last = list[listLength - 1];
if (
!last ||
!last.hasOwnProperty('depth') ||
last.depth !== depth
) {
newContainer = {
depth: depth,
content: []
};
if (form.hasOwnProperty('conspicuous')) {
newContainer.conspicuous = form.conspicuous;
}
newContainer.content.push(element);
list.push(newContainer);
} else {
list[listLength - 1].content.push(element);
}
return list;
}
}, list);
};
return form.content
.reduce(
function(list, element) {
var newContainer
if (element.hasOwnProperty('form')) {
newContainer = {
depth: ( depth + 1 ),
content: [ ],
numbering: element.numbering }
if (element.hasOwnProperty('heading')) {
newContainer.heading = element.heading }
if (element.form.hasOwnProperty('conspicuous')) {
newContainer.conspicuous = element.form.conspicuous }
list.push(newContainer)
return flatten(element.form, list, depth + 1) }
else {
var listLength = list.length
var last = list[listLength - 1]
var startNew = (
!last ||
!last.hasOwnProperty('depth') ||
last.depth !== depth )
if (startNew) {
newContainer = {
depth: depth,
content: [ ] }
if (form.hasOwnProperty('conspicuous')) {
newContainer.conspicuous = form.conspicuous }
newContainer.content.push(element)
list.push(newContainer) }
else {
list[listLength - 1].content.push(element) }
return list } },
list) }
module.exports = function(form, values) {
if (!values) {
values = {};
}
return flatten(resolve(clone(form), values), [], 1);
};
values = { } }
return flatten(resolve(clone(form), values), [ ], 1) }
{
"name": "commonform-flatten",
"description": "flatten Common Forms",
"version": "0.5.2",
"version": "0.5.3",
"author": "Kyle E. Mitchell <kyle@kemitchell.com> (http://kemitchell.com)",

@@ -6,0 +6,0 @@ "bugs": "https://github.com/commonform/commonform-flatten/issues",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc