@amimpact/willy-utils 1.5.0 → 1.5.1-beta.0
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 +7 -0
- package/dist/misc.js +22 -1
- package/package.json +1 -1
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
|
+
* Hex kleurcode converten naar rgba
|
|
8
|
+
*
|
|
9
|
+
* @param {string} hexCode
|
|
10
|
+
* @param {number} opacity
|
|
11
|
+
*/
|
|
12
|
+
export declare const convertHexToRGBA: (hexCode: string, opacity?: number) => string;
|
|
6
13
|
/**
|
|
7
14
|
* Downloaden van een bestand
|
|
8
15
|
*
|
package/dist/misc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrap = exports.isPlainObject = exports.getUrlsFromString = exports.getNestedSet = exports.downloadFile = exports.bytesToSize = void 0;
|
|
3
|
+
exports.wrap = exports.isPlainObject = exports.getUrlsFromString = exports.getNestedSet = exports.downloadFile = exports.convertHexToRGBA = exports.bytesToSize = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Toon mooier bestandsformaat
|
|
6
6
|
* @param {string | number} bytes
|
|
@@ -15,6 +15,27 @@ 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
|
+
* Hex kleurcode converten naar rgba
|
|
20
|
+
*
|
|
21
|
+
* @param {string} hexCode
|
|
22
|
+
* @param {number} opacity
|
|
23
|
+
*/
|
|
24
|
+
exports.convertHexToRGBA = function (hexCode, opacity) {
|
|
25
|
+
if (opacity === void 0) { opacity = 1; }
|
|
26
|
+
var hex = hexCode.replace('#', '');
|
|
27
|
+
if (hex.length === 3) {
|
|
28
|
+
hex = "" + hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
29
|
+
}
|
|
30
|
+
var r = parseInt(hex.substring(0, 2), 16);
|
|
31
|
+
var g = parseInt(hex.substring(2, 4), 16);
|
|
32
|
+
var b = parseInt(hex.substring(4, 6), 16);
|
|
33
|
+
/* Backward compatibility for whole number based opacity values. */
|
|
34
|
+
if (opacity > 1 && opacity <= 100) {
|
|
35
|
+
opacity = opacity / 100;
|
|
36
|
+
}
|
|
37
|
+
return "rgba(" + r + "," + g + "," + b + "," + opacity + ")";
|
|
38
|
+
};
|
|
18
39
|
/**
|
|
19
40
|
* Downloaden van een bestand
|
|
20
41
|
*
|