@schukai/monster 3.34.0 → 3.35.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,34 +4,34 @@
4
4
  * This file is licensed under the AGPLv3 License.
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
- import {internalSymbol} from "../constants.mjs";
8
- import {extend} from "../data/extend.mjs";
9
- import {Pathfinder} from "../data/pathfinder.mjs";
10
- import {parseDataURL} from "./dataurl.mjs";
11
- import {isString} from "./is.mjs";
12
- import {Observer} from "./observer.mjs";
13
- import {ProxyObserver} from "./proxyobserver.mjs";
14
- import {validateObject} from "./validate.mjs";
15
- import {isObject} from "./is.mjs";
16
-
17
- export {equipWithInternal}
7
+ import { internalSymbol } from "../constants.mjs";
8
+ import { extend } from "../data/extend.mjs";
9
+ import { Pathfinder } from "../data/pathfinder.mjs";
10
+ import { parseDataURL } from "./dataurl.mjs";
11
+ import { isString } from "./is.mjs";
12
+ import { Observer } from "./observer.mjs";
13
+ import { ProxyObserver } from "./proxyobserver.mjs";
14
+ import { validateObject } from "./validate.mjs";
15
+ import { isObject } from "./is.mjs";
16
+
17
+ export { equipWithInternal };
18
18
 
19
19
  /**
20
20
  * @private
21
21
  * @type {string}
22
22
  */
23
- const propertyName = 'internalDefaults'
23
+ const propertyName = "internalDefaults";
24
24
 
25
25
  /**
26
26
  * This function extends the given object with the following methods:
27
- *
27
+ *
28
28
  * - attachInternalObserver
29
29
  * - detachInternalObserver
30
30
  * - containsInternalObserver
31
31
  * - setInternal
32
32
  * - setInternals
33
33
  * - getInternal
34
- *
34
+ *
35
35
  * @license AGPLv3
36
36
  * @since 3.15.0
37
37
  * @copyright schukai GmbH
@@ -45,7 +45,7 @@ function equipWithInternal() {
45
45
  Object.defineProperty(self, propertyName, {
46
46
  get: function () {
47
47
  return {};
48
- }
48
+ },
49
49
  });
50
50
  }
51
51
 
@@ -61,7 +61,7 @@ function equipWithInternal() {
61
61
  self["attachInternalObserver"] = (observer) => {
62
62
  self[internalSymbol].attachObserver(observer);
63
63
  return self;
64
- }
64
+ };
65
65
 
66
66
  /**
67
67
  * Detach a observer
@@ -72,18 +72,17 @@ function equipWithInternal() {
72
72
  self["detachInternalObserver"] = (observer) => {
73
73
  self[internalSymbol].detachObserver(observer);
74
74
  return self;
75
- }
75
+ };
76
76
 
77
77
  /**
78
78
  * Check if a observer is attached
79
- *
79
+ *
80
80
  * @param {Observer} observer
81
81
  * @returns {boolean}
82
82
  */
83
83
  self["containsInternalObserver"] = (observer) => {
84
84
  return self[internalSymbol].containsObserver(observer);
85
- }
86
-
85
+ };
87
86
 
88
87
  /**
89
88
  * Set an internal value, nested internals can be specified by path `a.b.c`
@@ -95,11 +94,11 @@ function equipWithInternal() {
95
94
  self["setInternal"] = (path, value) => {
96
95
  new Pathfinder(self[internalSymbol].getSubject()).setVia(path, value);
97
96
  return self;
98
- }
97
+ };
99
98
 
100
99
  /**
101
100
  * set multiple internals at once
102
- *
101
+ *
103
102
  * @param {string|object} options
104
103
  * @return {Datasource}
105
104
  * @throws {Error} the options does not contain a valid json definition
@@ -111,7 +110,7 @@ function equipWithInternal() {
111
110
 
112
111
  extend(self[internalSymbol].getSubject(), defaults, options);
113
112
  return self;
114
- }
113
+ };
115
114
 
116
115
  /**
117
116
  * nested internals can be specified by path `a.b.c`
@@ -124,14 +123,12 @@ function equipWithInternal() {
124
123
  let value;
125
124
 
126
125
  try {
127
- value = new Pathfinder(self[internalSymbol]
128
- .getRealSubject()).getVia(path);
129
- } catch (e) {
130
- }
126
+ value = new Pathfinder(self[internalSymbol].getRealSubject()).getVia(path);
127
+ } catch (e) {}
131
128
 
132
129
  if (value === undefined) return defaultValue;
133
130
  return value;
134
- }
131
+ };
135
132
  }
136
133
 
137
134
  /**
@@ -141,9 +138,8 @@ function equipWithInternal() {
141
138
  * @return {boolean}
142
139
  */
