pdfmake 0.3.0-beta.3 → 0.3.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/build/pdfmake.js +2122 -8531
  3. package/build/pdfmake.js.map +1 -1
  4. package/build/pdfmake.min.js +2 -2
  5. package/build/pdfmake.min.js.map +1 -1
  6. package/build/vfs_fonts.js +6 -5
  7. package/js/3rd-party/svg-to-pdfkit/source.js +247 -920
  8. package/js/3rd-party/svg-to-pdfkit.js +0 -3
  9. package/js/DocMeasure.js +6 -139
  10. package/js/DocPreprocessor.js +2 -54
  11. package/js/DocumentContext.js +0 -40
  12. package/js/ElementWriter.js +2 -70
  13. package/js/LayoutBuilder.js +20 -165
  14. package/js/Line.js +6 -25
  15. package/js/OutputDocument.js +4 -13
  16. package/js/OutputDocumentServer.js +0 -6
  17. package/js/PDFDocument.js +1 -46
  18. package/js/PageElementWriter.js +7 -31
  19. package/js/PageSize.js +2 -16
  20. package/js/Printer.js +5 -46
  21. package/js/Renderer.js +11 -98
  22. package/js/SVGMeasure.js +1 -20
  23. package/js/StyleContextStack.js +12 -36
  24. package/js/TableProcessor.js +36 -117
  25. package/js/TextBreaker.js +2 -44
  26. package/js/TextDecorator.js +1 -38
  27. package/js/TextInlines.js +8 -49
  28. package/js/URLResolver.js +0 -13
  29. package/js/base.js +1 -17
  30. package/js/browser-extensions/OutputDocumentBrowser.js +5 -17
  31. package/js/browser-extensions/URLBrowserResolver.js +0 -17
  32. package/js/browser-extensions/fonts/Roboto.js +0 -4
  33. package/js/browser-extensions/index.js +0 -16
  34. package/js/browser-extensions/pdfMake.js +2 -4
  35. package/js/browser-extensions/standard-fonts/Courier.js +0 -4
  36. package/js/browser-extensions/standard-fonts/Helvetica.js +0 -4
  37. package/js/browser-extensions/standard-fonts/Symbol.js +0 -4
  38. package/js/browser-extensions/standard-fonts/Times.js +0 -4
  39. package/js/browser-extensions/standard-fonts/ZapfDingbats.js +0 -4
  40. package/js/columnCalculator.js +6 -18
  41. package/js/helpers/node.js +3 -27
  42. package/js/helpers/tools.js +0 -8
  43. package/js/helpers/variableType.js +4 -9
  44. package/js/index.js +0 -6
  45. package/js/qrEnc.js +126 -215
  46. package/js/tableLayouts.js +1 -28
  47. package/js/virtual-fs.js +3 -19
  48. package/package.json +2 -2
  49. package/src/3rd-party/svg-to-pdfkit/LICENSE +9 -9
@@ -2,13 +2,9 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  var _OutputDocument = _interopRequireDefault(require("../OutputDocument"));
7
-
8
6
  var _fileSaver = require("file-saver");
9
-
10
7
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
8
  /**
13
9
  * @returns {Window}
14
10
  */
@@ -16,14 +12,11 @@ const openWindow = () => {
16
12
  // we have to open the window immediately and store the reference
17
13
  // otherwise popup blockers will stop us
18
14
  let win = window.open('', '_blank');
19
-
20
15
  if (win === null) {
21
16
  throw new Error('Open PDF in new window blocked by browser');
22
17
  }
23
-
24
18
  return win;
25
19
  };
