aprog 1.8.6 → 1.8.7

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 (3) hide show
  1. package/index.js +2 -1
  2. package/package.json +1 -1
  3. package/src/html.js +12 -0
package/index.js CHANGED
@@ -17,5 +17,6 @@ export { saveItem, loadItem, setSecretKey } from './src/secretStorage.js';
17
17
  export {
18
18
  pushHTMLElementPrototype, pushAfterHTMLElementPrototype,
19
19
  pushBeforeHTMLElementPrototype, dataHTMLElementPrototype,
20
- toKebabCaseStringPrototype, repeatHTMLElementPrototype
20
+ toKebabCaseStringPrototype, toSnakeCaseStringPrototype,
21
+ repeatHTMLElementPrototype
21
22
  } from './src/html.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aprog",
3
- "version": "1.8.6",
3
+ "version": "1.8.7",
4
4
  "description": "Допоміжна бібліотека js",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/html.js CHANGED
@@ -46,6 +46,17 @@ export function toKebabCaseStringPrototype() {
46
46
  }
47
47
  }
48
48
 
49
+ export function toSnakeCaseStringPrototype() {
50
+ if (!String.prototype.toSnakeCase) {
51
+ String.prototype.toSnakeCase = function () {
52
+ return this
53
+ .replace(/([a-z0-9])([A-Z])/g, '$1_$2')
54
+ .replace(/([A-Z])([A-Z][a-z])/g, '$1_$2')
55
+ .toLowerCase();
56
+ };
57
+ }
58
+ }
59
+
49
60
  export function repeatHTMLElementPrototype() {
50
61
  if (!HTMLElement.prototype.repeat) {
51
62
  HTMLElement.prototype.repeat = function (newElement) {
@@ -62,4 +73,5 @@ pushAfterHTMLElementPrototype();
62
73
  pushBeforeHTMLElementPrototype();
63
74
  dataHTMLElementPrototype();
64
75
  toKebabCaseStringPrototype();
76
+ toSnakeCaseStringPrototype();
65
77
  repeatHTMLElementPrototype();