143
140
  function hasGetter(obj, prop) {
144
-
145
141
  while (isObject(obj)) {
146
- if (Object.getOwnPropertyDescriptor(obj, prop)?.['get']) {
142
+ if (Object.getOwnPropertyDescriptor(obj, prop)?.["get"]) {
147
143
  return true;
148
144
  }
149
145
  obj = Object.getPrototypeOf(obj);
@@ -168,8 +164,7 @@ function parseOptionsJSON(data) {
168
164
  try {
169
165
  let dataUrl = parseDataURL(data);
170
166
  data = dataUrl.content;
171
- } catch (e) {
172
- }
167
+ } catch (e) {}
173
168
 
174
169
  try {
175
170
  obj = JSON.parse(data);
@@ -142,7 +142,7 @@ function getMonsterVersion() {
142
142
  }
143
143
 
144
144
  /** don't touch, replaced by make with package.json version */
145
- monsterVersion = new Version("3.34.0");
145
+ monsterVersion = new Version("3.35.0");
146
146
 
147
147
  return monsterVersion;
148
148
  }
@@ -5,18 +5,50 @@
5
5
  * License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
6
6
  */
7
7
 
8
- const ENV_AWS_LAMBDA = 'aws-lambda';
9
- const ENV_GOOGLE_FUNCTIONS = 'google-functions';
10
- const ENV_ELECTRON = 'electron';
11
- const ENV_NODE = 'node';
12
- const ENV_BROWSER = 'browser';
13
- const ENV_WEB_WORKER = 'web-worker';
14
- const ENV_DENO = 'deno';
15
- const ENV_UNKNOWN = 'unknown';
8
+ /**
9
+ * @memberOf Monster.Util
10
+ * @type {string}
11
+ */
12
+ const ENV_AWS_LAMBDA = "aws-lambda";
13
+ /**
14
+ * @memberOf Monster.Util
15
+ * @type {string}
16
+ */
17
+ const ENV_GOOGLE_FUNCTIONS = "google-functions";
18
+ /**
19
+ * @memberOf Monster.Util
20
+ * @type {string}
21
+ */
22
+ const ENV_ELECTRON = "electron";
23
+ /**
24
+ * @memberOf Monster.Util
25
+ * @type {string}
26
+ */
27
+ const ENV_NODE = "node";
28
+ /**
29
+ * @memberOf Monster.Util
30
+ * @type {string}
31
+ */
32
+ const ENV_BROWSER = "browser";
33
+ /**
34
+ * @memberOf Monster.Util
35
+ * @type {string}
36
+ */
37
+ const ENV_WEB_WORKER = "web-worker";
38
+ /**
39
+ * @memberOf Monster.Util
40
+ * @type {string}
41
+ */
42
+ const ENV_DENO = "deno";
43
+ /**
44
+ * @memberOf Monster.Util
45
+ * @type {string}
46
+ */
47
+ const ENV_UNKNOWN = "unknown";
16
48
 
17
49
  /**
18
50
  * Detects and returns the current runtime environment.
19
- *
51
+ *
20
52
  * - 'aws-lambda': AWS Lambda environment
21
53
  * - 'google-functions': Google Cloud Functions environment
22
54
  * - 'electron': Electron environment
@@ -26,34 +58,24 @@ const ENV_UNKNOWN = 'unknown';
26
58
  * - 'deno': Deno environment
27
59
  * - 'react-native': React Native environment
28
60
  * - 'unknown': Unknown environment
29
- *
61
+ *
62
+ * @since 3.34.0
63
+ * @memberOf Monster.Util
30
64
  * @returns {string} The detected runtime environment. Possible values are:
31
65
  */
32
66
  function detectRuntimeEnvironment() {
33
67
  // AWS Lambda environment
34
- if (
35
- typeof process !== 'undefined' &&
36
- process.env != null &&
37
- process.env.AWS_LAMBDA_FUNCTION_NAME
38
- ) {
68
+ if (typeof process !== "undefined" && process.env != null && process.env.AWS_LAMBDA_FUNCTION_NAME) {
39
69
  return ENV_AWS_LAMBDA;
40
70
  }
41
71
 
42
72
  // Google Cloud Functions environment
43
- if (
44
- typeof process !== 'undefined' &&
45
- process.env != null &&
46
- process.env.FUNCTION_NAME
47
- ) {
73
+ if (typeof process !== "undefined" && process.env != null && process.env.FUNCTION_NAME) {
48
74
  return ENV_GOOGLE_FUNCTIONS;
49
75
  }
50
76
 
51
77
  // Node.js environment
52
- if (
53
- typeof process !== 'undefined' &&
54
- process.versions != null &&
55
- process.versions.node != null
56
- ) {
78
+ if (typeof process !== "undefined" && process.versions != null && process.versions.node != null) {
57
79
  // Electron environment
58
80
  if (process.versions.electron != null) {
59
81
  return ENV_ELECTRON;
@@ -63,20 +85,20 @@ function detectRuntimeEnvironment() {
63
85
 
64
86
  // Browser environment
65
87
  if (
66
- typeof window !== 'undefined' &&
67
- typeof window.document !== 'undefined' &&
68
- typeof navigator !== 'undefined' &&
69
- typeof navigator.userAgent === 'string'
88
+ typeof window !== "undefined" &&
89
+ typeof window.document !== "undefined" &&
90
+ typeof navigator !== "undefined" &&
91
+ typeof navigator.userAgent === "string"
70
92
  ) {
71
93
  // Web Worker environment
72
- if (typeof self === 'object' && typeof importScripts === 'function') {
94
+ if (typeof self === "object" && typeof importScripts === "function") {
73
95
  return ENV_WEB_WORKER;
74
96
  }
75
97
  return ENV_BROWSER;
76
98
  }
77
99
 
78
100
  // Deno environment
79
- if (typeof Deno !== 'undefined') {
101
+ if (typeof Deno !== "undefined") {
80
102
  return ENV_DENO;
81
103
  }
82
104
 
@@ -93,4 +115,5 @@ export {
93
115
  ENV_WEB_WORKER,
94
116
  ENV_DENO,
95
117
  ENV_UNKNOWN,
96
- detectRuntimeEnvironment}
118
+ detectRuntimeEnvironment,
119
+ };
@@ -7,7 +7,7 @@ describe('Monster', function () {
7
7
  let monsterVersion
8
8
 
9
9
  /** don´t touch, replaced by make with package.json version */
10
- monsterVersion = new Version("3.34.0")
10
+ monsterVersion = new Version("3.35.0")
11
11
 
12
12
  let m = getMonsterVersion();
13
13