Skip to content

Commit 64da9e2

Browse files
Fixed value reader performance bug.
1 parent d13a2e9 commit 64da9e2

File tree

10 files changed

+8406
-213
lines changed

10 files changed

+8406
-213
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#### Version 5.6.2
2+
* Fixed performance bug in the value reader.
13
#### Version 5.6.0
24
* Added `placeAssistantsAboveChildren` and `placeAdvisersAboveChildren` properties to `primitives.orgdiagram.Config` & `primitives.orgdiagram.ItemConfig`.
35
* Added `levelOffset` property to `primitives.orgdiagram.ItemConfig`.

min/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "basicprimitives",
3-
"version": "5.6.0",
3+
"version": "5.6.2",
44
"description": "Basic Primitives Diagrams for JavaScript - data visualization components library that implements organizational chart and multi-parent dependency diagrams, contains implementations of JavaScript Controls and PDF rendering plugins.",
55
"main": "primitives.latest.js",
66
"scripts": {

min/primitives.latest.js

Lines changed: 44 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @preserve Basic Primitives Diagrams v5.6.0
2+
* @preserve Basic Primitives Diagrams v5.6.2
33
* Copyright (c) 2013 - 2019 Basic Primitives Inc
44
*
55
* Non-commercial - Free
@@ -35,7 +35,7 @@
3535

3636
var primitives = {
3737
common: {
38-
version: "5.6.0"
38+
version: "5.6.2"
3939
},
4040
orgdiagram: {},
4141
famdiagram: {},
@@ -7017,38 +7017,39 @@ primitives.common.FunctionReader.prototype.read = function (target, source, path
70177017

70187018
/* /OptionsReaders/ObjectReader.js*/
70197019
primitives.common.ObjectReader = function (dataTemplate, isNullable, defaultValue) {
7020-
this.dataTemplate = dataTemplate;
7021-
this.isNullable = isNullable;
7022-
this.defaultValue = defaultValue;
7020+
this.dataTemplate = dataTemplate;
7021+
this.isNullable = isNullable;
7022+
this.defaultValue = defaultValue;
70237023
};
70247024

70257025
primitives.common.ObjectReader.prototype.read = function (target, source, path, context) {
7026-
var result = null,
7027-
property,
7028-
propertyDataTemplate;
7026+
var result = null,
7027+
isTargetObject = primitives.common.isObject(target),
7028+
property,
7029+
propertyDataTemplate;
70297030

7030-
if(!source) {
7031-
source = this.isNullable ? null : this.defaultValue;
7032-
}
7031+
if (!source) {
7032+
source = this.isNullable ? null : this.defaultValue;
7033+
}
70337034

7034-
if(primitives.common.isObject(source)) {
7035-
result = {};
7035+
if (primitives.common.isObject(source)) {
7036+
result = {};
70367037

7037-
for (property in this.dataTemplate) {
7038-
if (this.dataTemplate.hasOwnProperty(property)) {
7039-
propertyDataTemplate = this.dataTemplate[property];
7038+
for (property in this.dataTemplate) {
7039+
if (this.dataTemplate.hasOwnProperty(property)) {
7040+
propertyDataTemplate = this.dataTemplate[property];
70407041

7041-
result[property] = propertyDataTemplate.read(primitives.common.isObject(target) ? target[property] : null, source[property], path + "-" + property, context);
7042-
}
7043-
}
7044-
} else {
7045-
result = source;
7042+
result[property] = propertyDataTemplate.read(isTargetObject ? target[property] : null, source[property], path + "-" + property, context);
7043+
}
7044+
}
7045+
} else {
7046+
result = source;
70467047

7047-
if (target !== source) {
7048-
context.isChanged = true;
7049-
}
7050-
}
7051-
return result;
7048+
if (target !== source) {
7049+
context.isChanged = true;
7050+
}
7051+
}
7052+
return result;
70527053
};
70537054

70547055
/* /OptionsReaders/ValueReader.js*/
@@ -7067,21 +7068,24 @@ primitives.common.ValueReader = function (acceptedTypes, isNullable, defaultValu
70677068
};
70687069

70697070
primitives.common.ValueReader.prototype.stringify = function (target) {
7070-
var processed = [];
7071-
var result = JSON.stringify(target, function (key, value) {
7072-
if(key[0] === '_') {
7073-
return null;
7074-
}
7075-
if (value !== null && typeof value == "object") {
7076-
if (processed.indexOf(value) == -1) {
7077-
processed.push(value);
7078-
return value;
7071+
if (this.hash["object"] == true) {
7072+
var processed = [];
7073+
var result = JSON.stringify(target, function (key, value) {
7074+
if (key[0] === '_') {
7075+
return null;
70797076
}
7080-
return null;
7081-
}
7082-
return value;
7083-
});
7084-
return result;
7077+
if (value !== null && typeof value == "object") {
7078+
if (processed.indexOf(value) == -1) {
7079+
processed.push(value);
7080+
return value;
7081+
}
7082+
return null;
7083+
}
7084+
return value;
7085+
});
7086+
return result;
7087+
}
7088+
return target;
70857089
}
70867090

70877091
primitives.common.ValueReader.prototype.read = function (target, source, path, context) {

min/primitives.min.js

Lines changed: 133 additions & 132 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/data/xldataset.js

Lines changed: 7746 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)