@amimpact/willy-utils 1.3.8-beta.0 → 1.3.8-beta.1

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.
package/dist/misc.d.ts CHANGED
@@ -3,6 +3,13 @@
3
3
  * @param {string | number} bytes
4
4
  */
5
5
  export declare const bytesToSize: (bytes: number) => string;
6
+ /**
7
+ * Downloaden van een bestand
8
+ *
9
+ * @param {any} data
10
+ * @param {string} fileName
11
+ */
12
+ export declare const downloadFile: (data: any, fileName: string) => void;
6
13
  /**
7
14
  * Flat structure array ombouwen naar een array met children
8
15
  * @param {array} entries
@@ -16,6 +23,14 @@ export declare const getNestedSet: (entries: any[] | undefined, level: number |
16
23
  * @param {string} content - html
17
24
  */
18
25
  export declare const getUrlsFromString: (content: string) => RegExpMatchArray | null;
26
+ /**
27
+ * Bekijken of een waarde een object is
28
+ * https://github.com/reduxjs/redux/blob/master/src/utils/isPlainObject.ts
29
+ *
30
+ * @param {any} value - Waarde welke je wilt checken of het een object is
31
+ * @returns {boolean}
32
+ */
33
+ export declare const isPlainObject: (value: any) => boolean;
19
34
  /**
20
35
  * Wrap een element in een nieuw element
21
36
  *
@@ -23,10 +38,3 @@ export declare const getUrlsFromString: (content: string) => RegExpMatchArray |
23
38
  * @param {HTMLElement} wrapper
24
39
  */
25
40
  export declare const wrap: (el: HTMLElement, wrapper: HTMLElement) => void;
26
- /**
27
- * Downloaden van een bestand
28
- *
29
- * @param {any} data
30
- * @param {string} fileName
31
- */
32
- export declare const downloadFile: (data: any, fileName: string) => void;
package/dist/misc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.downloadFile = exports.wrap = exports.getUrlsFromString = exports.getNestedSet = exports.bytesToSize = void 0;
3
+ exports.wrap = exports.isPlainObject = exports.getUrlsFromString = exports.getNestedSet = exports.downloadFile = exports.bytesToSize = void 0;
4
4
  /**
5
5
  * Toon mooier bestandsformaat
6
6
  * @param {string | number} bytes
@@ -15,6 +15,25 @@ exports.bytesToSize = function (bytes) {
15
15
  var i = Math.floor(Math.log(bytes) / Math.log(1024));
16
16
  return Math.round(bytes / Math.pow(1024, i)) + ' ' + sizes[i];
17
17
  };
18
+ /**
19
+ * Downloaden van een bestand
20
+ *
21
+ * @param {any} data
22
+ * @param {string} fileName
23
+ */
24
+ exports.downloadFile = function (data, fileName) {
25
+ if (typeof window.navigator.msSaveBlob !== 'undefined') {
26
+ window.navigator.msSaveOrOpenBlob(new Blob([data]), fileName);
27
+ }
28
+ else {
29
+ var fileURL = window.URL.createObjectURL(new Blob([data]));
30
+ var fileLink = document.createElement('a');
31
+ fileLink.href = fileURL;
32
+ fileLink.setAttribute('download', fileName);
33
+ document.body.appendChild(fileLink);
34
+ fileLink.click();
35
+ }
36
+ };
18
37
  /**
19
38
  * Flat structure array ombouwen naar een array met children
20
39
  * @param {array} entries
@@ -48,6 +67,23 @@ exports.getUrlsFromString = function (content) {
48
67
  var m = content.match(regex);
49
68
  return m || null;
50
69
  };
70
+ /**
71
+ * Bekijken of een waarde een object is
72
+ * https://github.com/reduxjs/redux/blob/master/src/utils/isPlainObject.ts
73
+ *
74
+ * @param {any} value - Waarde welke je wilt checken of het een object is
75
+ * @returns {boolean}
76
+ */
77
+ exports.isPlainObject = function (value) {
78
+ if (typeof value !== 'object' || value === null) {
79
+ return false;
80
+ }
81
+ var proto = value;
82
+ while (Object.getPrototypeOf(proto) !== null) {
83
+ proto = Object.getPrototypeOf(proto);
84
+ }
85
+ return Object.getPrototypeOf(value) === proto;
86
+ };
51
87
  /**
52
88
  * Wrap een element in een nieuw element
53
89
  *
@@ -60,22 +96,3 @@ exports.wrap = function (el, wrapper) {
60
96
  wrapper.appendChild(el);
61
97
  }
62
98
  };
63
- /**
64
- * Downloaden van een bestand
65
- *
66
- * @param {any} data
67
- * @param {string} fileName
68
- */
69
- exports.downloadFile = function (data, fileName) {
70
- if (typeof window.navigator.msSaveBlob !== 'undefined') {
71
- window.navigator.msSaveOrOpenBlob(new Blob([data]), fileName);
72
- }
73
- else {
74
- var fileURL = window.URL.createObjectURL(new Blob([data]));
75
- var fileLink = document.createElement('a');
76
- fileLink.href = fileURL;
77
- fileLink.setAttribute('download', fileName);
78
- document.body.appendChild(fileLink);
79
- fileLink.click();
80
- }
81
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amimpact/willy-utils",
3
- "version": "1.3.8-beta.0",
3
+ "version": "1.3.8-beta.1",
4
4
  "description": "Javascript utils",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",