@lowdefy/operators 3.22.0 → 4.0.0-alpha.1

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 (75) hide show
  1. package/dist/common/and.js +8 -24
  2. package/dist/common/args.js +10 -31
  3. package/dist/common/array.js +244 -153
  4. package/dist/common/change_case.js +114 -160
  5. package/dist/common/date.js +33 -54
  6. package/dist/common/divide.js +16 -36
  7. package/dist/common/eq.js +10 -28
  8. package/dist/common/function.js +27 -59
  9. package/dist/common/get.js +21 -46
  10. package/dist/common/gt.js +10 -28
  11. package/dist/common/gte.js +10 -28
  12. package/dist/common/if.js +9 -26
  13. package/dist/common/if_none.js +13 -32
  14. package/dist/common/index.js +39 -53
  15. package/dist/common/json.js +53 -57
  16. package/dist/common/log.js +5 -18
  17. package/dist/common/lt.js +10 -28
  18. package/dist/common/lte.js +10 -28
  19. package/dist/common/math.js +255 -194
  20. package/dist/common/mql.js +93 -102
  21. package/dist/common/ne.js +10 -28
  22. package/dist/common/not.js +3 -16
  23. package/dist/common/number.js +130 -108
  24. package/dist/common/nunjucks.js +24 -44
  25. package/dist/common/object.js +89 -98
  26. package/dist/common/operator.js +33 -44
  27. package/dist/common/or.js +8 -24
  28. package/dist/common/product.js +11 -29
  29. package/dist/common/random.js +74 -109
  30. package/dist/common/regex.js +26 -49
  31. package/dist/common/string.js +270 -171
  32. package/dist/common/subtract.js +13 -32
  33. package/dist/common/sum.js +11 -29
  34. package/dist/common/switch.js +30 -0
  35. package/dist/common/type.js +36 -67
  36. package/dist/common/uri.js +29 -46
  37. package/dist/common/user.js +10 -35
  38. package/dist/common/uuid.js +48 -59
  39. package/dist/common/yaml.js +56 -63
  40. package/dist/getFromArray.js +22 -44
  41. package/dist/getFromObject.js +25 -70
  42. package/dist/index.js +14 -20
  43. package/dist/node/base64.js +31 -48
  44. package/dist/node/diff.js +30 -47
  45. package/dist/node/hash.js +55 -71
  46. package/dist/node/index.js +6 -14
  47. package/dist/{web/list_contexts.js → node/payload.js} +9 -16
  48. package/dist/node/secret.js +32 -53
  49. package/dist/nodeParser.js +95 -146
  50. package/dist/runClass.js +57 -82
  51. package/dist/runInstance.js +60 -84
  52. package/dist/web/_index.js +25 -0
  53. package/dist/web/actions.js +10 -31
  54. package/dist/web/base64.js +29 -46
  55. package/dist/{common/_index.js → web/event.js} +10 -30
  56. package/dist/web/event_log.js +10 -35
  57. package/dist/web/format.js +15 -37
  58. package/dist/web/global.js +25 -0
  59. package/dist/web/index.js +17 -21
  60. package/dist/{common/event.js → web/input.js} +10 -31
  61. package/dist/web/js.js +10 -30
  62. package/dist/web/location.js +44 -59
  63. package/dist/web/media.js +46 -75
  64. package/dist/web/menu.js +10 -28
  65. package/dist/web/request.js +19 -40
  66. package/dist/web/request_details.js +10 -35
  67. package/dist/web/state.js +25 -0
  68. package/dist/web/url_query.js +25 -0
  69. package/dist/webParser.js +115 -157
  70. package/package.json +16 -15
  71. package/dist/common/global.js +0 -50
  72. package/dist/common/input.js +0 -50
  73. package/dist/common/state.js +0 -50
  74. package/dist/common/url_query.js +0 -50
  75. package/dist/getFromOtherContext.js +0 -96
