@symbo.ls/utils 2.11.373 → 2.11.394
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/cjs/codify.js +30 -6
- package/dist/cjs/index.js +44 -6
- package/dist/cjs/load.js +12 -0
- package/dist/cjs/scaling.js +32 -8
- package/package.json +2 -2
- package/src/index.js +1 -0
- package/src/load.js +13 -0
package/dist/cjs/codify.js
CHANGED
|
@@ -293,6 +293,7 @@ var require_array = __commonJS({
|
|
|
293
293
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
294
294
|
var array_exports = {};
|
|
295
295
|
__export2(array_exports, {
|
|
296
|
+
addItemAfterEveryElement: () => addItemAfterEveryElement,
|
|
296
297
|
arrayContainsOtherArray: () => arrayContainsOtherArray,
|
|
297
298
|
createNestedObject: () => createNestedObject,
|
|
298
299
|
cutArrayAfterValue: () => cutArrayAfterValue,
|
|
@@ -304,6 +305,7 @@ var require_array = __commonJS({
|
|
|
304
305
|
removeFromArray: () => removeFromArray,
|
|
305
306
|
removeValueFromArray: () => removeValueFromArray,
|
|
306
307
|
removeValueFromArrayAll: () => removeValueFromArrayAll,
|
|
308
|
+
reorderArrayByValues: () => reorderArrayByValues,
|
|
307
309
|
swapItemsInArray: () => swapItemsInArray
|
|
308
310
|
});
|
|
309
311
|
module2.exports = __toCommonJS2(array_exports);
|
|
@@ -388,6 +390,27 @@ var require_array = __commonJS({
|
|
|
388
390
|
var removeValueFromArrayAll = (arr, value) => {
|
|
389
391
|
return arr.filter((item) => item !== value);
|
|
390
392
|
};
|
|
393
|
+
var addItemAfterEveryElement = (array, item) => {
|
|
394
|
+
const result = [];
|
|
395
|
+
for (let i = 0; i < array.length; i++) {
|
|
396
|
+
result.push(array[i]);
|
|
397
|
+
if (i < array.length - 1) {
|
|
398
|
+
result.push(item);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
};
|
|
403
|
+
var reorderArrayByValues = (array, valueToMove, insertBeforeValue) => {
|
|
404
|
+
const newArray = [...array];
|
|
405
|
+
const indexToMove = newArray.indexOf(valueToMove);
|
|
406
|
+
const indexToInsertBefore = newArray.indexOf(insertBeforeValue);
|
|
407
|
+
if (indexToMove !== -1 && indexToInsertBefore !== -1) {
|
|
408
|
+
const removedItem = newArray.splice(indexToMove, 1)[0];
|
|
409
|
+
const insertIndex = indexToInsertBefore < indexToMove ? indexToInsertBefore : indexToInsertBefore + 1;
|
|
410
|
+
newArray.splice(insertIndex, 0, removedItem);
|
|
411
|
+
}
|
|
412
|
+
return newArray;
|
|
413
|
+
};
|
|
391
414
|
}
|
|
392
415
|
});
|
|
393
416
|
|
|
@@ -664,7 +687,7 @@ var require_object = __commonJS({
|
|
|
664
687
|
}
|
|
665
688
|
return stringified;
|
|
666
689
|
};
|
|
667
|
-
var objectToString = (obj, indent = 0) => {
|
|
690
|
+
var objectToString = (obj = {}, indent = 0) => {
|
|
668
691
|
const spaces = " ".repeat(indent);
|
|
669
692
|
let str = "{\n";
|
|
670
693
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -731,7 +754,7 @@ var require_object = __commonJS({
|
|
|
731
754
|
continue;
|
|
732
755
|
const objProp = obj[prop];
|
|
733
756
|
if ((0, import_types.isString)(objProp)) {
|
|
734
|
-
if ((objProp.includes("=>") || objProp.startsWith("function") || objProp.startsWith("(")) && !objProp.startsWith("{") && !objProp.startsWith("[")) {
|
|
757
|
+
if ((objProp.includes("(){") || objProp.includes("() {") || objProp.includes("=>") || objProp.startsWith("()") || objProp.startsWith("async") || objProp.startsWith("function") || objProp.startsWith("(")) && !objProp.startsWith("{") && !objProp.startsWith("[")) {
|
|
735
758
|
try {
|
|
736
759
|
const evalProp = import_globals.window.eval(`(${objProp})`);
|
|
737
760
|
destringified[prop] = evalProp;
|
|
@@ -1119,20 +1142,21 @@ var require_cookie = __commonJS({
|
|
|
1119
1142
|
});
|
|
1120
1143
|
module2.exports = __toCommonJS2(cookie_exports);
|
|
1121
1144
|
var import_types = require_types();
|
|
1145
|
+
var import_utils3 = require_cjs();
|
|
1122
1146
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
1123
1147
|
var setCookie = (cname, cvalue, exdays = 365) => {
|
|
1124
|
-
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
1148
|
+
if ((0, import_types.isUndefined)(import_utils3.document) || (0, import_types.isUndefined)(import_utils3.document.cookie))
|
|
1125
1149
|
return;
|
|
1126
1150
|
const d = /* @__PURE__ */ new Date();
|
|
1127
1151
|
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
1128
1152
|
const expires = `expires=${d.toUTCString()}`;
|
|
1129
|
-
document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
1153
|
+
import_utils3.document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
1130
1154
|
};
|
|
1131
1155
|
var getCookie = (cname) => {
|
|
1132
|
-
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
1156
|
+
if ((0, import_types.isUndefined)(import_utils3.document) || (0, import_types.isUndefined)(import_utils3.document.cookie))
|
|
1133
1157
|
return;
|
|
1134
1158
|
const name = `${cname}=`;
|
|
1135
|
-
const decodedCookie = decodeURIComponent(document.cookie);
|
|
1159
|
+
const decodedCookie = decodeURIComponent(import_utils3.document.cookie);
|
|
1136
1160
|
const ca = decodedCookie.split(";");
|
|
1137
1161
|
for (let i = 0; i < ca.length; i++) {
|
|
1138
1162
|
let c = ca[i];
|
package/dist/cjs/index.js
CHANGED
|
@@ -293,6 +293,7 @@ var require_array = __commonJS({
|
|
|
293
293
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
294
294
|
var array_exports = {};
|
|
295
295
|
__export2(array_exports, {
|
|
296
|
+
addItemAfterEveryElement: () => addItemAfterEveryElement,
|
|
296
297
|
arrayContainsOtherArray: () => arrayContainsOtherArray,
|
|
297
298
|
createNestedObject: () => createNestedObject,
|
|
298
299
|
cutArrayAfterValue: () => cutArrayAfterValue,
|
|
@@ -304,6 +305,7 @@ var require_array = __commonJS({
|
|
|
304
305
|
removeFromArray: () => removeFromArray,
|
|
305
306
|
removeValueFromArray: () => removeValueFromArray,
|
|
306
307
|
removeValueFromArrayAll: () => removeValueFromArrayAll,
|
|
308
|
+
reorderArrayByValues: () => reorderArrayByValues,
|
|
307
309
|
swapItemsInArray: () => swapItemsInArray
|
|
308
310
|
});
|
|
309
311
|
module2.exports = __toCommonJS2(array_exports);
|
|
@@ -388,6 +390,27 @@ var require_array = __commonJS({
|
|
|
388
390
|
var removeValueFromArrayAll = (arr, value) => {
|
|
389
391
|
return arr.filter((item) => item !== value);
|
|
390
392
|
};
|
|
393
|
+
var addItemAfterEveryElement = (array, item) => {
|
|
394
|
+
const result = [];
|
|
395
|
+
for (let i = 0; i < array.length; i++) {
|
|
396
|
+
result.push(array[i]);
|
|
397
|
+
if (i < array.length - 1) {
|
|
398
|
+
result.push(item);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
};
|
|
403
|
+
var reorderArrayByValues = (array, valueToMove, insertBeforeValue) => {
|
|
404
|
+
const newArray = [...array];
|
|
405
|
+
const indexToMove = newArray.indexOf(valueToMove);
|
|
406
|
+
const indexToInsertBefore = newArray.indexOf(insertBeforeValue);
|
|
407
|
+
if (indexToMove !== -1 && indexToInsertBefore !== -1) {
|
|
408
|
+
const removedItem = newArray.splice(indexToMove, 1)[0];
|
|
409
|
+
const insertIndex = indexToInsertBefore < indexToMove ? indexToInsertBefore : indexToInsertBefore + 1;
|
|
410
|
+
newArray.splice(insertIndex, 0, removedItem);
|
|
411
|
+
}
|
|
412
|
+
return newArray;
|
|
413
|
+
};
|
|
391
414
|
}
|
|
392
415
|
});
|
|
393
416
|
|
|
@@ -664,7 +687,7 @@ var require_object = __commonJS({
|
|
|
664
687
|
}
|
|
665
688
|
return stringified;
|
|
666
689
|
};
|
|
667
|
-
var objectToString = (obj, indent = 0) => {
|
|
690
|
+
var objectToString = (obj = {}, indent = 0) => {
|
|
668
691
|
const spaces = " ".repeat(indent);
|
|
669
692
|
let str = "{\n";
|
|
670
693
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -731,7 +754,7 @@ var require_object = __commonJS({
|
|
|
731
754
|
continue;
|
|
732
755
|
const objProp = obj[prop];
|
|
733
756
|
if ((0, import_types.isString)(objProp)) {
|
|
734
|
-
if ((objProp.includes("=>") || objProp.startsWith("function") || objProp.startsWith("(")) && !objProp.startsWith("{") && !objProp.startsWith("[")) {
|
|
757
|
+
if ((objProp.includes("(){") || objProp.includes("() {") || objProp.includes("=>") || objProp.startsWith("()") || objProp.startsWith("async") || objProp.startsWith("function") || objProp.startsWith("(")) && !objProp.startsWith("{") && !objProp.startsWith("[")) {
|
|
735
758
|
try {
|
|
736
759
|
const evalProp = import_globals.window.eval(`(${objProp})`);
|
|
737
760
|
destringified[prop] = evalProp;
|
|
@@ -1119,20 +1142,21 @@ var require_cookie = __commonJS({
|
|
|
1119
1142
|
});
|
|
1120
1143
|
module2.exports = __toCommonJS2(cookie_exports);
|
|
1121
1144
|
var import_types = require_types();
|
|
1145
|
+
var import_utils3 = require_cjs();
|
|
1122
1146
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
1123
1147
|
var setCookie = (cname, cvalue, exdays = 365) => {
|
|
1124
|
-
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
1148
|
+
if ((0, import_types.isUndefined)(import_utils3.document) || (0, import_types.isUndefined)(import_utils3.document.cookie))
|
|
1125
1149
|
return;
|
|
1126
1150
|
const d = /* @__PURE__ */ new Date();
|
|
1127
1151
|
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
1128
1152
|
const expires = `expires=${d.toUTCString()}`;
|
|
1129
|
-
document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
1153
|
+
import_utils3.document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
1130
1154
|
};
|
|
1131
1155
|
var getCookie = (cname) => {
|
|
1132
|
-
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
1156
|
+
if ((0, import_types.isUndefined)(import_utils3.document) || (0, import_types.isUndefined)(import_utils3.document.cookie))
|
|
1133
1157
|
return;
|
|
1134
1158
|
const name = `${cname}=`;
|
|
1135
|
-
const decodedCookie = decodeURIComponent(document.cookie);
|
|
1159
|
+
const decodedCookie = decodeURIComponent(import_utils3.document.cookie);
|
|
1136
1160
|
const ca = decodedCookie.split(";");
|
|
1137
1161
|
for (let i = 0; i < ca.length; i++) {
|
|
1138
1162
|
let c = ca[i];
|
|
@@ -1358,6 +1382,7 @@ __export(src_exports, {
|
|
|
1358
1382
|
findClosestNumber: () => findClosestNumber,
|
|
1359
1383
|
findClosestNumberInFactory: () => findClosestNumberInFactory,
|
|
1360
1384
|
formatDate: () => formatDate,
|
|
1385
|
+
loadJavascript: () => loadJavascript,
|
|
1361
1386
|
loadJavascriptFile: () => loadJavascriptFile,
|
|
1362
1387
|
removeChars: () => removeChars,
|
|
1363
1388
|
toCamelCase: () => toCamelCase,
|
|
@@ -1439,6 +1464,17 @@ var loadJavascriptFile = (FILE_URL, async = true, doc = document, type = "text/j
|
|
|
1439
1464
|
}
|
|
1440
1465
|
});
|
|
1441
1466
|
};
|
|
1467
|
+
var loadJavascript = (body, async = true, doc = document, type = "text/javascript") => {
|
|
1468
|
+
try {
|
|
1469
|
+
const scriptEle = doc.createElement("script");
|
|
1470
|
+
scriptEle.type = type;
|
|
1471
|
+
scriptEle.async = async;
|
|
1472
|
+
scriptEle.innerHTML = body;
|
|
1473
|
+
doc.body.appendChild(scriptEle);
|
|
1474
|
+
} catch (error) {
|
|
1475
|
+
console.warn(error);
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1442
1478
|
|
|
1443
1479
|
// src/index.js
|
|
1444
1480
|
var copyStringToClipboard = (str) => {
|
|
@@ -1467,6 +1503,8 @@ var toTitleCase = (str) => str && str.replace(
|
|
|
1467
1503
|
);
|
|
1468
1504
|
var toDashCase = (val) => val.replace(/[^a-zA-Z0-9]/g, " ").trim().toLowerCase().replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
1469
1505
|
var toDescriptionCase = (str = "") => {
|
|
1506
|
+
if (typeof str !== "string")
|
|
1507
|
+
return;
|
|
1470
1508
|
const result = str.replace(/([A-Z])/g, " $1");
|
|
1471
1509
|
return result.charAt(0).toUpperCase() + result.slice(1);
|
|
1472
1510
|
};
|
package/dist/cjs/load.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/load.js
|
|
21
21
|
var load_exports = {};
|
|
22
22
|
__export(load_exports, {
|
|
23
|
+
loadJavascript: () => loadJavascript,
|
|
23
24
|
loadJavascriptFile: () => loadJavascriptFile
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(load_exports);
|
|
@@ -47,3 +48,14 @@ var loadJavascriptFile = (FILE_URL, async = true, doc = document, type = "text/j
|
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
50
|
};
|
|
51
|
+
var loadJavascript = (body, async = true, doc = document, type = "text/javascript") => {
|
|
52
|
+
try {
|
|
53
|
+
const scriptEle = doc.createElement("script");
|
|
54
|
+
scriptEle.type = type;
|
|
55
|
+
scriptEle.async = async;
|
|
56
|
+
scriptEle.innerHTML = body;
|
|
57
|
+
doc.body.appendChild(scriptEle);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.warn(error);
|
|
60
|
+
}
|
|
61
|
+
};
|
package/dist/cjs/scaling.js
CHANGED
|
@@ -130,7 +130,7 @@ var require_globals = __commonJS({
|
|
|
130
130
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
131
131
|
var globals_exports = {};
|
|
132
132
|
__export2(globals_exports, {
|
|
133
|
-
document: () =>
|
|
133
|
+
document: () => document,
|
|
134
134
|
global: () => global,
|
|
135
135
|
self: () => self,
|
|
136
136
|
window: () => window
|
|
@@ -139,7 +139,7 @@ var require_globals = __commonJS({
|
|
|
139
139
|
var global = globalThis;
|
|
140
140
|
var self = globalThis;
|
|
141
141
|
var window = globalThis;
|
|
142
|
-
var
|
|
142
|
+
var document = window.document;
|
|
143
143
|
}
|
|
144
144
|
});
|
|
145
145
|
|
|
@@ -293,6 +293,7 @@ var require_array = __commonJS({
|
|
|
293
293
|
var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
|
|
294
294
|
var array_exports = {};
|
|
295
295
|
__export2(array_exports, {
|
|
296
|
+
addItemAfterEveryElement: () => addItemAfterEveryElement,
|
|
296
297
|
arrayContainsOtherArray: () => arrayContainsOtherArray,
|
|
297
298
|
createNestedObject: () => createNestedObject,
|
|
298
299
|
cutArrayAfterValue: () => cutArrayAfterValue,
|
|
@@ -304,6 +305,7 @@ var require_array = __commonJS({
|
|
|
304
305
|
removeFromArray: () => removeFromArray,
|
|
305
306
|
removeValueFromArray: () => removeValueFromArray,
|
|
306
307
|
removeValueFromArrayAll: () => removeValueFromArrayAll,
|
|
308
|
+
reorderArrayByValues: () => reorderArrayByValues,
|
|
307
309
|
swapItemsInArray: () => swapItemsInArray
|
|
308
310
|
});
|
|
309
311
|
module2.exports = __toCommonJS2(array_exports);
|
|
@@ -388,6 +390,27 @@ var require_array = __commonJS({
|
|
|
388
390
|
var removeValueFromArrayAll = (arr, value) => {
|
|
389
391
|
return arr.filter((item) => item !== value);
|
|
390
392
|
};
|
|
393
|
+
var addItemAfterEveryElement = (array, item) => {
|
|
394
|
+
const result = [];
|
|
395
|
+
for (let i = 0; i < array.length; i++) {
|
|
396
|
+
result.push(array[i]);
|
|
397
|
+
if (i < array.length - 1) {
|
|
398
|
+
result.push(item);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return result;
|
|
402
|
+
};
|
|
403
|
+
var reorderArrayByValues = (array, valueToMove, insertBeforeValue) => {
|
|
404
|
+
const newArray = [...array];
|
|
405
|
+
const indexToMove = newArray.indexOf(valueToMove);
|
|
406
|
+
const indexToInsertBefore = newArray.indexOf(insertBeforeValue);
|
|
407
|
+
if (indexToMove !== -1 && indexToInsertBefore !== -1) {
|
|
408
|
+
const removedItem = newArray.splice(indexToMove, 1)[0];
|
|
409
|
+
const insertIndex = indexToInsertBefore < indexToMove ? indexToInsertBefore : indexToInsertBefore + 1;
|
|
410
|
+
newArray.splice(insertIndex, 0, removedItem);
|
|
411
|
+
}
|
|
412
|
+
return newArray;
|
|
413
|
+
};
|
|
391
414
|
}
|
|
392
415
|
});
|
|
393
416
|
|
|
@@ -664,7 +687,7 @@ var require_object = __commonJS({
|
|
|
664
687
|
}
|
|
665
688
|
return stringified;
|
|
666
689
|
};
|
|
667
|
-
var objectToString = (obj, indent = 0) => {
|
|
690
|
+
var objectToString = (obj = {}, indent = 0) => {
|
|
668
691
|
const spaces = " ".repeat(indent);
|
|
669
692
|
let str = "{\n";
|
|
670
693
|
for (const [key, value] of Object.entries(obj)) {
|
|
@@ -731,7 +754,7 @@ var require_object = __commonJS({
|
|
|
731
754
|
continue;
|
|
732
755
|
const objProp = obj[prop];
|
|
733
756
|
if ((0, import_types.isString)(objProp)) {
|
|
734
|
-
if ((objProp.includes("=>") || objProp.startsWith("function") || objProp.startsWith("(")) && !objProp.startsWith("{") && !objProp.startsWith("[")) {
|
|
757
|
+
if ((objProp.includes("(){") || objProp.includes("() {") || objProp.includes("=>") || objProp.startsWith("()") || objProp.startsWith("async") || objProp.startsWith("function") || objProp.startsWith("(")) && !objProp.startsWith("{") && !objProp.startsWith("[")) {
|
|
735
758
|
try {
|
|
736
759
|
const evalProp = import_globals.window.eval(`(${objProp})`);
|
|
737
760
|
destringified[prop] = evalProp;
|
|
@@ -1119,20 +1142,21 @@ var require_cookie = __commonJS({
|
|
|
1119
1142
|
});
|
|
1120
1143
|
module2.exports = __toCommonJS2(cookie_exports);
|
|
1121
1144
|
var import_types = require_types();
|
|
1145
|
+
var import_utils2 = require_cjs();
|
|
1122
1146
|
var isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
1123
1147
|
var setCookie = (cname, cvalue, exdays = 365) => {
|
|
1124
|
-
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
1148
|
+
if ((0, import_types.isUndefined)(import_utils2.document) || (0, import_types.isUndefined)(import_utils2.document.cookie))
|
|
1125
1149
|
return;
|
|
1126
1150
|
const d = /* @__PURE__ */ new Date();
|
|
1127
1151
|
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
1128
1152
|
const expires = `expires=${d.toUTCString()}`;
|
|
1129
|
-
document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
1153
|
+
import_utils2.document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
1130
1154
|
};
|
|
1131
1155
|
var getCookie = (cname) => {
|
|
1132
|
-
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
1156
|
+
if ((0, import_types.isUndefined)(import_utils2.document) || (0, import_types.isUndefined)(import_utils2.document.cookie))
|
|
1133
1157
|
return;
|
|
1134
1158
|
const name = `${cname}=`;
|
|
1135
|
-
const decodedCookie = decodeURIComponent(document.cookie);
|
|
1159
|
+
const decodedCookie = decodeURIComponent(import_utils2.document.cookie);
|
|
1136
1160
|
const ca = decodedCookie.split(";");
|
|
1137
1161
|
for (let i = 0; i < ca.length; i++) {
|
|
1138
1162
|
let c = ca[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/utils",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.394",
|
|
4
4
|
"author": "symbo.ls",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@domql/utils": "latest"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "96fc31e44dd43084955c647e91b5d0e70d56aee8"
|
|
30
30
|
}
|
package/src/index.js
CHANGED
|
@@ -44,6 +44,7 @@ export const toDashCase = val => val
|
|
|
44
44
|
.replace(/^-|-$/g, '') // Remove leading and trailing dashes
|
|
45
45
|
|
|
46
46
|
export const toDescriptionCase = (str = '') => {
|
|
47
|
+
if (typeof str !== 'string') return
|
|
47
48
|
const result = str.replace(/([A-Z])/g, ' $1')
|
|
48
49
|
return result.charAt(0).toUpperCase() + result.slice(1)
|
|
49
50
|
}
|
package/src/load.js
CHANGED
|
@@ -27,3 +27,16 @@ export const loadJavascriptFile = (FILE_URL, async = true, doc = document, type
|
|
|
27
27
|
}
|
|
28
28
|
})
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
export const loadJavascript = (body, async = true, doc = document, type = 'text/javascript') => {
|
|
32
|
+
try {
|
|
33
|
+
const scriptEle = doc.createElement('script')
|
|
34
|
+
scriptEle.type = type
|
|
35
|
+
scriptEle.async = async
|
|
36
|
+
scriptEle.innerHTML = body
|
|
37
|
+
|
|
38
|
+
doc.body.appendChild(scriptEle)
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.warn(error)
|
|
41
|
+
}
|
|
42
|
+
}
|