Comparing version 0.23.4 to 0.23.5
# Minim Changelog | ||
## 0.23.5 (2019-07-02) | ||
This release brings some performance improvements, namely to serialising with | ||
the JSON serialisers. | ||
## 0.23.4 (2019-06-11) | ||
@@ -4,0 +9,0 @@ |
@@ -130,9 +130,3 @@ const negate = require('lodash/negate'); | ||
hasKey(value) { | ||
for (let i = 0; i < this.content.length; i += 1) { | ||
if (this.content[i].key.equals(value)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
return this.content.some(member => member.key.equals(value)); | ||
} | ||
@@ -139,0 +133,0 @@ |
@@ -365,34 +365,18 @@ const JSONSerialiser = require('./JSONSerialiser'); | ||
if (item.element === 'array') { | ||
// This is a plain array, but maybe it contains elements with | ||
// additional information? Let's see! | ||
const values = []; | ||
return item.map((subItem) => { | ||
if (this.shouldRefract(subItem) || key === 'default') { | ||
return this.serialise(subItem); | ||
} | ||
for (let index = 0; index < item.length; index += 1) { | ||
const subItem = item.get(index); | ||
if (this.shouldRefract(subItem) || key === 'default') { | ||
values.push(this.serialise(subItem)); | ||
} else if (subItem.element === 'array' || subItem.element === 'object' || subItem.element === 'enum') { | ||
if (subItem.element === 'array' || subItem.element === 'object' || subItem.element === 'enum') { | ||
// items for array or enum inside array are always serialised | ||
const value = subItem.children.map(subSubItem => this.serialise(subSubItem)); | ||
values.push(value); | ||
} else { | ||
values.push(subItem.toValue()); | ||
return subItem.children.map(subSubItem => this.serialise(subSubItem)); | ||
} | ||
} | ||
return values; | ||
return subItem.toValue(); | ||
}); | ||
} | ||
if (item.element === 'object') { | ||
// This is an object, so we need to check if it's members contain | ||
// additional information | ||
const values = []; | ||
const content = item.content || []; | ||
for (let index = 0; index < content.length; index += 1) { | ||
values.push(this.serialise(content[index])); | ||
} | ||
return values; | ||
return (item.content || []).map(this.serialise, this); | ||
} | ||
@@ -410,7 +394,6 @@ | ||
obj.keys().forEach((key) => { | ||
const value = obj.get(key); | ||
obj.forEach((value, key) => { | ||
if (value) { | ||
result[key] = this.convertKeyToRefract(key, value); | ||
const keyValue = key.toValue(); | ||
result[keyValue] = this.convertKeyToRefract(keyValue, value); | ||
} | ||
@@ -417,0 +400,0 @@ }); |
@@ -132,7 +132,5 @@ /** | ||
obj.keys().forEach((key) => { | ||
const value = obj.get(key); | ||
obj.forEach((value, key) => { | ||
if (value) { | ||
result[key] = this.serialise(value); | ||
result[key.toValue()] = this.serialise(value); | ||
} | ||
@@ -139,0 +137,0 @@ }); |
{ | ||
"name": "minim", | ||
"version": "0.23.4", | ||
"version": "0.23.5", | ||
"description": "A library for interacting with JSON through Refract elements", | ||
@@ -5,0 +5,0 @@ "main": "lib/minim.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
615311
8510