Skip to content

Commit

Permalink
Simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky committed Mar 6, 2022
1 parent aaab586 commit e83d5a4
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/config/normalize/lib/wild_wild_path/tokens/main.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
import { OTHER_TOKEN_TYPES, getOtherStringTokenType } from './other.js'
import { OTHER_TOKEN_TYPES } from './other.js'
import { PROP_TOKEN } from './prop.js'

// Retrieve the type of a given token parsed object
export const getObjectTokenType = function (token) {
return TOKEN_TYPES.find((tokenType) => tokenType.testObject(token))
}

// Order is significant as they are tested serially
const TOKEN_TYPES = [...OTHER_TOKEN_TYPES, PROP_TOKEN]

// Retrieve the type of a given token serialized string
export const getStringTokenType = function (chars, isProp) {
if (isProp) {
return PROP_TOKEN
}

const tokenType = getOtherStringTokenType(chars)
return tokenType === undefined ? PROP_TOKEN : tokenType
return isProp
? PROP_TOKEN
: TOKEN_TYPES.find((tokenType) => tokenType.testString(chars))
}

// Order is significant as they are tested serially
const TOKEN_TYPES = [...OTHER_TOKEN_TYPES, PROP_TOKEN]

0 comments on commit e83d5a4

Please sign in to comment.