Skip to content

Commit

Permalink
refactor: Move getTypeDefNames inline
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 15, 2020
1 parent 884de82 commit 289514d
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions plugins/gatsby-source-newrelic-sdk/src/typeDefInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ const IGNORED_TYPE_DEFS = [

const flatten = (arr) => [].concat(...arr);

const getTypeDefNames = (tags) => {
return flatten(Object.values(tags))
.flatMap((tag) => [tag.type, tag.promiseType])
.filter(Boolean)
.filter((tag) => !IGNORED_TYPE_DEFS.includes(tag))
.map((tag) => tag.replace(/\[\]$/, '')); // TimePickerRange[] => TimePickerRange
};

exports.getTypeDefs = (properties, sdk) => {
return properties
.map((property) => property && property.__docs__ && property.__docs__.tags)
.filter(Boolean)
.flatMap(getTypeDefNames)
.flatMap((tags) => flatten(Object.values(tags)))
.flatMap((tag) => [tag.type, tag.promiseType])
.filter(Boolean)
.filter((name) => !IGNORED_TYPE_DEFS.includes(name))
.map((name) => name.replace(/\[\]$/, '')) // TimePickerRange[] => TimePickerRange
.map((name) => sdk.__typeDefs__[name])
.filter((typeDef) => typeDef !== undefined)
.map((typeDef) => ({
Expand Down

0 comments on commit 289514d

Please sign in to comment.