1 | const isSet = obj => obj instanceof Set;
|
2 |
|
3 | function optionalSet(props, propName, componentName) {
|
4 | const prop = props[propName];
|
5 | const type = typeof prop;
|
6 |
|
7 | if (prop != null && !isSet(prop)) {
|
8 | return new Error(
|
9 | `Invalid prop \`${propName}\` of type \`${type}\` supplied to \`${componentName}\`, expected \`Set\`.`
|
10 | );
|
11 | }
|
12 | }
|
13 |
|
14 | function requiredSet(props, propName, componentName) {
|
15 | const prop = props[propName];
|
16 | const type = typeof prop;
|
17 |
|
18 | if (prop == null || !isSet(prop)) {
|
19 | return new Error(
|
20 | `Invalid prop \`${propName}\` of type \`${type}\` supplied to \`${componentName}\`, expected \`Set\`.`
|
21 | );
|
22 | }
|
23 | }
|
24 |
|
25 | optionalSet.isRequired = requiredSet;
|
26 |
|
27 | export default optionalSet;
|