ex_yarn v0.4.1 ExYarn.Token View Source

A token is the building block of a lockfile (intended for internal use only)

This module takes a lockfile's contents as input and breaks it up into a list of tokens, each of them representing a single discrete element of the lockfile.

Tokens represent every piece that makes up a lockfile, from comments, strings and integers to line returns, colons and indentation.

Link to this section Summary

Types

t()

The representation of a token

The list of types a token can have

Functions

Main entrypoint for the module. Takes as input a String representing the contents of a yarn lockfile and returns the corresponding list of tokens.

Takes a ExYarn.Parser.Token as an input and returns a boolean indicating whether or not it can be used as a value for a key

Link to this section Types

Specs

t() :: %ExYarn.Token{
  col: integer(),
  line: integer(),
  type: tokenType(),
  value: any()
}

The representation of a token

Specs

tokenType() ::
  :boolean
  | :string
  | :identifier
  | :eof
  | :colon
  | :new_line
  | :comment
  | :indent
  | :invalid
  | :number
  | :comma

The list of types a token can have

Link to this section Functions

Specs

tokenize(String.t()) :: [t()]

Main entrypoint for the module. Takes as input a String representing the contents of a yarn lockfile and returns the corresponding list of tokens.

Link to this function

valid_prop_value?(token)

View Source

Specs

valid_prop_value?(t()) :: boolean()

Takes a ExYarn.Parser.Token as an input and returns a boolean indicating whether or not it can be used as a value for a key