@schukai/monster 3.4.2 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/example/i18n/providers/embed.mjs +5 -0
- package/package.json +1 -1
- package/source/constants.mjs +4 -9
- package/source/constraints/abstract.mjs +4 -6
- package/source/constraints/abstractoperator.mjs +6 -12
- package/source/constraints/andoperator.mjs +3 -6
- package/source/constraints/invalid.mjs +3 -6
- package/source/constraints/isarray.mjs +6 -9
- package/source/constraints/isobject.mjs +4 -7
- package/source/constraints/namespace.mjs +1 -3
- package/source/constraints/oroperator.mjs +26 -25
- package/source/constraints/valid.mjs +3 -6
- package/source/data/buildmap.mjs +20 -36
- package/source/data/buildtree.mjs +29 -29
- package/source/data/datasource/namespace.mjs +1 -1
- package/source/data/datasource/server/restapi/writeerror.mjs +6 -6
- package/source/data/datasource/server/restapi.mjs +51 -65
- package/source/data/datasource/server/webconnect.mjs +26 -35
- package/source/data/datasource/server.mjs +17 -21
- package/source/data/datasource/storage/localstorage.mjs +8 -11
- package/source/data/datasource/storage/sessionstorage.mjs +8 -10
- package/source/data/datasource/storage.mjs +18 -22
- package/source/data/datasource.mjs +27 -43
- package/source/data/diff.mjs +20 -32
- package/source/data/extend.mjs +20 -14
- package/source/data/namespace.mjs +1 -3
- package/source/data/pathfinder.mjs +40 -67
- package/source/data/pipe.mjs +6 -10
- package/source/data/transformer.mjs +141 -157
- package/source/dom/assembler.mjs +6 -9
- package/source/dom/attributes.mjs +36 -48
- package/source/dom/constants.mjs +55 -71
- package/source/dom/customcontrol.mjs +16 -21
- package/source/dom/customelement.mjs +140 -164
- package/source/dom/events.mjs +17 -24
- package/source/dom/focusmanager.mjs +30 -48
- package/source/dom/locale.mjs +41 -10
- package/source/dom/namespace.mjs +1 -1
- package/source/dom/ready.mjs +7 -10
- package/source/dom/resource/data.mjs +38 -46
- package/source/dom/resource/link/namespace.mjs +1 -3
- package/source/dom/resource/link/stylesheet.mjs +7 -11
- package/source/dom/resource/link.mjs +36 -17
- package/source/dom/resource/namespace.mjs +1 -1
- package/source/dom/resource/script.mjs +23 -13
- package/source/dom/resource.mjs +47 -60
- package/source/dom/resourcemanager.mjs +36 -43
- package/source/dom/template.mjs +17 -24
- package/source/dom/theme.mjs +8 -12
- package/source/dom/updater.mjs +150 -196
- package/source/dom/util.mjs +11 -12
- package/source/dom/worker/factory.mjs +21 -25
- package/source/dom/worker/namespace.mjs +1 -1
- package/source/i18n/formatter.mjs +20 -24
- package/source/i18n/locale.mjs +40 -42
- package/source/i18n/namespace.mjs +1 -1
- package/source/i18n/provider.mjs +4 -7
- package/source/i18n/providers/embed.mjs +115 -0
- package/source/i18n/providers/fetch.mjs +33 -38
- package/source/i18n/translations.mjs +16 -20
- package/source/logging/handler/console.mjs +6 -10
- package/source/logging/handler.mjs +15 -18
- package/source/logging/logentry.mjs +8 -9
- package/source/logging/logger.mjs +73 -55
- package/source/logging/namespace.mjs +1 -1
- package/source/math/namespace.mjs +1 -1
- package/source/math/random.mjs +13 -14
- package/source/monster.mjs +132 -100
- package/source/net/namespace.mjs +1 -3
- package/source/net/webconnect/message.mjs +6 -8
- package/source/net/webconnect/namespace.mjs +1 -3
- package/source/net/webconnect.mjs +28 -39
- package/source/text/formatter.mjs +44 -55
- package/source/types/base.mjs +16 -26
- package/source/types/basewithoptions.mjs +8 -14
- package/source/types/binary.mjs +4 -5
- package/source/types/dataurl.mjs +19 -27
- package/source/types/global.mjs +14 -26
- package/source/types/id.mjs +4 -6
- package/source/types/is.mjs +11 -16
- package/source/types/mediatype.mjs +29 -44
- package/source/types/namespace.mjs +0 -1
- package/source/types/node.mjs +16 -22
- package/source/types/nodelist.mjs +10 -14
- package/source/types/noderecursiveiterator.mjs +11 -14
- package/source/types/observablequeue.mjs +13 -16
- package/source/types/observer.mjs +16 -23
- package/source/types/observerlist.mjs +18 -21
- package/source/types/proxyobserver.mjs +24 -37
- package/source/types/queue.mjs +8 -13
- package/source/types/randomid.mjs +10 -10
- package/source/types/regex.mjs +3 -5
- package/source/types/stack.mjs +4 -8
- package/source/types/tokenlist.mjs +24 -31
- package/source/types/typeof.mjs +5 -7
- package/source/types/uniquequeue.mjs +8 -13
- package/source/types/uuid.mjs +18 -25
- package/source/types/validate.mjs +26 -27
- package/source/types/version.mjs +17 -25
- package/source/util/clone.mjs +23 -32
- package/source/util/comparator.mjs +7 -15
- package/source/util/deadmansswitch.mjs +16 -23
- package/source/util/freeze.mjs +5 -7
- package/source/util/namespace.mjs +1 -1
- package/source/util/processing.mjs +33 -39
- package/source/util/trimspaces.mjs +17 -24
- package/test/cases/dom/locale.mjs +15 -0
- package/test/cases/i18n/providers/embed.mjs +72 -0
- package/test/cases/monster.mjs +1 -1
@@ -5,12 +5,12 @@
|
|
5
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
6
|
*/
|
7
7
|
|
8
|
-
import {Base} from
|
9
|
-
import {isObject} from
|
10
|
-
import {TokenList} from
|
11
|
-
import {UniqueQueue} from
|
12
|
-
import {instanceSymbol} from
|
13
|
-
export {Observer}
|
8
|
+
import { Base } from "./base.mjs";
|
9
|
+
import { isObject } from "./is.mjs";
|
10
|
+
import { TokenList } from "./tokenlist.mjs";
|
11
|
+
import { UniqueQueue } from "./uniquequeue.mjs";
|
12
|
+
import { instanceSymbol } from "../constants.mjs";
|
13
|
+
export { Observer };
|
14
14
|
|
15
15
|
/**
|
16
16
|
* An observer manages a callback function
|
@@ -32,7 +32,7 @@ export {Observer}
|
|
32
32
|
*
|
33
33
|
* ```js
|
34
34
|
* Observer(function(a, b, c) {
|
35
|
-
* console.log(a, b, c); // ↦ "a", 2, true
|
35
|
+
* console.log(a, b, c); // ↦ "a", 2, true
|
36
36
|
* }, "a", 2, true)
|
37
37
|
* ```
|
38
38
|
*
|
@@ -45,7 +45,6 @@ export {Observer}
|
|
45
45
|
* @memberOf Monster.Types
|
46
46
|
*/
|
47
47
|
class Observer extends Base {
|
48
|
-
|
49
48
|
/**
|
50
49
|
*
|
51
50
|
* @param {function} callback
|
@@ -54,13 +53,13 @@ class Observer extends Base {
|
|
54
53
|
constructor(callback, ...args) {
|
55
54
|
super();
|
56
55
|
|
57
|
-
if (typeof callback !==
|
58
|
-
throw new Error("observer callback must be a function")
|
56
|
+
if (typeof callback !== "function") {
|
57
|
+
throw new Error("observer callback must be a function");
|
59
58
|
}
|
60
59
|
|
61
60
|
this.callback = callback;
|
62
61
|
this.arguments = args;
|
63
|
-
this.tags = new TokenList;
|
62
|
+
this.tags = new TokenList();
|
64
63
|
this.queue = new UniqueQueue();
|
65
64
|
}
|
66
65
|
|
@@ -72,8 +71,7 @@ class Observer extends Base {
|
|
72
71
|
static get [instanceSymbol]() {
|
73
72
|
return Symbol.for("@schukai/monster/types/observer");
|
74
73
|
}
|
75
|
-
|
76
|
-
|
74
|
+
|
77
75
|
/**
|
78
76
|
*
|
79
77
|
* @param {string} tag
|
@@ -99,7 +97,7 @@ class Observer extends Base {
|
|
99
97
|
* @returns {Array}
|
100
98
|
*/
|
101
99
|
getTags() {
|
102
|
-
return this.tags.entries()
|
100
|
+
return this.tags.entries();
|
103
101
|
}
|
104
102
|
|
105
103
|
/**
|
@@ -108,7 +106,7 @@ class Observer extends Base {
|
|
108
106
|
* @returns {boolean}
|
109
107
|
*/
|
110
108
|
hasTag(tag) {
|
111
|
-
return this.tags.contains(tag)
|
109
|
+
return this.tags.contains(tag);
|
112
110
|
}
|
113
111
|
|
114
112
|
/**
|
@@ -128,9 +126,8 @@ class Observer extends Base {
|
|
128
126
|
self.queue.add(subject);
|
129
127
|
|
130
128
|
setTimeout(() => {
|
131
|
-
|
132
129
|
try {
|
133
|
-
// the queue and the settimeout ensure that an object is not
|
130
|
+
// the queue and the settimeout ensure that an object is not
|
134
131
|
// informed of the same change more than once.
|
135
132
|
if (self.queue.isEmpty()) {
|
136
133
|
resolve();
|
@@ -146,14 +143,10 @@ class Observer extends Base {
|
|
146
143
|
}
|
147
144
|
|
148
145
|
resolve(result);
|
149
|
-
|
150
146
|
} catch (e) {
|
151
147
|
reject(e);
|
152
148
|
}
|
153
|
-
}, 0)
|
154
|
-
|
149
|
+
}, 0);
|
155
150
|
});
|
156
|
-
|
157
|
-
};
|
158
|
-
|
151
|
+
}
|
159
152
|
}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
/**
|
4
2
|
* Copyright schukai GmbH and contributors 2022. All Rights Reserved.
|
5
3
|
* Node module: @schukai/monster
|
@@ -7,12 +5,11 @@
|
|
7
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
8
6
|
*/
|
9
7
|
|
8
|
+
import { Base } from "./base.mjs";
|
9
|
+
import { Observer } from "./observer.mjs";
|
10
|
+
import { validateInstance } from "./validate.mjs";
|
10
11
|
|
11
|
-
|
12
|
-
import {Observer} from "./observer.mjs";
|
13
|
-
import {validateInstance} from "./validate.mjs";
|
14
|
-
|
15
|
-
export {ObserverList}
|
12
|
+
export { ObserverList };
|
16
13
|
|
17
14
|
/**
|
18
15
|
* With the help of the ObserverList class, observer can be managed.
|
@@ -23,7 +20,6 @@ export {ObserverList}
|
|
23
20
|
* @memberOf Monster.Types
|
24
21
|
*/
|
25
22
|
class ObserverList extends Base {
|
26
|
-
|
27
23
|
/**
|
28
24
|
*
|
29
25
|
*/
|
@@ -39,11 +35,11 @@ class ObserverList extends Base {
|
|
39
35
|
* @throws {TypeError} value is not an instance of Observer
|
40
36
|
*/
|
41
37
|
attach(observer) {
|
42
|
-
validateInstance(observer, Observer)
|
38
|
+
validateInstance(observer, Observer);
|
43
39
|
|
44
40
|
this.observers.push(observer);
|
45
41
|
return this;
|
46
|
-
}
|
42
|
+
}
|
47
43
|
|
48
44
|
/**
|
49
45
|
*
|
@@ -52,9 +48,10 @@ class ObserverList extends Base {
|
|
52
48
|
* @throws {TypeError} value is not an instance of Observer
|
53
49
|
*/
|
54
50
|
detach(observer) {
|
55
|
-
validateInstance(observer, Observer)
|
51
|
+
validateInstance(observer, Observer);
|
56
52
|
|
57
|
-
var i = 0
|
53
|
+
var i = 0;
|
54
|
+
var l = this.observers.length;
|
58
55
|
for (; i < l; i++) {
|
59
56
|
if (this.observers[i] === observer) {
|
60
57
|
this.observers.splice(i, 1);
|
@@ -62,7 +59,7 @@ class ObserverList extends Base {
|
|
62
59
|
}
|
63
60
|
|
64
61
|
return this;
|
65
|
-
}
|
62
|
+
}
|
66
63
|
|
67
64
|
/**
|
68
65
|
*
|
@@ -71,15 +68,16 @@ class ObserverList extends Base {
|
|
71
68
|
* @throws {TypeError} value is not an instance of Observer
|
72
69
|
*/
|
73
70
|
contains(observer) {
|
74
|
-
validateInstance(observer, Observer)
|
75
|
-
var i = 0
|
71
|
+
validateInstance(observer, Observer);
|
72
|
+
var i = 0;
|
73
|
+
var l = this.observers.length;
|
76
74
|
for (; i < l; i++) {
|
77
75
|
if (this.observers[i] === observer) {
|
78
76
|
return true;
|
79
77
|
}
|
80
78
|
}
|
81
79
|
return false;
|
82
|
-
}
|
80
|
+
}
|
83
81
|
|
84
82
|
/**
|
85
83
|
*
|
@@ -87,15 +85,14 @@ class ObserverList extends Base {
|
|
87
85
|
* @return {Promise}
|
88
86
|
*/
|
89
87
|
notify(subject) {
|
88
|
+
let pomises = [];
|
90
89
|
|
91
|
-
let
|
92
|
-
|
93
|
-
let i = 0, l = this.observers.length;
|
90
|
+
let i = 0;
|
91
|
+
let l = this.observers.length;
|
94
92
|
for (; i < l; i++) {
|
95
93
|
pomises.push(this.observers[i].update(subject));
|
96
94
|
}
|
97
95
|
|
98
96
|
return Promise.all(pomises);
|
99
|
-
}
|
100
|
-
|
97
|
+
}
|
101
98
|
}
|
@@ -5,19 +5,19 @@
|
|
5
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
6
|
*/
|
7
7
|
|
8
|
-
import {Base} from
|
9
|
-
import {isArray, isObject, isPrimitive} from "./is.mjs";
|
10
|
-
import {Observer} from "./observer.mjs";
|
11
|
-
import {ObserverList} from "./observerlist.mjs";
|
12
|
-
import {validateObject} from "./validate.mjs";
|
13
|
-
import {extend} from "../data/extend.mjs";
|
14
|
-
import {instanceSymbol} from
|
15
|
-
export {ProxyObserver}
|
8
|
+
import { Base } from "./base.mjs";
|
9
|
+
import { isArray, isObject, isPrimitive } from "./is.mjs";
|
10
|
+
import { Observer } from "./observer.mjs";
|
11
|
+
import { ObserverList } from "./observerlist.mjs";
|
12
|
+
import { validateObject } from "./validate.mjs";
|
13
|
+
import { extend } from "../data/extend.mjs";
|
14
|
+
import { instanceSymbol } from "../constants.mjs";
|
15
|
+
export { ProxyObserver };
|
16
16
|
|
17
17
|
/**
|
18
18
|
* An observer manages a callback function
|
19
19
|
*
|
20
|
-
* With the ProxyObserver you can attach observer for observation.
|
20
|
+
* With the ProxyObserver you can attach observer for observation.
|
21
21
|
* With each change at the object to be observed an update takes place.
|
22
22
|
*
|
23
23
|
* This also applies to nested objects.
|
@@ -28,8 +28,7 @@ export {ProxyObserver}
|
|
28
28
|
* @copyright schukai GmbH
|
29
29
|
* @memberOf Monster.Types
|
30
30
|
*/
|
31
|
-
|
32
|
-
|
31
|
+
class ProxyObserver extends Base {
|
33
32
|
/**
|
34
33
|
*
|
35
34
|
* @param {object} object
|
@@ -47,7 +46,7 @@ export {ProxyObserver}
|
|
47
46
|
this.proxyMap = new WeakMap();
|
48
47
|
this.proxyMap.set(this.subject, this.realSubject);
|
49
48
|
|
50
|
-
this.observers = new ObserverList;
|
49
|
+
this.observers = new ObserverList();
|
51
50
|
}
|
52
51
|
|
53
52
|
/**
|
@@ -59,7 +58,6 @@ export {ProxyObserver}
|
|
59
58
|
return Symbol.for("@schukai/monster/types/proxy-observer");
|
60
59
|
}
|
61
60
|
|
62
|
-
|
63
61
|
/**
|
64
62
|
* Get the real object
|
65
63
|
*
|
@@ -68,7 +66,7 @@ export {ProxyObserver}
|
|
68
66
|
* @returns {object}
|
69
67
|
*/
|
70
68
|
getSubject() {
|
71
|
-
return this.subject
|
69
|
+
return this.subject;
|
72
70
|
}
|
73
71
|
|
74
72
|
/**
|
@@ -77,8 +75,8 @@ export {ProxyObserver}
|
|
77
75
|
* @return {Monster.Types.ProxyObserver}
|
78
76
|
*/
|
79
77
|
setSubject(obj) {
|
80
|
-
|
81
|
-
let
|
78
|
+
let i;
|
79
|
+
let k = Object.keys(this.subject);
|
82
80
|
for (i = 0; i < k.length; i++) {
|
83
81
|
delete this.subject[k[i]];
|
84
82
|
}
|
@@ -93,7 +91,7 @@ export {ProxyObserver}
|
|
93
91
|
* @returns {object}
|
94
92
|
*/
|
95
93
|
getRealSubject() {
|
96
|
-
return this.realSubject
|
94
|
+
return this.realSubject;
|
97
95
|
}
|
98
96
|
|
99
97
|
/**
|
@@ -103,7 +101,7 @@ export {ProxyObserver}
|
|
103
101
|
* @returns {ProxyObserver}
|
104
102
|
*/
|
105
103
|
attachObserver(observer) {
|
106
|
-
this.observers.attach(observer)
|
104
|
+
this.observers.attach(observer);
|
107
105
|
return this;
|
108
106
|
}
|
109
107
|
|
@@ -114,7 +112,7 @@ export {ProxyObserver}
|
|
114
112
|
* @returns {ProxyObserver}
|
115
113
|
*/
|
116
114
|
detachObserver(observer) {
|
117
|
-
this.observers.detach(observer)
|
115
|
+
this.observers.detach(observer);
|
118
116
|
return this;
|
119
117
|
}
|
120
118
|
|
@@ -132,9 +130,8 @@ export {ProxyObserver}
|
|
132
130
|
* @returns {boolean}
|
133
131
|
*/
|
134
132
|
containsObserver(observer) {
|
135
|
-
return this.observers.contains(observer)
|
133
|
+
return this.observers.contains(observer);
|
136
134
|
}
|
137
|
-
|
138
135
|
}
|
139
136
|
|
140
137
|
/**
|
@@ -144,15 +141,12 @@ export {ProxyObserver}
|
|
144
141
|
* @see {@link https://gitlab.schukai.com/-/snippets/49}
|
145
142
|
*/
|
146
143
|
function getHandler() {
|
147
|
-
|
148
144
|
const proxy = this;
|
149
145
|
|
150
146
|
// https://262.ecma-international.org/9.0/#sec-proxy-object-internal-methods-and-internal-slots
|
151
147
|
const handler = {
|
152
|
-
|
153
148
|
// https://262.ecma-international.org/9.0/#sec-proxy-object-internal-methods-and-internal-slots-get-p-receiver
|
154
149
|
get: function (target, key, receiver) {
|
155
|
-
|
156
150
|
const value = Reflect.get(target, key, receiver);
|
157
151
|
|
158
152
|
if (typeof key === "symbol") {
|
@@ -164,7 +158,7 @@ function getHandler() {
|
|
164
158
|
}
|
165
159
|
|
166
160
|
// set value as proxy if object or array
|
167
|
-
if (
|
161
|
+
if (isArray(value) || isObject(value)) {
|
168
162
|
if (proxy.objectMap.has(value)) {
|
169
163
|
return proxy.objectMap.get(value);
|
170
164
|
} else if (proxy.proxyMap.has(value)) {
|
@@ -175,16 +169,13 @@ function getHandler() {
|
|
175
169
|
proxy.proxyMap.set(p, value);
|
176
170
|
return p;
|
177
171
|
}
|
178
|
-
|
179
172
|
}
|
180
173
|
|
181
174
|
return value;
|
182
|
-
|
183
175
|
},
|
184
176
|
|
185
|
-
// https://262.ecma-international.org/9.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver
|
177
|
+
// https://262.ecma-international.org/9.0/#sec-proxy-object-internal-methods-and-internal-slots-set-p-v-receiver
|
186
178
|
set: function (target, key, value, receiver) {
|
187
|
-
|
188
179
|
if (proxy.proxyMap.has(value)) {
|
189
180
|
value = proxy.proxyMap.get(value);
|
190
181
|
}
|
@@ -209,11 +200,11 @@ function getHandler() {
|
|
209
200
|
descriptor = {
|
210
201
|
writable: true,
|
211
202
|
enumerable: true,
|
212
|
-
configurable: true
|
213
|
-
}
|
203
|
+
configurable: true,
|
204
|
+
};
|
214
205
|
}
|
215
206
|
|
216
|
-
descriptor[
|
207
|
+
descriptor["value"] = value;
|
217
208
|
result = Reflect.defineProperty(target, key, descriptor);
|
218
209
|
|
219
210
|
if (typeof key !== "symbol") {
|
@@ -223,7 +214,6 @@ function getHandler() {
|
|
223
214
|
return result;
|
224
215
|
},
|
225
216
|
|
226
|
-
|
227
217
|
// https://262.ecma-international.org/9.0/#sec-proxy-object-internal-methods-and-internal-slots-delete-p
|
228
218
|
deleteProperty: function (target, key) {
|
229
219
|
if (key in target) {
|
@@ -240,7 +230,6 @@ function getHandler() {
|
|
240
230
|
|
241
231
|
// https://262.ecma-international.org/9.0/#sec-proxy-object-internal-methods-and-internal-slots-defineownproperty-p-desc
|
242
232
|
defineProperty: function (target, key, descriptor) {
|
243
|
-
|
244
233
|
let result = Reflect.defineProperty(target, key, descriptor);
|
245
234
|
if (typeof key !== "symbol") {
|
246
235
|
proxy.observers.notify(proxy);
|
@@ -257,10 +246,8 @@ function getHandler() {
|
|
257
246
|
}
|
258
247
|
|
259
248
|
return result;
|
260
|
-
}
|
261
|
-
|
249
|
+
},
|
262
250
|
};
|
263
251
|
|
264
|
-
|
265
252
|
return handler;
|
266
253
|
}
|
package/source/types/queue.mjs
CHANGED
@@ -5,20 +5,20 @@
|
|
5
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
6
|
*/
|
7
7
|
|
8
|
-
import {Base} from
|
9
|
-
import {instanceSymbol} from
|
8
|
+
import { Base } from "./base.mjs";
|
9
|
+
import { instanceSymbol } from "../constants.mjs";
|
10
10
|
|
11
|
-
export {Queue}
|
11
|
+
export { Queue };
|
12
12
|
|
13
13
|
/**
|
14
14
|
* A queue is a list of items that are processed one after another (first in, first out).
|
15
|
-
*
|
15
|
+
*
|
16
16
|
* With a queue you can add items to the end of the list `Queue.add()` and remove items from the beginning of the list `Queue.pop()`.
|
17
|
-
*
|
17
|
+
*
|
18
18
|
* With `Queue.peek()` you can get the first item without removing it from the list.
|
19
|
-
*
|
19
|
+
*
|
20
20
|
* You can create the instance via `new Queue()`.
|
21
|
-
*
|
21
|
+
*
|
22
22
|
* @externalExample ../../example/types/queue.mjs
|
23
23
|
* @license AGPLv3
|
24
24
|
* @since 1.4.0
|
@@ -27,7 +27,6 @@ export {Queue}
|
|
27
27
|
* @summary A Queue (Fifo)
|
28
28
|
*/
|
29
29
|
class Queue extends Base {
|
30
|
-
|
31
30
|
/**
|
32
31
|
*
|
33
32
|
*/
|
@@ -45,8 +44,6 @@ class Queue extends Base {
|
|
45
44
|
return Symbol.for("@schukai/monster/types/queue");
|
46
45
|
}
|
47
46
|
|
48
|
-
|
49
|
-
|
50
47
|
/**
|
51
48
|
* @return {boolean}
|
52
49
|
*/
|
@@ -74,7 +71,7 @@ class Queue extends Base {
|
|
74
71
|
* @returns {Queue}
|
75
72
|
*/
|
76
73
|
add(value) {
|
77
|
-
this.data.push(value)
|
74
|
+
this.data.push(value);
|
78
75
|
return this;
|
79
76
|
}
|
80
77
|
|
@@ -100,6 +97,4 @@ class Queue extends Base {
|
|
100
97
|
}
|
101
98
|
return this.data.shift();
|
102
99
|
}
|
103
|
-
|
104
|
-
|
105
100
|
}
|
@@ -5,11 +5,11 @@
|
|
5
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
6
|
*/
|
7
7
|
|
8
|
-
import {random} from "../math/random.mjs";
|
9
|
-
import {getGlobal} from "./global.mjs";
|
10
|
-
import {ID} from "./id.mjs";
|
8
|
+
import { random } from "../math/random.mjs";
|
9
|
+
import { getGlobal } from "./global.mjs";
|
10
|
+
import { ID } from "./id.mjs";
|
11
11
|
|
12
|
-
export {RandomID}
|
12
|
+
export { RandomID };
|
13
13
|
|
14
14
|
/**
|
15
15
|
* @private
|
@@ -27,7 +27,6 @@ let internalCounter = 0;
|
|
27
27
|
* @summary class to generate random numbers
|
28
28
|
*/
|
29
29
|
class RandomID extends ID {
|
30
|
-
|
31
30
|
/**
|
32
31
|
* create new object
|
33
32
|
*/
|
@@ -36,10 +35,11 @@ class RandomID extends ID {
|
|
36
35
|
|
37
36
|
internalCounter += 1;
|
38
37
|
|
39
|
-
this.id =
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
this.id =
|
39
|
+
getGlobal()
|
40
|
+
.btoa(random(1, 10000))
|
41
|
+
.replace(/=/g, "")
|
42
|
+
/** No numbers at the beginning of the ID, because of possible problems with DOM */
|
43
|
+
.replace(/^[0-9]+/, "X") + internalCounter;
|
43
44
|
}
|
44
|
-
|
45
45
|
}
|
package/source/types/regex.mjs
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
6
|
*/
|
7
7
|
|
8
|
-
import {validateString} from "./validate.mjs";
|
8
|
+
import { validateString } from "./validate.mjs";
|
9
9
|
|
10
|
-
export {escapeString}
|
10
|
+
export { escapeString };
|
11
11
|
|
12
12
|
/**
|
13
13
|
* This function prefixes all special characters that may appear in a regex with a slash.
|
@@ -21,7 +21,5 @@ export {escapeString}
|
|
21
21
|
* @throws {TypeError} value is not a string
|
22
22
|
*/
|
23
23
|
function escapeString(value) {
|
24
|
-
return validateString(value)
|
25
|
-
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
26
|
-
.replace(/-/g, '\\x2d');
|
24
|
+
return validateString(value).replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
27
25
|
}
|
package/source/types/stack.mjs
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
|
6
6
|
*/
|
7
7
|
|
8
|
-
import {Base} from
|
9
|
-
import {instanceSymbol} from
|
10
|
-
export {Stack}
|
8
|
+
import { Base } from "./base.mjs";
|
9
|
+
import { instanceSymbol } from "../constants.mjs";
|
10
|
+
export { Stack };
|
11
11
|
|
12
12
|
/**
|
13
13
|
* You can call the method via the monster namespace `new Monster.Types.Queue()`.
|
@@ -18,7 +18,6 @@ export {Stack}
|
|
18
18
|
* @memberOf Monster.Types
|
19
19
|
*/
|
20
20
|
class Stack extends Base {
|
21
|
-
|
22
21
|
/**
|
23
22
|
*
|
24
23
|
*/
|
@@ -36,7 +35,6 @@ class Stack extends Base {
|
|
36
35
|
return Symbol.for("@schukai/monster/types/stack");
|
37
36
|
}
|
38
37
|
|
39
|
-
|
40
38
|
/**
|
41
39
|
* @return {boolean}
|
42
40
|
*/
|
@@ -64,7 +62,7 @@ class Stack extends Base {
|
|
64
62
|
* @returns {Queue}
|
65
63
|
*/
|
66
64
|
push(value) {
|
67
|
-
this.data.push(value)
|
65
|
+
this.data.push(value);
|
68
66
|
return this;
|
69
67
|
}
|
70
68
|
|
@@ -91,6 +89,4 @@ class Stack extends Base {
|
|
91
89
|
}
|
92
90
|
return this.data.pop();
|
93
91
|
}
|
94
|
-
|
95
|
-
|
96
92
|
}
|