1 | import _typeof from "@babel/runtime/helpers/typeof";
|
2 |
|
3 | var isIterable = function isIterable(obj) {
|
4 | return typeof obj[Symbol.iterator] === 'function';
|
5 | };
|
6 |
|
7 | function optionalIterable(props, propName, componentName) {
|
8 | var prop = props[propName];
|
9 |
|
10 | var type = _typeof(prop);
|
11 |
|
12 | if (prop != null && !isIterable(prop)) {
|
13 | return new Error("Invalid prop `".concat(propName, "` of type `").concat(type, "` supplied to `").concat(componentName, "`, expected `iterable`."));
|
14 | }
|
15 | }
|
16 |
|
17 | function requiredIterable(props, propName, componentName) {
|
18 | var prop = props[propName];
|
19 |
|
20 | var type = _typeof(prop);
|
21 |
|
22 | if (prop == null || !isIterable(prop)) {
|
23 | return new Error("Invalid prop `".concat(propName, "` of type `").concat(type, "` supplied to `").concat(componentName, "`, expected `iterable`."));
|
24 | }
|
25 | }
|
26 |
|
27 | optionalIterable.isRequired = requiredIterable;
|
28 | export default optionalIterable;
|
29 |
|
\ | No newline at end of file |