26
-
27
20
  class OutputDocumentBrowser extends _OutputDocument.default {
28
21
  /**
29
22
  * @returns {Promise<Blob>}
@@ -44,12 +37,11 @@ class OutputDocumentBrowser extends _OutputDocument.default {
44
37
  });
45
38
  });
46
39
  }
40
+
47
41
  /**
48
42
  * @param {string} filename
49
43
  * @returns {Promise}
50
44
  */
51
-
52
-
53
45
  download(filename = 'file.pdf') {
54
46
  return new Promise((resolve, reject) => {
55
47
  this.getBlob().then(blob => {
@@ -64,24 +56,23 @@ class OutputDocumentBrowser extends _OutputDocument.default {
64
56
  });
65
57
  });
66
58
  }
59
+
67
60
  /**
68
61
  * @param {Window} win
69
62
  * @returns {Promise}
70
63
  */
71
-
72
-
73
64
  open(win = null) {
74
65
  return new Promise((resolve, reject) => {
75
66
  if (!win) {
76
67
  win = openWindow();
77
68
  }
78
-
79
69
  this.getBlob().then(blob => {
80
70
  try {
81
71
  let urlCreator = window.URL || window.webkitURL;
82
72
  let pdfUrl = urlCreator.createObjectURL(blob);
83
- win.location.href = pdfUrl; //
73
+ win.location.href = pdfUrl;
84
74
 
75
+ //
85
76
  resolve();
86
77
  /* temporarily disabled
87
78
  if (win === window) {
@@ -104,12 +95,11 @@ class OutputDocumentBrowser extends _OutputDocument.default {
104
95
  });
105
96
  });
106
97
  }
98
+
107
99
  /**
108
100
  * @param {Window} win
109
101
  * @returns {Promise}
110
102
  */
111
-
112
-
113
103
  print(win = null) {
114
104
  return new Promise((resolve, reject) => {
115
105
  this.getStream().then(stream => {
@@ -124,8 +114,6 @@ class OutputDocumentBrowser extends _OutputDocument.default {
124
114
  });
125
115
  });
126
116
  }
127
-
128
117
  }
129
-
130
118
  var _default = OutputDocumentBrowser;
131
119
  exports.default = _default;
@@ -2,62 +2,49 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  const fetchUrl = (url, headers = {}) => {
7
6
  return new Promise((resolve, reject) => {
8
7
  const xhr = new XMLHttpRequest();
9
8
  xhr.open('GET', url, true);
10
-
11
9
  for (let headerName in headers) {
12
10
  xhr.setRequestHeader(headerName, headers[headerName]);
13
11
  }
14
-
15
12
  xhr.responseType = 'arraybuffer';
16
-
17
13
  xhr.onreadystatechange = () => {
18
14
  if (xhr.readyState !== 4) {
19
15
  return;
20
16
  }
21
-
22
17
  const ok = xhr.status >= 200 && xhr.status < 300;
23
-
24
18
  if (!ok) {
25
19
  setTimeout(() => {
26
20
  reject(new TypeError(`Failed to fetch (url: "${url}")`));
27
21
  }, 0);
28
22
  }
29
23
  };
30
-
31
24
  xhr.onload = () => {
32
25
  const ok = xhr.status >= 200 && xhr.status < 300;
33
-
34
26
  if (ok) {
35
27
  resolve(xhr.response);
36
28
  }
37
29
  };
38
-
39
30
  xhr.onerror = () => {
40
31
  setTimeout(() => {
41
32
  reject(new TypeError(`Network request failed (url: "${url}")`));
42
33
  }, 0);
43
34
  };
44
-
45
35
  xhr.ontimeout = () => {
46
36
  setTimeout(() => {
47
37
  reject(new TypeError(`Network request failed (url: "${url}")`));
48
38
  }, 0);
49
39
  };
50
-
51
40
  xhr.send();
52
41
  });
53
42
  };
54
-
55
43
  class URLBrowserResolver {
56
44
  constructor(fs) {
57
45
  this.fs = fs;
58
46
  this.resolving = {};
59
47
  }
60
-
61
48
  resolve(url, headers = {}) {
62
49
  if (!this.resolving[url]) {
63
50
  this.resolving[url] = new Promise((resolve, reject) => {
@@ -74,10 +61,8 @@ class URLBrowserResolver {
74
61
  }
75
62
  });
76
63
  }
77
-
78
64
  return this.resolving[url];
79
65
  }
80
-
81
66
  resolved() {
82
67
  return new Promise((resolve, reject) => {
83
68
  Promise.all(Object.values(this.resolving)).then(() => {
@@ -87,8 +72,6 @@ class URLBrowserResolver {
87
72
  });
88
73
  });
89
74
  }
90
-
91
75
  }
92
-
93
76
  var _default = URLBrowserResolver;
94
77
  exports.default = _default;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var fs = require('fs');
4
-
5
4
  var fontContainer = {
6
5
  vfs: {
7
6
  'Roboto-Regular.ttf': {
@@ -30,13 +29,10 @@ var fontContainer = {
30
29
  }
31
30
  }
32
31
  };
33
-
34
32
  var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
35
-
36
33
  if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
37
34
  _global.pdfMake.addFontContainer(fontContainer);
38
35
  }
39
-
40
36
  if (typeof module !== 'undefined') {
41
37
  module.exports = fontContainer;
42
38
  }
@@ -2,19 +2,12 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  var _base = _interopRequireDefault(require("../base"));
7
-
8
6
  var _OutputDocumentBrowser = _interopRequireDefault(require("./OutputDocumentBrowser"));
9
-
10
7
  var _URLBrowserResolver = _interopRequireDefault(require("./URLBrowserResolver"));
11
-
12
8
  var _fs = _interopRequireDefault(require("fs"));
13
-
14
9
  var _configurator = _interopRequireDefault(require("core-js/configurator"));
15
-
16
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
11
  // core-js: Polyfills will be used only if natives completely unavailable.
19
12
  (0, _configurator.default)({
20
13
  useNative: ['Promise']
@@ -27,25 +20,21 @@ let defaultClientFonts = {
27
20
  bolditalics: 'Roboto-MediumItalic.ttf'
28
21
  }
29
22
  };
30
-
31
23
  class pdfmake extends _base.default {
32
24
  constructor() {
33
25
  super();
34
26
  this.urlResolver = new _URLBrowserResolver.default(this.virtualfs);
35
27
  this.fonts = defaultClientFonts;
36
28
  }
37
-
38
29
  addFontContainer(fontContainer) {
39
30
  this.addVirtualFileSystem(fontContainer.vfs);
40
31
  this.addFonts(fontContainer.fonts);
41
32
  }
42
-
43
33
  addVirtualFileSystem(vfs) {
44
34
  for (let key in vfs) {
45
35
  if (vfs.hasOwnProperty(key)) {
46
36
  let data;
47
37
  let encoding;
48
-
49
38
  if (typeof vfs[key] === 'object') {
50
39
  data = vfs[key].data;
51
40
  encoding = vfs[key].encoding || 'base64';
@@ -53,18 +42,13 @@ class pdfmake extends _base.default {
53
42
  data = vfs[key];
54
43
  encoding = 'base64';
55
44
  }
56
-
57
45
  _fs.default.writeFileSync(key, data, encoding);
58
46
  }
59
47
  }
60
48
  }
61
-
62
49
  _transformToDocument(doc) {
63
50
  return new _OutputDocumentBrowser.default(doc);
64
51
  }
65
-
66
52
  }
67
-
68
53
  var _default = new pdfmake();
69
-
70
54
  exports.default = _default;
@@ -4,14 +4,12 @@ const isBrowserSupported = () => {
4
4
  if (typeof window === 'undefined' || typeof window.navigator === 'undefined') {
5
5
  // Enviroment is not browser.
6
6
  return true;
7
- } // Internet Explorer 10 and older is not supported.
8
-
7
+ }
9
8
 
9
+ // Internet Explorer 10 and older is not supported.
10
10
  return window.navigator.userAgent.indexOf("MSIE") === -1;
11
11
  };
12
-
13
12
  if (!isBrowserSupported()) {
14
13
  throw new Error('pdfmake: Internet Explorer 10 and older is not supported. Upgrade to version 11 or use modern browser.');
15
14
  }
16
-
17
15
  module.exports = require('./index').default;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var fs = require('fs');
4
-
5
4
  var fontContainer = {
6
5
  vfs: {
7
6
  'data/Courier.afm': {
@@ -30,13 +29,10 @@ var fontContainer = {
30
29
  }
31
30
  }
32
31
  };
33
-
34
32
  var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
35
-
36
33
  if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
37
34
  _global.pdfMake.addFontContainer(fontContainer);
38
35
  }
39
-
40
36
  if (typeof module !== 'undefined') {
41
37
  module.exports = fontContainer;
42
38
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var fs = require('fs');
4
-
5
4
  var fontContainer = {
6
5
  vfs: {
7
6
  'data/Helvetica.afm': {
@@ -30,13 +29,10 @@ var fontContainer = {
30
29
  }
31
30
  }
32
31
  };
33
-
34
32
  var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
35
-
36
33
  if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
37
34
  _global.pdfMake.addFontContainer(fontContainer);
38
35
  }
39
-
40
36
  if (typeof module !== 'undefined') {
41
37
  module.exports = fontContainer;
42
38
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var fs = require('fs');
4
-
5
4
  var fontContainer = {
6
5
  vfs: {
7
6
  'data/Symbol.afm': {
@@ -15,13 +14,10 @@ var fontContainer = {
15
14
  }
16
15
  }
17
16
  };
18
-
19
17
  var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
20
-
21
18
  if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
22
19
  _global.pdfMake.addFontContainer(fontContainer);
23
20
  }
24
-
25
21
  if (typeof module !== 'undefined') {
26
22
  module.exports = fontContainer;
27
23
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var fs = require('fs');
4
-
5
4
  var fontContainer = {
6
5
  vfs: {
7
6
  'data/Times-Roman.afm': {
@@ -30,13 +29,10 @@ var fontContainer = {
30
29
  }
31
30
  }
32
31
  };
33
-
34
32
  var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
35
-
36
33
  if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
37
34
  _global.pdfMake.addFontContainer(fontContainer);
38
35
  }
39
-
40
36
  if (typeof module !== 'undefined') {
41
37
  module.exports = fontContainer;
42
38
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var fs = require('fs');
4
-
5
4
  var fontContainer = {
6
5
  vfs: {
7
6
  'data/ZapfDingbats.afm': {
@@ -15,13 +14,10 @@ var fontContainer = {
15
14
  }
16
15
  }
17
16
  };
18
-
19
17
  var _global = typeof window === 'object' ? window : typeof global === 'object' ? global : typeof self === 'object' ? self : void 0;
20
-
21
18
  if (typeof _global.pdfMake !== 'undefined' && typeof _global.pdfMake.addFontContainer !== 'undefined') {
22
19
  _global.pdfMake.addFontContainer(fontContainer);
23
20
  }
24
-
25
21
  if (typeof module !== 'undefined') {
26
22
  module.exports = fontContainer;
27
23
  }
@@ -2,9 +2,7 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.default = void 0;
5
-
6
5
  var _variableType = require("./helpers/variableType");
7
-
8
6
  function buildColumnWidths(columns, availableWidth) {
9
7
  let autoColumns = [];
10
8
  let autoMin = 0;
@@ -32,21 +30,19 @@ function buildColumnWidths(columns, availableWidth) {
32
30
  if ((0, _variableType.isString)(col.width) && /\d+%/.test(col.width)) {
33
31
  col.width = parseFloat(col.width) * initial_availableWidth / 100;
34
32
  }
35
-
36
33
  if (col.width < col._minWidth && col.elasticWidth) {
37
34
  col._calcWidth = col._minWidth;
38
35
  } else {
39
36
  col._calcWidth = col.width;
40
37
  }
41
-
42
38
  availableWidth -= col._calcWidth;
43
- }); // http://www.freesoft.org/CIE/RFC/1942/18.htm
39
+ });
40
+
41
+ // http://www.freesoft.org/CIE/RFC/1942/18.htm
44
42
  // http://www.w3.org/TR/CSS2/tables.html#width-layout
45
43
  // http://dev.w3.org/csswg/css3-tables-algorithms/Overview.src.htm
46
-
47
44
  let minW = autoMin + starMaxMin * starColumns.length;
48
45
  let maxW = autoMax + starMaxMax * starColumns.length;
49
-
50
46
  if (minW >= availableWidth) {
51
47
  // case 1 - there's no way to fit all columns within available width
52
48
  // that's actually pretty bad situation with PDF as we have no horizontal scroll
@@ -75,7 +71,6 @@ function buildColumnWidths(columns, availableWidth) {
75
71
  availableWidth -= col._calcWidth;
76
72
  });
77
73
  }
78
-
79
74
  if (starColumns.length > 0) {
80
75
  let starSize = availableWidth / starColumns.length;
81
76
  starColumns.forEach(col => {
@@ -84,16 +79,14 @@ function buildColumnWidths(columns, availableWidth) {
84
79
  }
85
80
  }
86
81
  }
87
-
88
82
  function isAutoColumn(column) {
89
83
  return column.width === 'auto';
90
84
  }
91
-
92
85
  function isStarColumn(column) {
93
86
  return column.width === null || column.width === undefined || column.width === '*' || column.width === 'star';
94
- } //TODO: refactor and reuse in measureTable
95
-
87
+ }
96
88
 
89
+ //TODO: refactor and reuse in measureTable
97
90
  function measureMinMax(columns) {
98
91
  let result = {
99
92
  min: 0,
@@ -104,10 +97,8 @@ function measureMinMax(columns) {
104
97
  max: 0
105
98
  };
106
99
  let starCount = 0;
107
-
108
100
  for (let i = 0, l = columns.length; i < l; i++) {
109
101
  let c = columns[i];
110
-
111
102
  if (isStarColumn(c)) {
112
103
  maxStar.min = Math.max(maxStar.min, c._minWidth);
113
104
  maxStar.max = Math.max(maxStar.max, c._maxWidth);
@@ -120,19 +111,16 @@ function measureMinMax(columns) {
120
111
  result.max += c.width !== undefined && c.width || c._maxWidth;
121
112
  }
122
113
  }
123
-
124
114
  if (starCount) {
125
115
  result.min += starCount * maxStar.min;
126
116
  result.max += starCount * maxStar.max;
127
117
  }
128
-
129
118
  return result;
130
119
  }
120
+
131
121
  /**
132
122
  * Calculates column widths
133
123
  */
134
-
135
-
136
124
  var _default = {
137
125
  buildColumnWidths: buildColumnWidths,
138
126
  measureMinMax: measureMinMax,
@@ -4,83 +4,68 @@ exports.__esModule = true;
4
4
  exports.getNodeId = getNodeId;
5
5
  exports.getNodeMargin = getNodeMargin;
6
6
  exports.stringifyNode = stringifyNode;
7
-
8
7
  var _variableType = require("./variableType");
9
-
10
8
  function fontStringify(key, val) {
11
9
  if (key === 'font') {
12
10
  return 'font';
13
11
  }
14
-
15
12
  return val;
16
13
  }
14
+
17
15
  /**
18
16
  * Convert node to readable string
19
17
  *
20
18
  * @param {object} node
21
19
  * @returns {string}
22
20
  */
23
-
24
-
25
21
  function stringifyNode(node) {
26
22
  return JSON.stringify(node, fontStringify);
27
23
  }
24
+
28
25
  /**
29
26
  * @param {object} node
30
27
  * @returns {?string}
31
28
  */
32
-
33
-
34
29
  function getNodeId(node) {
35
30
  if (node.id) {
36
31
  return node.id;
37
32
  }
38
-
39
33
  if (Array.isArray(node.text)) {
40
34
  for (let n of node.text) {
41
35
  let nodeId = getNodeId(n);
42
-
43
36
  if (nodeId) {
44
37
  return nodeId;
45
38
  }
46
39
  }
47
40
  }
48
-
49
41
  return null;
50
42
  }
43
+
51
44
  /**
52
45
  * @param {object} node
53
46
  * @param {object} styleStack object is instance of PDFDocument
54
47
  * @returns {?Array}
55
48
  */
56
-
57
-
58
49
  function getNodeMargin(node, styleStack) {
59
50
  function processSingleMargins(node, currentMargin) {
60
51
  if (node.marginLeft || node.marginTop || node.marginRight || node.marginBottom) {
61
52
  return [node.marginLeft || currentMargin[0] || 0, node.marginTop || currentMargin[1] || 0, node.marginRight || currentMargin[2] || 0, node.marginBottom || currentMargin[3] || 0];
62
53
  }
63
-
64
54
  return currentMargin;
65
55
  }
66
-
67
56
  function flattenStyleArray(styleArray, styleStack) {
68
57
  let flattenedStyles = {};
69
-
70
58
  for (let i = styleArray.length - 1; i >= 0; i--) {
71
59
  let styleName = styleArray[i];
72
60
  let style = styleStack.styleDictionary[styleName];
73
-
74
61
  for (let key in style) {
75
62
  if (style.hasOwnProperty(key)) {
76
63
  flattenedStyles[key] = style[key];
77
64
  }
78
65
  }
79
66
  }
80
-
81
67
  return flattenedStyles;
82
68
  }
83
-
84
69
  function convertMargin(margin) {
85
70
  if ((0, _variableType.isNumber)(margin)) {
86
71
  margin = [margin, margin, margin, margin];
@@ -89,34 +74,25 @@ function getNodeMargin(node, styleStack) {
89
74
  margin = [margin[0], margin[1], margin[0], margin[1]];
90
75
  }
91
76
  }
92
-
93
77
  return margin;
94
78
  }
95
-
96
79
  let margin = [undefined, undefined, undefined, undefined];
97
-
98
80
  if (node.style) {
99
81
  let styleArray = Array.isArray(node.style) ? node.style : [node.style];
100
82
  let flattenedStyleArray = flattenStyleArray(styleArray, styleStack);
101
-
102
83
  if (flattenedStyleArray) {
103
84
  margin = processSingleMargins(flattenedStyleArray, margin);
104
85
  }
105
-
106
86
  if (flattenedStyleArray.margin) {
107
87
  margin = convertMargin(flattenedStyleArray.margin);
108
88
  }
109
89
  }
110
-
111
90
  margin = processSingleMargins(node, margin);
112
-
113
91
  if (node.margin) {
114
92
  margin = convertMargin(node.margin);
115
93
  }
116
-
117
94
  if (margin[0] === undefined && margin[1] === undefined && margin[2] === undefined && margin[3] === undefined) {
118
95
  return null;
119
96
  }
120
-
121
97
  return margin;
122
98
  }
@@ -3,13 +3,10 @@
3
3
  exports.__esModule = true;
4
4
  exports.offsetVector = offsetVector;
5
5
  exports.pack = pack;
6
-
7
6
  function pack(...args) {
8
7
  let result = {};
9
-
10
8
  for (let i = 0, l = args.length; i < l; i++) {
11
9
  let obj = args[i];
12
-
13
10
  if (obj) {
14
11
  for (let key in obj) {
15
12
  if (obj.hasOwnProperty(key)) {
@@ -18,10 +15,8 @@ function pack(...args) {
18
15
  }
19
16
  }
20
17
  }
21
-
22
18
  return result;
23
19
  }
24
-
25
20
  function offsetVector(vector, x, y) {
26
21
  switch (vector.type) {
27
22
  case 'ellipse':
@@ -29,20 +24,17 @@ function offsetVector(vector, x, y) {
29
24
  vector.x += x;
30
25
  vector.y += y;
31
26
  break;
32
-
33
27
  case 'line':
34
28
  vector.x1 += x;
35
29
  vector.x2 += x;
36
30
  vector.y1 += y;
37
31
  vector.y2 += y;
38
32
  break;
39
-
40
33
  case 'polyline':
41
34
  for (let i = 0, l = vector.points.length; i < l; i++) {
42
35
  vector.points[i].x += x;
43
36
  vector.points[i].y += y;
44
37
  }
45
-
46
38
  break;
47
39
  }
48
40
  }
@@ -6,7 +6,6 @@ exports.isNumber = isNumber;
6
6
  exports.isObject = isObject;
7
7
  exports.isString = isString;
8
8
  exports.isValue = isValue;
9
-
10
9
  /**
11
10
  * @param {any} variable
12
11
  * @returns {boolean}
@@ -14,39 +13,35 @@ exports.isValue = isValue;
14
13
  function isString(variable) {
15
14
  return typeof variable === 'string' || variable instanceof String;
16
15
  }
16
+
17
17
  /**
18
18
  * @param {any} variable
19
19
  * @returns {boolean}
20
20
  */
21
-
22
-
23
21
  function isNumber(variable) {
24
22
  return typeof variable === 'number' || variable instanceof Number;
25
23
  }
24
+
26
25
  /**
27
26
  * @param {any} variable
28
27
  * @returns {boolean}
29
28
  */
30
-
31
-
32
29
  function isObject(variable) {
33
30
  return variable !== null && !Array.isArray(variable) && !isString(variable) && !isNumber(variable) && typeof variable === 'object';
34
31
  }
32
+
35
33
  /**
36
34
  * @param {any} variable
37
35
  * @returns {boolean}
38
36
  */
39
-
40
-
41
37
  function isEmptyObject(variable) {
42
38
  return isObject(variable) && Object.keys(variable).length === 0;
43
39
  }
40
+
44
41
  /**
45
42
  * @param {any} variable
46
43
  * @returns {boolean}
47
44
  */
48
-
49
-
50
45
  function isValue(variable) {
51
46
  return variable !== undefined && variable !== null;
52
47
  }