Releases: pskfyi/handy
0.4.0
Continuous Integration
-
preview release notes; closes #17 (5d0211e)
See the example here from the very PR which implemented this feature.
Features
-
(parser): init (056852f)
Parser combinator libraries provide composable parsers used together to construct more complex parsers. This first draft is robust enough for simple DSLs. Notably it does not implement backtracking or a chain combinator, which would allow for more advanced branching. However the TS implementation is very powerful, capable of inferring the return types from complex parsers without explicit compiler hints in userland.
show/hide
The following is a brief overview of the features added. Additionally, the four existing parsers in the repository were re-written using the library - they can serve as examples and documentation, in addition to robust JSDoc comments and test suites.
-
The base
Parser
class implements core helper methods like.fallback()
,into()
,.not()
,.and()
,.or()
,.optional
,.ignore
, and.zeroOrMore
. -
Shorthand factory
string()
makes it easy to construct a Parser from one or more strings. -
ArrayParser
with shorthand factorysequence()
provides a specializedParser
with array-specific.flat
,.item()
,.items()
,.join()
, and.toObject()
, and specialized handling for parser-like inputs and ignored parsers. -
RegExpParser
with shorthand factoryregexp()
provides a specializedParser
around one or more RegExp patterns, with RegExp-specific.match
,.group()
, and.groups()
methods. -
Common helpers like
whitespace
,blankLine
, andend
are provided. Some are re-exported underline
(ex.line.blank
) andwhitespace
(ex.whitespace.inline
) for convenience.
-
-
(string): add
Text
; replacelocation()
; closes #89 (a759626)show/hide
The
Text
class wraps a string value as a body of text such as a text file's contents, with special considerations for lines, line numbers, and column numbers.-
The input
Text
value can be accessed via.value
or.input
getters. The internal value is immutable. -
Text
exposes.length
and.valueOf()
for convenience and parity with nativeString
. -
Text.lines
correctly handles splitting on newline characters while retaining them, and caches its output. -
Text.locationAt(index)
converts aPosition
-like index to aTextLocation
(line number, column number, and normalized offset value). This replaces thelocation()
helper. TheTextLocation
type is moved intostring/Text.ts
and also re-exported asText.Location
.
-
-
(string): add
TextCursor
(3830890)A
TextCursor
isText
tracking aPosition
within itself, alongside a suite of useful methods and getters. This provides a way to describe substrings without creating them, which can be memory-intensive for some tasks. Preliminary benchmarks also show thatTextCursor
is ~1.8x faster for standard parsing tasks than plainstring
and its methods, regardless of input length.TextCursor
also has an attractive.inspect()
method which depicts the cursor location within the text:…jumps over the lazy d… ^
-
(array/types): init (e3b017f)
show/hide
-
Fill
replaces array values with a given value. -
Flat
is analogous toArray.prototype.flat()
-
Indices
extracts the index values of an array. -
Index
extracts a union of indices from an array. -
FromIndices
describes a new array from a given array and a tuple of indices. -
Reverse
describes an array with the same elements in reverse order. -
Zip
combines two arrays into an array of tuples. Useful for creating object entries. -
The
Tuple
namespace clusters all helper types which respect tuples, which currently includes all types. This was a preferable alternative to starting a new top-leveltuple
module just to house these typedefs.
-
-
(object/types): init (5da75ff)
show/hide
-
Key
is a valid object key. -
EmptyObject
is an object for which all properties are invalid. -
Entry
is a key-value tuple. -
Pair
is a key-value pair in an object. -
EntryToPair
converts anEntry
to aPair
-
FromEntries
convertsEntry
s to an object -
ToEntries
converts an object to an array ofEntry
s -
The
Obj
namespace clusters these helper types.
-
-
(array/types): add
TypedArray
(3574bb1) -
(array/types): add
TupleOfLength
(5edb2ca) -
(ts/types): add
Satisfies
(d32c3d6) -
(number): init; add
types
(54b6c7a)show/hide
-
NumberType
yields a string literal that describes an input number:type T = NumberType<-1> // "-integer"
-
Wide
filters for widened typesnumber
and the infinities. -
Finite
filters for non-Wide
types -
Integer
filters integers including zero. -
Float
filters numbers with decimals. -
The
Num
namespace clusters these types.
-
-
(string/types): init (eae206d)
show/hide
-
Char
represents one of the characters within a string. -
Index
represents one of the indices of a string. -
Indices
represents a tuple containing each index of a string. -
ToTuple
represents a string as a tuple of individual characters. -
Wide
filtersstring
from specific strings, returningstring
when the input wasstring
andnever
otherwise. -
The
Str
namespace clusters these types.
-
-
(collection/types): init (2359f6f)
show/hide
-
IndexedCollection
is simplyArrayLike<unknown>
for naming purposes. -
Index
represents one of the indices within anIndexedCollection
collection. -
Indices
represents a tuple containing each index of anIndexedCollection
. UsesStr.Indices
andTuple.Indices
under the hood.
-
-
(path): add
dir()
(881798b) -
(os): init; add
newlines
utilities (a57d4e7) -
(evalCodeBlocks): allow blocks to opt out with
no-eval
; closes #37 (9a0fea2) -
(evalCodeBlocks): condense output (c635b8a)
-
(evalCodeBlocks): exit code 1 on failure; closes #59 (c67c2be)
-
(json): init; move
types/json
->json/types
(d5b6167) -
(ts): add
Intersect
util type (71a657e) -
(DirectedGraph):
.has()
accepts edges, paths, and is variadic (6d3df59) -
(DirectedGraph):
.add()
accepts edges, paths, and is variadic (7d80ed1) -
(DirectedGraph):
.remove()
accepts edges, paths, and is variadic (b84c431) -
(DirectedGraph): namespace typedefs (22789a1)
-
(cli): add console size helpers; closes #93 (18a8ee7)
-
consoleWidth()
returns the actual console width in columns, else a fallback value when unable. -
consoleHeight()
does the same for height in rows. -
consoleSize()
does both at once.
-
-
(string): add
elide
helpers; closes #94 (88636fe)-
elideStart()
replaces the start of a string with ellipses -
elideEnd()
replaces the end of a string with ellipses -
elideMiddle()
replaces the middle of a string with ellipses -
elideAround()
dynamically elides the start and/or end of a string with ellipses, centered around a chosen index
-
-
(md/codeBlock):
findAll
functions returnTextLocation
(4e7f776) -
(evalCodeBlocks): log line and error on fail; closes #42 (f3c9bed)
-
(collection): add
position
submodule (19fa4a6)A
Position
describes a location between items in anIndexedCollection
such as an array or string. For example"a"
has twoPositions
-0
and1
, representing the locations before and aftera
. This has some unique properties:0
is always a valid, and the collection'slength
is always valid. These semantics correspond to the behavior of the first argument ofArray.splice
.The function
toPosition
takes a positive or negative index and normalizes it into a positivePosition
value, where-1
refers to the position before the last item in the collection. The special value-0
refers to thePosition
at the end of the collection, identical to the collection'slength
. -
(mermaid): init; add
flowchart()
(bbb4fff) -
(string): add
escape
helpers (7f4b8ee)-
escapeFull()
replaces special characters like newline with two-character literals of their escape sequences like"\n"
-
escapeTerse()
is converts special characters into single-character unicode symbols, to preserve string length. Importantly, newline becomes"¶"
and tab becomes"⇥"
-
-
(array/types):
Flat
respects non-tuple arrays (329912e) -
(string/TextCursor): visualize spaces as
·
(b57ac02) -
(git/commit): add
sha()
(641b43d) -
(md/codeBlock):
findAll
functions return details objects (1cc011f)
Fixes
-
Breaking Change (DirectedGraph): constrain and document vertex types (28bd64e)
Previously vertices were
NonNullable
but this still allowed problematicboolean
,unknown
, and Array types. This commit constrains vertices tostring
,number
,symbol
, and non-Array objects, preventing confusion and setting up for API improvements that rely on arrays to represent edges and paths. -
(makeReleaseNotes): wire
inclusive
CLI flag (1f91b7b) -
(path/globRoot): make path separator agnostic (9ebdce5)
-
(md): parse Windows newlines (dc368ff)
-
(array/types): handle readonly arrays (032d55b)
-
(evalCodeBlocks): handle ✔️ (019f8a5)
-
(evalCodeBlocks): avoid check em...
0.3.0
This release we focused on adding CI and getting it running on MacOS, Ubuntu, and Windows 🎉
Thanks to @AustinArey for his many contributions to this release!
Continuous Integration
-
init PR checks (7ec03b1)
-
(steps):
continue-on-error
->success() || failure()
; closes #29 (c4b37fc) -
adding full tests on ubuntu (ade5e6a)
Features
-
(cli/cmd): don't throw with
fullResult
option; closes #27 (c179244) -
(ts): init; extract
evaluate()
frommd/codeBlock/evaluate
(6bf2e21) -
(makeReleaseNotes): add
inclusive
option; closes #24 (da4582c)
Fixes
0.2.0
Chores
-
add license file (7227b43)
This was accidentally omitted before. In case it ever matters: All previous commits are available under the same (0BSD) license.
Features
-
Breaking Change:
scripts/evalCodeBlocks
->md/script/evalCodeBlocks
(3c51daa) -
(md): init; add
codeBlock
module (8e4b1e8)-
regex.ts
contains regex patterns matching code blocks -
framed.ts
andindented.ts
address both types of code block -
infoString.ts
addresses the info string of a fenced code block -
create.ts
,parse.ts
, andfindAll.ts
dynamically handle both types of code block -
scripts/evalCodeBlock.ts
upgraded to use superior code block finding and parsing, and to be more aware of language codes
-
-
(md): extract
evaluate()
&evaluateAll()
(712b3ab)Previously
scripts/evalCodeBlock
held this logic for evaluating TS code blocks. Now thatmd/codeBlock
module exists, it makes a perfect home for extracting this code. This also lays the groundwork for upcoming features. -
(cli): init; add
cmd()
(b0b821d) -
(io/clipboard): init; add
copy()
&paste()
(e9d3276) -
(git): add
script/makeReleaseNotes.ts
(38a6fc8)This script will generate release notes from conventional commits since the last tag. Often the result is satisfactory as-is, and it's otherwise a great starting point.
See the readme entry or run with
--help
option for full info. It's recommended to use the-g
flag to group commits by type, the-c
flag to copy the output to clipboard, and the--types
flag to filter and order the types of commits to include.deno run -A https://deno.land/x/handy/git/script/makeReleaseNotes.ts \ -gc --types=feat,fix
-
(git): init; add
tag.ts
(d223236)-
get()
retrieves all tags -
getLatest()
retrieves the latest semver tag, or the alphabetically last tag if the tags are not semver-sortable
-
-
(git): add
commit
module (32ec6c1)-
commit.COMMIT_LOG_REGEX
can parse a commit into named capture groups -
commit.splitLog()
splits agit log
result into multiple commits -
commit.describe()
takes onegit log
commit and turns it into aCommitDescription
-
commit.get()
retrieves a single commit asCommitDescription
-
commit.getSpan()
retrieves an inclusive span of commits asCommitDescription[]
-
-
(git): add
commit/conventional
module (3da1887)-
commit.conventional.parse()
turns a commit message into aConventionalCommit
-
commit.conventional.stringify()
turns aConventionalCommit
into a commit message
-
-
(DirectedGraph): custom console log output (0b29d2a)
-
(DirectedGraph): add
Symbol.iterator
(19fdcc0) -
(DirectedGraph): add
.roots
&.leaves
(b54deb7) -
(DirectedGraph): add
.isCyclic
&.hasCycle()
(b2a9703) -
(DirectedGraph): add
.isTree
(a66d63c) -
(DirectedGraph): add
.isForest
(2bbcdda) -
(DirectedGraph): add
.has()
(4a440e4) -
(DirectedGraph): add
.subgraph()
(fe8fe01) -
(string): init; add
splitOn()
&splitOnFirst()
(bf4f771) -
(string): add
sequences()
&mostConsecutive()
(f4ffe25) -
(string): add
dedent()
(d20afed) -
(string): add
indent()
(e7cb673)
Fixes
0.1.0
- Ported from https://github.com/pskfyi/deno-utils and renamed to Handy
- Added Scripts section with first script
- Polished some existing functions
- Fixed and simplified globImport
- Renamed
timing.oncePerInterval
toarray.mapOnInterval
and adjusted API