@@ -1,14 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _runClass = _interopRequireDefault(require("../runClass"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
1
  /*
13
2
  Copyright 2020-2021 Lowdefy, Inc
14
3
 
@@ -23,45 +12,39 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
13
  See the License for the specific language governing permissions and
25
14
  limitations under the License.
26
- */
15
+ */ import runClass from '../runClass.js';
27
16
  function decode(input) {
28
- return atob(input);
17
+ return atob(input);
29
18
  }
30
-
31
19
  function encode(input) {
32
- return btoa(input);
20
+ return btoa(input);
33
21
  }
34
-
35
- var functions = {
36
- encode,
37
- decode
22
+ const functions = {
23
+ encode,
24
+ decode
38
25
  };
39
- var meta = {
40
- encode: {
41
- singleArg: true,
42
- validTypes: ['string']
43
- },
44
- decode: {
45
- singleArg: true,
46
- validTypes: ['string']
47
- }
26
+ const meta = {
27
+ encode: {
28
+ singleArg: true,
29
+ validTypes: [
30
+ 'string'
31
+ ]
32
+ },
33
+ decode: {
34
+ singleArg: true,
35
+ validTypes: [
36
+ 'string'
37
+ ]
38
+ }
48
39
  };
49
-
50
- function _base64(_ref) {
51
- var {
52
- params,
53
- location,
54
- methodName
55
- } = _ref;
56
- return (0, _runClass.default)({
57
- functions,
58
- location,
59
- meta,
60
- methodName,
61
- operator: '_base64',
62
- params
63
- });
40
+ function _base64({ params , location , methodName }) {
41
+ return runClass({
42
+ functions,
43
+ location,
44
+ meta,
45
+ methodName,
46
+ operator: '_base64',
47
+ params
48
+ });
64
49
  }
65
-
66
- var _default = _base64;
67
- exports.default = _default;
50
+ export default _base64;
@@ -1,14 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
1
  /*
13
2
  Copyright 2020-2021 Lowdefy, Inc
14
3
 
@@ -23,23 +12,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
13
  See the License for the specific language governing permissions and
25
14
  limitations under the License.
26
- */
27
- function _index(_ref) {
28
- var {
29
- arrayIndices,
30
- env,
31
- location,
32
- params
33
- } = _ref;
34
- return (0, _getFromObject.default)({
35
- arrayIndices,
36
- env,
37
- location,
38
- object: arrayIndices,
39
- operator: '_index',
40
- params
41
- });
15
+ */ import getFromObject from '../getFromObject.js';
16
+ function _event({ arrayIndices , event , location , params }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: event,
21
+ operator: '_event',
22
+ params
23
+ });
42
24
  }
43
-
44
- var _default = _index;
45
- exports.default = _default;
25
+ export default _event;
@@ -1,14 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
1
  /*
13
2
  Copyright 2020-2021 Lowdefy, Inc
14
3
 
@@ -23,28 +12,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
13
  See the License for the specific language governing permissions and
25
14
  limitations under the License.
26
- */
27
- function _event_log(_ref) {
28
- var {
29
- params,
30
- eventLog,
31
- context,
32
- contexts,
33
- arrayIndices,
34
- location,
35
- env
36
- } = _ref;
37
- return (0, _getFromObject.default)({
38
- arrayIndices,
39
- context,
40
- contexts,
41
- env,
42
- location,
43
- object: eventLog,
44
- operator: '_event_log',
45
- params
46
- });
15
+ */ import getFromObject from '../getFromObject.js';
16
+ function _event_log({ arrayIndices , eventLog , location , params }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: eventLog,
21
+ operator: '_event_log',
22
+ params
23
+ });
47
24
  }
48
-
49
- var _default = _event_log;
50
- exports.default = _default;
25
+ export default _event_log;
@@ -1,16 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _helpers = require("@lowdefy/helpers");
9
-
10
- var _format2 = _interopRequireDefault(require("@lowdefy/format"));
11
-
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
1
  /*
15
2
  Copyright 2020-2021 Lowdefy, Inc
16
3
 
@@ -25,28 +12,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
25
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
13
  See the License for the specific language governing permissions and
27
14
  limitations under the License.
28
- */
29
- function _format(_ref) {
30
- var {
31
- location,
32
- methodName,
33
- params
34
- } = _ref;
35
-
36
- if (!_format2.default[methodName]) {
37
- throw new Error("Operator Error: $_format.".concat(methodName, " is not supported, use one of the following: ").concat(Object.keys(_format2.default).join(', '), ".\n Received: {\"_format.").concat(methodName, "\":").concat(JSON.stringify(params), "} at ").concat(location, "."));
38
- }
39
-
40
- if (!_helpers.type.isObject(params)) {
41
- throw new Error("Operator Error: _format takes an object as arguments. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
42
- }
43
-
44
- if (!_helpers.type.isObject(params.params) && !_helpers.type.isUndefined(params.params)) {
45
- throw new Error("Operator Error: _format params argument should be an object or undefined. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
46
- }
47
-
48
- return _format2.default[methodName](params.params)(params.on);
15
+ */ import { type } from '@lowdefy/helpers';
16
+ import formatters from '@lowdefy/format';
17
+ function _format({ location , methodName , params }) {
18
+ if (!formatters[methodName]) {
19
+ throw new Error(`Operator Error: $_format.${methodName} is not supported, use one of the following: ${Object.keys(formatters).join(', ')}.
20
+ Received: {"_format.${methodName}":${JSON.stringify(params)}} at ${location}.`);
21
+ }
22
+ if (!type.isObject(params)) {
23
+ throw new Error(`Operator Error: _format takes an object as arguments. Received: ${JSON.stringify(params)} at ${location}.`);
24
+ }
25
+ if (!type.isObject(params.params) && !type.isUndefined(params.params)) {
26
+ throw new Error(`Operator Error: _format params argument should be an object or undefined. Received: ${JSON.stringify(params)} at ${location}.`);
27
+ }
28
+ return formatters[methodName](params.params)(params.on);
49
29
  }
50
-
51
- var _default = _format;
52
- exports.default = _default;
30
+ export default _format;
@@ -0,0 +1,25 @@
1
+ /*
2
+ Copyright 2020-2021 Lowdefy, Inc
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */ import getFromObject from '../getFromObject.js';
16
+ function _global({ arrayIndices , location , lowdefyGlobal , params }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: lowdefyGlobal,
21
+ operator: '_global',
22
+ params
23
+ });
24
+ }
25
+ export default _global;
package/dist/web/index.js CHANGED
@@ -1,10 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
1
  /*
9
2
  Copyright 2020-2021 Lowdefy, Inc
10
3
 
@@ -19,18 +12,21 @@ exports.default = void 0;
19
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
13
  See the License for the specific language governing permissions and
21
14
  limitations under the License.
22
- */
23
- var _default = {
24
- _actions: 'web/actions',
25
- _event_log: 'web/event_log',
26
- _base64: 'web/base64',
27
- _format: 'web/format',
28
- _list_contexts: 'web/list_contexts',
29
- _location: 'web/location',
30
- _js: 'web/js',
31
- _media: 'web/media',
32
- _menu: 'web/menu',
33
- _request_details: 'web/request_details',
34
- _request: 'web/request'
15
+ */ export default {
16
+ _actions: 'web/actions',
17
+ _base64: 'web/base64',
18
+ _event_log: 'web/event_log',
19
+ _event: 'web/event',
20
+ _format: 'web/format',
21
+ _global: 'web/global',
22
+ _index: 'web/_index',
23
+ _input: 'web/input',
24
+ _js: 'web/js',
25
+ _location: 'web/location',
26
+ _media: 'web/media',
27
+ _menu: 'web/menu',
28
+ _request_details: 'web/request_details',
29
+ _request: 'web/request',
30
+ _state: 'web/state',
31
+ _url_query: 'web/url_query'
35
32
  };
36
- exports.default = _default;
@@ -1,14 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
1
  /*
13
2
  Copyright 2020-2021 Lowdefy, Inc
14
3
 
@@ -23,24 +12,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
13
  See the License for the specific language governing permissions and
25
14
  limitations under the License.
26
- */
27
- function _event(_ref) {
28
- var {
29
- arrayIndices,
30
- env,
31
- event,
32
- location,
33
- params
34
- } = _ref;
35
- return (0, _getFromObject.default)({
36
- arrayIndices,
37
- env,
38
- location,
39
- object: event,
40
- operator: '_event',
41
- params
42
- });
15
+ */ import getFromObject from '../getFromObject.js';
16
+ function _input({ arrayIndices , input , location , params }) {
17
+ return getFromObject({
18
+ arrayIndices,
19
+ location,
20
+ object: input,
21
+ operator: '_input',
22
+ params
23
+ });
43
24
  }
44
-
45
- var _default = _event;
46
- exports.default = _default;
25
+ export default _input;
package/dist/web/js.js CHANGED
@@ -1,12 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _helpers = require("@lowdefy/helpers");
9
-
10
1
  /*
11
2
  Copyright 2020-2021 Lowdefy, Inc
12
3
 
@@ -21,25 +12,14 @@ var _helpers = require("@lowdefy/helpers");
21
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
13
  See the License for the specific language governing permissions and
23
14
  limitations under the License.
24
- */
25
- function _js(_ref) {
26
- var {
27
- context,
28
- params,
29
- location,
30
- methodName
31
- } = _ref;
32
-
33
- if (!_helpers.type.isFunction(context.lowdefy.imports.jsOperators[methodName])) {
34
- throw new Error("Operator Error: _js.".concat(methodName, " is not a function."));
35
- }
36
-
37
- if (!_helpers.type.isNone(params) && !_helpers.type.isArray(params)) {
38
- throw new Error("Operator Error: _js.".concat(methodName, " takes an array as input at ").concat(location, "."));
39
- }
40
-
41
- return context.lowdefy.imports.jsOperators[methodName](...(params || []));
15
+ */ import { type } from '@lowdefy/helpers';
16
+ function _js({ context , params , location , methodName }) {
17
+ if (!type.isFunction(context.lowdefy.imports.jsOperators[methodName])) {
18
+ throw new Error(`Operator Error: _js.${methodName} is not a function.`);
19
+ }
20
+ if (!type.isNone(params) && !type.isArray(params)) {
21
+ throw new Error(`Operator Error: _js.${methodName} takes an array as input at ${location}.`);
22
+ }
23
+ return context.lowdefy.imports.jsOperators[methodName](...params || []);
42
24
  }
43
-
44
- var _default = _js;
45
- exports.default = _default;
25
+ export default _js;
@@ -1,14 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
1
  /*
13
2
  Copyright 2020-2021 Lowdefy, Inc
14
3
 
@@ -23,52 +12,48 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
13
  See the License for the specific language governing permissions and
25
14
  limitations under the License.
26
- */
27
- var validProperties = ['basePath', 'href', 'origin', 'protocol', 'homePageId', 'host', 'hostname', 'port', 'pageId', 'pathname', 'search', 'hash'];
28
-
29
- function _location(_ref) {
30
- var {
31
- arrayIndices,
32
- context,
33
- contexts,
34
- env,
35
- location,
36
- params
37
- } = _ref;
38
-
39
- if (!window || !window.location) {
40
- throw new Error("Operator Error: Browser window.location not available for _location. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
41
- }
42
-
43
- if (!validProperties.includes(params)) {
44
- throw new Error("Operator Error: _location only returns values for ".concat(validProperties.join(', '), ". Received: ").concat(JSON.stringify(params), " at ").concat(location, "."));
45
- }
46
-
47
- var windowLocation = {
48
- basePath: context.lowdefy.basePath,
49
- href: window.location.href,
50
- origin: window.location.origin,
51
- protocol: window.location.protocol,
52
- homePageId: context.lowdefy.homePageId,
53
- host: window.location.host,
54
- hostname: window.location.hostname,
55
- port: window.location.port,
56
- pageId: context.lowdefy.pageId,
57
- pathname: window.location.pathname,
58
- search: window.location.search,
59
- hash: window.location.hash
60
- };
61
- return (0, _getFromObject.default)({
62
- arrayIndices,
63
- context,
64
- contexts,
65
- env,
66
- location,
67
- object: windowLocation,
68
- operator: '_location',
69
- params
70
- });
15
+ */ import getFromObject from '../getFromObject.js';
16
+ const validProperties = [
17
+ 'basePath',
18
+ 'href',
19
+ 'origin',
20
+ 'protocol',
21
+ 'homePageId',
22
+ 'host',
23
+ 'hostname',
24
+ 'port',
25
+ 'pageId',
26
+ 'pathname',
27
+ 'search',
28
+ 'hash',
29
+ ];
30
+ function _location({ arrayIndices , context , location , params }) {
31
+ if (!window || !window.location) {
32
+ throw new Error(`Operator Error: Browser window.location not available for _location. Received: ${JSON.stringify(params)} at ${location}.`);
33
+ }
34
+ if (!validProperties.includes(params)) {
35
+ throw new Error(`Operator Error: _location only returns values for ${validProperties.join(', ')}. Received: ${JSON.stringify(params)} at ${location}.`);
36
+ }
37
+ const windowLocation = {
38
+ basePath: context.lowdefy.basePath,
39
+ href: window.location.href,
40
+ origin: window.location.origin,
41
+ protocol: window.location.protocol,
42
+ homePageId: context.lowdefy.homePageId,
43
+ host: window.location.host,
44
+ hostname: window.location.hostname,
45
+ port: window.location.port,
46
+ pageId: context.lowdefy.pageId,
47
+ pathname: window.location.pathname,
48
+ search: window.location.search,
49
+ hash: window.location.hash
50
+ };
51
+ return getFromObject({
52
+ arrayIndices,
53
+ location,
54
+ object: windowLocation,
55
+ operator: '_location',
56
+ params
57
+ });
71
58
  }
72
-
73
- var _default = _location;
74
- exports.default = _default;
59
+ export default _location;
package/dist/web/media.js CHANGED
@@ -1,14 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.breakpoints = void 0;
7
-
8
- var _getFromObject = _interopRequireDefault(require("../getFromObject"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
1
  /*
13
2
  Copyright 2020-2021 Lowdefy, Inc
14
3
 
@@ -23,68 +12,50 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
23
12
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
13
  See the License for the specific language governing permissions and
25
14
  limitations under the License.
26
- */
27
- var breakpoints = [576, 768, 992, 1200, 1600];
28
- exports.breakpoints = breakpoints;
29
-
30
- function _media(_ref) {
31
- var {
32
- arrayIndices,
33
- context,
34
- contexts,
35
- env,
36
- location,
37
- params
38
- } = _ref;
39
-
40
- if (!window || !window.innerWidth) {
41
- throw new Error("Operator Error: device window width not available for _media. Received: ".concat(JSON.stringify(params), " at ").concat(location, "."));
42
- }
43
-
44
- var size;
45
-
46
- switch (true) {
47
- case window.innerWidth < breakpoints[0]:
48
- size = 'xs';
49
- break;
50
-
51
- case window.innerWidth < breakpoints[1]:
52
- size = 'sm';
53
- break;
54
-
55
- case window.innerWidth < breakpoints[2]:
56
- size = 'md';
57
- break;
58
-
59
- case window.innerWidth < breakpoints[3]:
60
- size = 'lg';
61
- break;
62
-
63
- case window.innerWidth < breakpoints[4]:
64
- size = 'xl';
65
- break;
66
-
67
- default:
68
- size = 'xxl';
69
- break;
70
- }
71
-
72
- var media = {
73
- size,
74
- width: window.innerWidth,
75
- height: window.innerHeight
76
- };
77
- return (0, _getFromObject.default)({
78
- arrayIndices,
79
- context,
80
- contexts,
81
- env,
82
- location,
83
- object: media,
84
- operator: '_media',
85
- params
86
- });
15
+ */ import getFromObject from '../getFromObject.js';
16
+ const breakpoints = {
17
+ xs: 576,
18
+ sm: 768,
19
+ md: 992,
20
+ lg: 1200,
21
+ xl: 1600
22
+ };
23
+ function _media({ arrayIndices , location , params }) {
24
+ if (!window || !window.innerWidth) {
25
+ throw new Error(`Operator Error: device window width not available for _media. Received: ${JSON.stringify(params)} at ${location}.`);
26
+ }
27
+ let size;
28
+ switch(true){
29
+ case window.innerWidth < breakpoints.xs:
30
+ size = 'xs';
31
+ break;
32
+ case window.innerWidth < breakpoints.sm:
33
+ size = 'sm';
34
+ break;
35
+ case window.innerWidth < breakpoints.md:
36
+ size = 'md';
37
+ break;
38
+ case window.innerWidth < breakpoints.lg:
39
+ size = 'lg';
40
+ break;
41
+ case window.innerWidth < breakpoints.xl:
42
+ size = 'xl';
43
+ break;
44
+ default:
45
+ size = 'xxl';
46
+ break;
47
+ }
48
+ const media = {
49
+ size,
50
+ width: window.innerWidth,
51
+ height: window.innerHeight
52
+ };
53
+ return getFromObject({
54
+ arrayIndices,
55
+ location,
56
+ object: media,
57
+ operator: '_media',
58
+ params
59
+ });
87
60
  }
88
-
89
- var _default = _media;
90
- exports.default = _default;
61
+ export default _media;