UNPKG

918 BJavaScriptView Raw
1import _typeof from "@babel/runtime/helpers/typeof";
2
3var isIterable = function isIterable(obj) {
4 return typeof obj[Symbol.iterator] === 'function';
5};
6
7function 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
17function 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
27optionalIterable.isRequired = requiredIterable;
28export default optionalIterable;
29//# sourceMappingURL=iterable.js.map
\No newline at end of file