EzScala is a Scala library that helps write Scala easier.
It provides the following features:
- Extension methods
- Operators
&&
: AND operator for Truthy/Falsy value||
: OR operator for Truthy/Falsy value|
: map left value to another value, by right function- For
String
: write string in UTF-8 encoding to aFile
orOutputStream
- For
Array[Byte]
,Iterator[Byte]
,Iterable[Byte]
,InputStream
: write bytes in UTF-8 encoding to aFile
orOutputStream
- For
|=
: call right function, and return left value|==
: assert left value is true, or throw AssertionError|>
: alias ofIterable.map
,Iterator.map
|>|
: alias ofIterable.flatmap
,Iterator.flatmap
|?
: alias ofIterable.filter
,Iterator.filter
|!=
: alias ofIterable.tapeach
,Iterator.tapeach
|!
: alias ofIterable.foreach
,Iterator.foreach
String
:bytes
: get UTF-8 encoded bytes of Stringfind
,find1
,find2
,find3
: find substring by regular expression, and return found substring, or group 1/2/3replace
,replaceAll
: replace substring by regular expressionfile
: use this string as file path to create aFile
objecthttp
: use this string as URL to create a Http requestHttpRequestData
object. See IO section
Array[Byte]
string
: UTF-8 decode to Stringbase64
: Base64 encode to Stringbase64Url
: Base64 encode to String, with URL safe
- IO operations
AutoClosable
use
: consume resource, and auto close it
File
bytes
: return all bytes as aArray[Byte]
/
: resolve child item in directoryparent
: resolve parent directory
InputStream
bytes
: return all bytes as aArray[Byte]
HttpRequestData
:header
: add http request header to requestget
,post
: send HTTP Get/Post request, and return aHttpResponseWrapper
HttpResponseWrapper
:close
: implementation ofAutoClosable
statusCode
: return status code of HTTP responsewithStream
: call a function with anInputStream
of HTTP responsebytes
: return all bytes as aArray[Byte]
text
: return http response content as UTF-8 String
- OS interaction
os.run
: run a command line, check its return status, and return its output as Stringos.sh
: run a command line in shell, check its return status, and return its output as String
- Operators