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

Commit

Permalink
Do not use Object.values.
Browse files Browse the repository at this point in the history
Fixes gh-203
  • Loading branch information
paularmstrong committed Jan 3, 2017
1 parent a40e638 commit d8bfc2a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/schemas/Array.js
Expand Up @@ -9,10 +9,12 @@ const validateSchema = (definition) => {
return definition[0];
};

const getValues = (input) => Array.isArray(input) ? input : Object.keys(input).map((key) => input[key]);

export const normalize = (schema, input, parent, key, visit, addEntity) => {
schema = validateSchema(schema);

const values = Array.isArray(input) ? input : Object.values(input);
const values = getValues(input);

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

export default class ArraySchema extends PolymorphicSchema {
normalize(input, parent, key, visit, addEntity) {
const values = Array.isArray(input) ? input : Object.values(input);
const values = getValues(input);

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

0 comments on commit d8bfc2a

Please sign in to comment.