Skip to content
This repository was archived by the owner on Mar 20, 2022. It is now read-only.

Commit d8bfc2a

Browse files
committed
Do not use Object.values.
Fixes gh-203
1 parent a40e638 commit d8bfc2a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/schemas/Array.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ const validateSchema = (definition) => {
99
return definition[0];
1010
};
1111

12+
const getValues = (input) => Array.isArray(input) ? input : Object.keys(input).map((key) => input[key]);
13+
1214
export const normalize = (schema, input, parent, key, visit, addEntity) => {
1315
schema = validateSchema(schema);
1416

15-
const values = Array.isArray(input) ? input : Object.values(input);
17+
const values = getValues(input);
1618

1719
// Special case: Arrays pass *their* parent on to their children, since there
1820
// is not any special information that can be gathered from themselves directly
@@ -21,7 +23,7 @@ export const normalize = (schema, input, parent, key, visit, addEntity) => {
2123

2224
export default class ArraySchema extends PolymorphicSchema {
2325
normalize(input, parent, key, visit, addEntity) {
24-
const values = Array.isArray(input) ? input : Object.values(input);
26+
const values = getValues(input);
2527

2628
return values.map((value, index) => this.normalizeValue(value, parent, key, visit, addEntity))
2729
.filter((value) => value !== undefined && value !== null);

0 commit comments

Comments
 (0)