minify/src/ef6438c4-76db-4aa1-bb15-bc9...
Robot e23917c5e1
update 2024-04-07 13:20:18
2024-04-07 13:20:29 +02:00
..
README.md update 2023-10-24 10:36:32 2023-10-24 10:36:42 +02:00
code.php first commit 2023-04-15 16:58:37 +02:00
code.power first commit 2023-04-15 16:58:37 +02:00
settings.json update 2024-04-07 13:20:18 2024-04-07 13:20:29 +02:00

README.md

██████╗  ██████╗ ██╗    ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║    ██║██╔════╝██╔══██╗
██████╔╝██║   ██║██║ █╗ ██║█████╗  ██████╔╝
██╔═══╝ ██║   ██║██║███╗██║██╔══╝  ██╔══██╗
██║     ╚██████╔╝╚███╔███╔╝███████╗██║  ██║
╚═╝      ╚═════╝  ╚══╝╚══╝ ╚══════╝╚═╝  ╚═╝

class JavaScript (Details)

namespace: VDM\Minify extends: Minify

@startuml
class JavaScript  #Gold {
  # $keywordsReserved
  # $keywordsBefore
  # $keywordsAfter
  # $operatorsBefore
  + execute(string[optional] $path = null) : string
  # stripComments()
  # extractRegex()
  # stripWhitespace(string $content) : string
  # getOperatorsForRegex(array $operators, string $delimiter = '/') : string[]
  # getKeywordsForRegex(array $keywords, string $delimiter = '/') : string[]
  # propertyNotation(string $content) : string
  # shortenBools(string $content) : string
}

note right of JavaScript::execute
  Minify the data.
Perform JS optimizations.

  return: string
end note

note left of JavaScript::stripComments
  Strip comments from source code.

end note

note right of JavaScript::extractRegex
  JS can have /-delimited regular expressions, like: /ab+c/.match(string).
The content inside the regex can contain characters that may be confused
for JS code: e.g. it could contain whitespace it needs to match & we
don't want to strip whitespace in there.
The regex can be pretty simple: we don't have to care about comments,
(which also use slashes) because stripComments() will have stripped those
already.
This method will replace all string content with simple REGEX#
placeholder text, so we've rid all regular expressions from characters
that may be misinterpreted. Original regex content will be saved in
$this->extracted and after doing all other minifying, we can restore the
original content via restoreRegex()

end note

note left of JavaScript::stripWhitespace
  Strip whitespace.
We won't strip *all* whitespace, but as much as possible. The thing that
we'll preserve are newlines we're unsure about.
JavaScript doesn't require statements to be terminated with a semicolon.
It will automatically fix missing semicolons with ASI (automatic semi-
colon insertion) at the end of line causing errors (without semicolon.)
Because it's sometimes hard to tell if a newline is part of a statement
that should be terminated or not, we'll just leave some of them alone.

  return: string
end note

note right of JavaScript::getOperatorsForRegex
  We'll strip whitespace around certain operators with regular expressions.
This will prepare the given array by escaping all characters.

  return: string[]
end note

note left of JavaScript::getKeywordsForRegex
  We'll strip whitespace around certain keywords with regular expressions.
This will prepare the given array by escaping all characters.

  return: string[]
end note

note right of JavaScript::propertyNotation
  Replaces all occurrences of array['key'] by array.key.

  return: string
end note

note left of JavaScript::shortenBools
  Replaces true & false by !0 and !1.

  return: string
end note
 
@enduml

     ██╗ ██████╗██████╗
     ██║██╔════╝██╔══██╗
     ██║██║     ██████╔╝
██   ██║██║     ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
 ╚════╝  ╚═════╝╚═════╝

Build with Joomla Component Builder