Tokenizer

object Tokenizer

Utility class to convert a NPM requirement string into a list of tokens.

Types

Token
Link copied to clipboard
class Token(type: Tokenizer.TokenType, value: String?)
A token in a requirement string.
TokenType
Link copied to clipboard
enum TokenType : Enum<Tokenizer.TokenType>
The different types of tokens (unary operators, binary operators, delimiters and versions)

Functions

tokenize
Link copied to clipboard
fun tokenize(requirement: String, type: Semver.SemverType): List<Tokenizer.Token?>
Takes a NPM requirement string and creates a list of tokens by performing 3 operations:
  • If the token is a version, it will add the version string

  • If the token is an operator, it will add the operator

  • It will insert missing "AND" operators for ranges