@webalternatif/js-core 1.6.3 → 1.6.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 (57) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/Mouse.js +6 -1
  3. package/dist/cjs/Translator.js +7 -1
  4. package/dist/cjs/array.js +5 -35
  5. package/dist/cjs/dom.js +817 -208
  6. package/dist/cjs/eventDispatcher.js +6 -1
  7. package/dist/cjs/index.js +6 -13
  8. package/dist/cjs/is.js +44 -1
  9. package/dist/cjs/math.js +56 -31
  10. package/dist/cjs/traversal.js +1 -2
  11. package/dist/cjs/utils.js +155 -38
  12. package/dist/esm/Mouse.js +7 -1
  13. package/dist/esm/Translator.js +7 -1
  14. package/dist/esm/array.js +4 -35
  15. package/dist/esm/dom.js +816 -206
  16. package/dist/esm/eventDispatcher.js +7 -1
  17. package/dist/esm/index.js +7 -8
  18. package/dist/esm/is.js +43 -0
  19. package/dist/esm/math.js +58 -32
  20. package/dist/esm/traversal.js +1 -2
  21. package/dist/esm/utils.js +156 -39
  22. package/dist/umd/Translator.umd.js +1 -0
  23. package/dist/umd/dom.umd.js +1 -0
  24. package/dist/umd/eventDispatcher.umd.js +1 -0
  25. package/dist/umd/mouse.umd.js +1 -0
  26. package/dist/umd/webf.umd.js +1 -0
  27. package/docs/array.md +41 -8
  28. package/docs/dom.md +1063 -269
  29. package/docs/is.md +244 -0
  30. package/docs/math.md +87 -7
  31. package/docs/mouse.md +43 -0
  32. package/docs/translator.md +14 -14
  33. package/docs/traversal.md +16 -16
  34. package/docs/utils.md +173 -20
  35. package/package.json +10 -4
  36. package/src/Mouse.js +73 -0
  37. package/src/Translator.js +148 -0
  38. package/src/array.js +136 -0
  39. package/src/dom.js +1553 -0
  40. package/src/eventDispatcher.js +118 -0
  41. package/src/index.js +106 -0
  42. package/src/is.js +201 -0
  43. package/src/math.js +113 -0
  44. package/src/onOff.js +313 -0
  45. package/src/random.js +38 -0
  46. package/src/string.js +662 -0
  47. package/src/stringPrototype.js +16 -0
  48. package/src/traversal.js +236 -0
  49. package/src/utils.js +242 -0
  50. package/types/Translator.d.ts +6 -5
  51. package/types/array.d.ts +0 -1
  52. package/types/dom.d.ts +763 -204
  53. package/types/index.d.ts +22 -21
  54. package/types/is.d.ts +3 -0
  55. package/types/math.d.ts +6 -5
  56. package/types/utils.d.ts +4 -4
  57. package/types/i18n.d.ts +0 -4
package/README.md CHANGED
@@ -3,11 +3,11 @@
3
3
  [![codecov](https://codecov.io/github/webalternatif/js-core/branch/main/graph/badge.svg?token=MLPFU51XJH)](https://codecov.io/github/webalternatif/js-core)
4
4
  ![npm](https://img.shields.io/npm/v/@webalternatif/js-core)
5
5
 
6
- # js-core
6
+ # `@webalternatif/js-core`
7
7
 
8
- Modular JavaScript utilities for modern applications.
8
+ The utility library that would’ve been revolutionary in 2012.
9
9
 
10
- Lightweight, framework-agnostic helpers for data manipulation, DOM handling, events and internationalization.
10
+ Lightweight, framework-agnostic helpers for data manipulation, DOM handling, events, internationalization and more to come.
11
11
 
12
12
  ---
13
13
 
package/dist/cjs/Mouse.js CHANGED
@@ -82,4 +82,9 @@ function _getEvent(ev) {
82
82
  }
83
83
  return ev;
84
84
  }
85
- var _default = exports["default"] = Mouse;
85
+ var _default = exports["default"] = Mouse;
86
+ /* istanbul ignore else */
87
+ if (typeof window !== 'undefined') {
88
+ window.webf = window.webf || {};
89
+ window.webf.mouse = Mouse;
90
+ }
@@ -33,7 +33,7 @@ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.h
33
33
  var _lang = /*#__PURE__*/new WeakMap();
34
34
  var _mapping = /*#__PURE__*/new WeakMap();
35
35
  var _Translator_brand = /*#__PURE__*/new WeakSet();
36
- var Translator = exports["default"] = /*#__PURE__*/function () {
36
+ var Translator = /*#__PURE__*/function () {
37
37
  /**
38
38
  * @param {TranslatorMapping} mapping
39
39
  * @param {string} [defaultLang]
@@ -145,4 +145,10 @@ function _resolve(entry) {
145
145
  return entry();
146
146
  }
147
147
  return entry;
148
+ }
149
+ var _default = exports["default"] = Translator;
150
+ /* istanbul ignore next */
151
+ if (typeof window !== 'undefined') {
152
+ window.webf = window.webf || {};
153
+ window.webf.Translator = Translator;
148
154
  }
package/dist/cjs/array.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.range = exports.lastIndexOf = exports.indexOf = exports.inArray = exports.compareArray = exports.array_unique = exports.array_diff = exports.arrayUnique = exports.arrayDiff = void 0;
6
+ exports.range = exports.lastIndexOf = exports.indexOf = exports.inArray = exports.array_unique = exports.array_diff = exports.arrayUnique = exports.arrayDiff = void 0;
7
7
  var _traversal = require("./traversal.js");
8
8
  var _is = require("./is.js");
9
9
  var _math = require("./math.js");
@@ -18,15 +18,13 @@ var _utils = require("./utils.js");
18
18
  * @returns {boolean}
19
19
  *
20
20
  * @example
21
- * inArray(2, [1, 2, 3])
22
- * // → true
21
+ * inArray(2, [1, 2, 3]) => true
23
22
  *
24
23
  * @example
25
- * inArray({a: 1}, {a: 1, b: 2})
26
- * // → true
24
+ * inArray({a: 1}, {a: 1, b: 2}) // => true
27
25
  *
28
26
  * @example
29
- * inArray(5, [1, 2, 3]) // false
27
+ * inArray(5, [1, 2, 3]) // => false
30
28
  */
31
29
  var inArray = exports.inArray = function inArray(value, arr) {
32
30
  var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
@@ -44,7 +42,7 @@ var inArray = exports.inArray = function inArray(value, arr) {
44
42
  ret = (0, _utils.equals)(val, value);
45
43
  return false;
46
44
  } else if ((0, _is.isArray)(value) && (0, _is.isObject)(val)) {
47
- ret = _compareArray(val, value);
45
+ ret = (0, _utils.equals)(val, value);
48
46
  return false;
49
47
  // eslint-disable-next-line eqeqeq
50
48
  } else if (val == value) {
@@ -102,34 +100,6 @@ var lastIndexOf = exports.lastIndexOf = function lastIndexOf(arr, elt) {
102
100
  }
103
101
  return -1;
104
102
  };
105
-
106
- /**
107
- * Returns true if given arrays are equals
108
- *
109
- * @example
110
- *
111
- *
112
- * @param {Array} a1
113
- * @param {Array} a2
114
- * @returns {boolean}
115
- */
116
- var _compareArray = exports.compareArray = function compareArray(a1, a2) {
117
- if (a1.length !== a2.length) {
118
- return false;
119
- } else {
120
- for (var i = 0; i < a1.length; i++) {
121
- if ((0, _is.isArray)(a1[i])) {
122
- if (!(0, _is.isArray)(a2[i])) {
123
- return false;
124
- }
125
- return _compareArray(a1[i], a2[i]);
126
- } else if (a1[i] !== a2[i]) {
127
- return false;
128
- }
129
- }
130
- }
131
- return true;
132
- };
133
103
  var arrayUnique = exports.arrayUnique = function arrayUnique(arr) {
134
104
  return arr.filter(function (el, index, arr) {
135
105
  return index === indexOf(arr, el);