Dartlings is a collection of various tiny yet useful libraries in Dart. Each dartling is a one-file library that typically doesn't span over more than 100 or 200 lines; everything else is out of scope of Dartlings.
Range is a
Collection<int> that iterates from a specified number
to another (greater) specified number. Optionally, you can specify
the step of iteration.
var r = new Range(0, 10);
ranges from 0 to 10 inclusive. I.e., it iterates over these numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10.
If you specify a step,
var r = new Range(0, 10, step: 2);
you will only get 0, 2, 4, 6, 8 and 10.
Additionally, there is a function
range which creates a
step 1. By default, the
start value is inclusive and
end is exclusive.
var r = range(0, 10);
will only iterate from 0 to 9. It accepts optional
which controls the
end value, so that
var r = range(0, 10, inclusive: true);
iterates from 0 to 10.
ANSI terminal (
Tiny library for colored output on ANSI terminals. Only provides a handful
of functions that takes a
String (or any object, actually) and returns
its colored variant that can be sent to the terminal.
These functions have descriptive names:
print(red("this will be red"));
There's also one constant called
lineBegin which is useful when writing
some single-line temporary information that should be later overwritten.
It only returns cursor to the beginning of the line and clears it, so it only
makes sense if the temporary information didn't contain any line terminators.
This can easily be achieved by using
Usage looks like:
stdout.writeString("> Running some heavy computation..."); // and later stdout.writeString(lineBegin); print(green("Done!"));