<commit_before><!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [CompUnit::Util](#compunitutil)
  - [Utilities](#utilities)
    - [load](#load)
    - [find-loaded](#find-loaded)
    - [all-loaded](#all-loaded)
    - [at-unit](#at-unit)
    - [capture-import](#capture-import)
  - [Re-Exporting](#re-exporting)
    - [re-export](#re-export)
    - [re-exporthow](#re-exporthow)
    - [steal-export-sub](#steal-export-sub)
    - [steal-globalish](#steal-globalish)
    - [re-export-everything](#re-export-everything)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# CompUnit::Util

Utility functions for introspecting `CompUnit`s and re-exporting their symbols.

Apart from `load` none of the routines here will load a compunit. All
parameters named `$handle` will converted to a `CompUnit::Handle`
automatically. If the `$handle` you pass is not a defined `CompUnit` or
`CompUnit::Handle`, `&find-loaded` will be used to search for an
loaded compunit matching your argument.

**warning** this module relies on unspec'd rakudo internals and could
break without warning

## Utilities

### load
`(Str:D $short-name,*%opts --> CompUnit:D)`

``` perl6
use CompUnit::Util :load;
my CompUnit $cu = load('Test');
# or even
my $cu = load('MyModule', version => v3);
```


Loads a compunit by name. All named arguments to
`CompUnit::DependencySpecification` are accepted (other
than `short-name` which is the positional argument).

### find-loaded
`($match --> CompUnit)`

``` perl6
use CompUnit::Util :find-loaded;
need SomeModule;
my CompUnit $some-module = find-loaded('SomeModule');
```

Searches all the `CompUnit::Repository`s until it finds a loaded
compunit matching `$match`. Returns a failure otherwise.

### all-loaded

```perl6
use CompUnit::Util :all-loaded;
.note for all-loaded;
```

Returns all presently loaded `CompUnit`s.<commit_msg>made note about load<commit_after><!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
- [CompUnit::Util](#compunitutil)
  - [Utilities](#utilities)
    - [load](#load)
    - [find-loaded](#find-loaded)
    - [all-loaded](#all-loaded)
    - [at-unit](#at-unit)
    - [capture-import](#capture-import)
  - [Re-Exporting](#re-exporting)
    - [re-export](#re-export)
    - [re-exporthow](#re-exporthow)
    - [steal-export-sub](#steal-export-sub)
    - [steal-globalish](#steal-globalish)
    - [re-export-everything](#re-export-everything)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# CompUnit::Util

Utility functions for introspecting `CompUnit`s and re-exporting their symbols.

Apart from `load` none of the routines here will load a compunit. All
parameters named `$handle` will converted to a `CompUnit::Handle`
automatically. If the `$handle` you pass is not a defined `CompUnit` or
`CompUnit::Handle`, `&find-loaded` will be used to search for an
loaded compunit matching your argument.

**warning** this module relies on unspec'd rakudo internals and could
break without warning

## Utilities

### load
`(Str:D $short-name,*%opts --> CompUnit:D)`

``` perl6
use CompUnit::Util :load;
my CompUnit $cu = load('Test');
# or even
my $cu = load('MyModule', version => v3);
```

Loads a compunit by name. All named arguments to
`CompUnit::DependencySpecification` are accepted (other than
`short-name` which is the positional argument). At the moment `load`
is just short for:

``` perl6
    $*REPO.need(CompUnit::Dependencyspecification.new(:short_name<MyModule>));
```

### find-loaded
`($match --> CompUnit)`

``` perl6
use CompUnit::Util :find-loaded;
need SomeModule;
my CompUnit $some-module = find-loaded('SomeModule');
```

Searches all the `CompUnit::Repository`s until it finds a loaded
compunit matching `$match`. Returns a failure otherwise.

### all-loaded

```perl6
use CompUnit::Util :all-loaded;
.note for all-loaded;
```

Returns all presently loaded `CompUnit`s.
{'fraction_non_alphanumeric': 0.14736070381231672, 'fraction_numerical': 0.0021994134897360706, 'mean_word_length': 4.399736147757256, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3151098', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1290, 'n_words': 410}