-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
7 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |