Skip to content

Commit

Permalink
fix(docs): describe exports and mark with release status
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Mar 31, 2020
1 parent 6d7e72e commit e4958ee
Show file tree
Hide file tree
Showing 46 changed files with 257 additions and 30 deletions.
2 changes: 2 additions & 0 deletions docs/api/js-utils.arraymapper.map.md
Expand Up @@ -4,6 +4,8 @@

## ArrayMapper.map() method

Transform the input list into a map, extracting elements using the mapper's options.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 1 addition & 1 deletion docs/api/js-utils.arraymapper.md
Expand Up @@ -30,5 +30,5 @@ export declare class ArrayMapper

| Method | Modifiers | Description |
| --- | --- | --- |
| [map(input)](./js-utils.arraymapper.map.md) | | |
| [map(input)](./js-utils.arraymapper.map.md) | | Transform the input list into a map, extracting elements using the mapper's options. |

2 changes: 2 additions & 0 deletions docs/api/js-utils.asynctracker.dump.md
Expand Up @@ -4,6 +4,8 @@

## AsyncTracker.dump() method

Print a listing of all tracked resources. When debug mode is enabled (DEBUG=TRUE), include stack traces.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.asynctracker.getstack.md
Expand Up @@ -4,6 +4,8 @@

## AsyncTracker.getStack() method

Get a filtered version of the current call stack. This creates a new error to generate the stack trace and will be quite slow.

<b>Signature:</b>

```typescript
Expand Down
4 changes: 2 additions & 2 deletions docs/api/js-utils.asynctracker.md
Expand Up @@ -33,7 +33,7 @@ export declare class AsyncTracker
| --- | --- | --- |
| [clear()](./js-utils.asynctracker.clear.md) | | |
| [disable()](./js-utils.asynctracker.disable.md) | | |
| [dump()](./js-utils.asynctracker.dump.md) | | |
| [dump()](./js-utils.asynctracker.dump.md) | | Print a listing of all tracked resources. When debug mode is enabled (DEBUG=TRUE), include stack traces. |
| [enable()](./js-utils.asynctracker.enable.md) | | |
| [getStack()](./js-utils.asynctracker.getstack.md) | | |
| [getStack()](./js-utils.asynctracker.getstack.md) | | Get a filtered version of the current call stack. This creates a new error to generate the stack trace and will be quite slow. |

2 changes: 2 additions & 0 deletions docs/api/js-utils.checklist.data.md
Expand Up @@ -4,6 +4,8 @@

## Checklist.data property

TODO: switch to Set

<b>Signature:</b>

```typescript
Expand Down
4 changes: 3 additions & 1 deletion docs/api/js-utils.checklist.md
Expand Up @@ -4,6 +4,8 @@

## Checklist class

Check whether items are included or not (blacklist or whitelist, depending on `mode`<!-- -->).

<b>Signature:</b>

```typescript
Expand All @@ -20,7 +22,7 @@ export declare class Checklist<T> implements ChecklistOptions<T>
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [data](./js-utils.checklist.data.md) | | <code>Array&lt;T&gt;</code> | |
| [data](./js-utils.checklist.data.md) | | <code>Array&lt;T&gt;</code> | TODO: switch to Set |
| [mode](./js-utils.checklist.mode.md) | | <code>ChecklistMode</code> | |
## Methods
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.childprocesserror.md
Expand Up @@ -4,6 +4,8 @@

## ChildProcessError class

Error indicating that a child process exited with an error status.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.concat.md
Expand Up @@ -4,6 +4,8 @@

## concat() function

Concatenate a list of buffers.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.constructorname.md
Expand Up @@ -4,6 +4,8 @@

## constructorName() function

Get the constructor name from an instance.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.defaultwhen.md
Expand Up @@ -4,6 +4,8 @@

## defaultWhen() function

Return the first element when `condition` is true and the second element when `condition` is false.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.encode.md
Expand Up @@ -4,6 +4,8 @@

## encode() function

Concatenate then encode a list of buffers.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.getconstructor.md
Expand Up @@ -4,6 +4,8 @@

## getConstructor() function

Get the constructor from an instance.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.getmethods.md
Expand Up @@ -4,6 +4,8 @@

## getMethods() function

Get the methods from an instance and its prototypes.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.gettestlogger.md
Expand Up @@ -4,6 +4,8 @@

## getTestLogger() function

Get a test logger. Returns a null logger unless `verbose` is true or run under debug mode.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.invalidargumenterror.md
Expand Up @@ -4,6 +4,8 @@

## InvalidArgumentError class

Error indicating that an invalid argument was passed to a function call.

<b>Signature:</b>

```typescript
Expand Down
4 changes: 4 additions & 0 deletions docs/api/js-utils.isdebug.md
Expand Up @@ -4,6 +4,10 @@

## isDebug() function

Test if DEBUG mode is set.

TODO: check variable value as well

<b>Signature:</b>

```typescript
Expand Down
42 changes: 21 additions & 21 deletions docs/api/js-utils.md
Expand Up @@ -10,13 +10,13 @@
| --- | --- |
| [ArrayMapper](./js-utils.arraymapper.md) | Map an array of items into a map of arrays using the specified keys, able to <code>skip</code> initial items and gather remaining items into a <code>rest</code> key. |
| [AsyncTracker](./js-utils.asynctracker.md) | Async resource tracker using node's internal hooks.<!-- -->This probably won't work in a browser. It does not hold references to the resource, to avoid leaks. Adapted from https://gist.github.com/boneskull/7fe75b63d613fa940db7ec990a5f5843\#file-async-dump-js |
| [Checklist](./js-utils.checklist.md) | |
| [ChildProcessError](./js-utils.childprocesserror.md) | |
| [InvalidArgumentError](./js-utils.invalidargumenterror.md) | |
| [MissingKeyError](./js-utils.missingkeyerror.md) | |
| [NotFoundError](./js-utils.notfounderror.md) | |
| [NotImplementedError](./js-utils.notimplementederror.md) | |
| [TimeoutError](./js-utils.timeouterror.md) | |
| [Checklist](./js-utils.checklist.md) | Check whether items are included or not (blacklist or whitelist, depending on <code>mode</code>). |
| [ChildProcessError](./js-utils.childprocesserror.md) | Error indicating that a child process exited with an error status. |
| [InvalidArgumentError](./js-utils.invalidargumenterror.md) | Error indicating that an invalid argument was passed to a function call. |
| [MissingKeyError](./js-utils.missingkeyerror.md) | Error indicating that a required key did not exist in a map-like. |
| [NotFoundError](./js-utils.notfounderror.md) | Error indicating that some value was not found. |
| [NotImplementedError](./js-utils.notimplementederror.md) | Error indicating that a function has not been implemented yet. |
| [TimeoutError](./js-utils.timeouterror.md) | Error indicating that a promise timed out. |

## Enumerations

Expand All @@ -28,43 +28,43 @@

| Function | Description |
| --- | --- |
| [concat(chunks)](./js-utils.concat.md) | |
| [constructorName(val)](./js-utils.constructorname.md) | |
| [concat(chunks)](./js-utils.concat.md) | Concatenate a list of buffers. |
| [constructorName(val)](./js-utils.constructorname.md) | Get the constructor name from an instance. |
| [countOf(val)](./js-utils.countof.md) | Calculate the "length" of an array or value.<!-- -->Arrays return their length, single values return 1, and nil values return 0. This counts the number of elements that setOrPush would add. |
| [defaultWhen(condition, items)](./js-utils.defaultwhen.md) | |
| [defaultWhen(condition, items)](./js-utils.defaultwhen.md) | Return the first element when <code>condition</code> is true and the second element when <code>condition</code> is false. |
| [defer(ms, val)](./js-utils.defer.md) | Resolve after a set amount of time. |
| [doesExist(val)](./js-utils.doesexist.md) | Check if a variable is not nil. |
| [encode(chunks, encoding)](./js-utils.encode.md) | |
| [encode(chunks, encoding)](./js-utils.encode.md) | Concatenate then encode a list of buffers. |
| [entriesOf(map)](./js-utils.entriesof.md) | Get entries of a map-like. |
| [filterNil(list)](./js-utils.filternil.md) | Remove any null or undefined items from the list. |
| [getConstructor(val)](./js-utils.getconstructor.md) | |
| [getConstructor(val)](./js-utils.getconstructor.md) | Get the constructor from an instance. |
| [getHead(map, key)](./js-utils.gethead.md) | Get the first element from the specified key within a map of lists. |
| [getHeadOrDefault(map, key, defaultValue)](./js-utils.getheadordefault.md) | Get the first element from the specified key, within a map of lists, or a default value when the key does not exist or is nil. |
| [getMethods(value)](./js-utils.getmethods.md) | |
| [getMethods(value)](./js-utils.getmethods.md) | Get the methods from an instance and its prototypes. |
| [getOrDefault(map, key, defaultValue)](./js-utils.getordefault.md) | Get a map key or default value when the key does not exist or is nil. |
| [getTestLogger(verbose)](./js-utils.gettestlogger.md) | |
| [isDebug()](./js-utils.isdebug.md) | |
| [getTestLogger(verbose)](./js-utils.gettestlogger.md) | Get a test logger. Returns a null logger unless <code>verbose</code> is true or run under debug mode. |
| [isDebug()](./js-utils.isdebug.md) | Test if DEBUG mode is set.<!-- -->TODO: check variable value as well |
| [isNil(val)](./js-utils.isnil.md) | Check if a value is nil. |
| [leftPad(val, min, fill)](./js-utils.leftpad.md) | |
| [makeDict(map)](./js-utils.makedict.md) | Turns a map or dict into a dict |
| [makeMap(val)](./js-utils.makemap.md) | Clone a map or map-like object into a new map. |
| [mergeList(parts)](./js-utils.mergelist.md) | Merge arguments, which may or may not be arrays, into one return that is definitely an array. |
| [mergeMap(target, source)](./js-utils.mergemap.md) | Merge the <code>source</code> map into the <code>target</code> map, replacing keys that already exist. |
| [mustCoalesce(values)](./js-utils.mustcoalesce.md) | Return the first value that is not nil.<!-- -->TODO: rename to mustDefault |
| [mustCoalesce(values)](./js-utils.mustcoalesce.md) | Return the first value that is not nil.<!-- -->@<!-- -->todo: rename to mustDefault |
| [mustExist(val)](./js-utils.mustexist.md) | Assert that a variable is not nil and return the value. |
| [mustFind(list, predicate)](./js-utils.mustfind.md) | Find a value matching the given predicate or throw. |
| [mustGet(map, key)](./js-utils.mustget.md) | Get an element from a Map and guard against nil values. |
| [normalizeMap(map)](./js-utils.normalizemap.md) | |
| [normalizeMap(map)](./js-utils.normalizemap.md) | <b><i>(BETA)</i></b> Normalize a map-like of values into a dict of lists of strings. |
| [pairsToMap(pairs)](./js-utils.pairstomap.md) | Turns a list of name-value pairs into a map. |
| [pushMergeMap(args)](./js-utils.pushmergemap.md) | Merge the provided maps into a new map, merging keys that already exist by pushing new items. |
| [removePid(path)](./js-utils.removepid.md) | |
| [removePid(path)](./js-utils.removepid.md) | Remove the file at the given <code>path</code>. |
| [setOrPush(map, key, val)](./js-utils.setorpush.md) | Set a map key to a new array or push to the existing value. |
| [signal(signals)](./js-utils.signal.md) | |
| [spyLogger(spies)](./js-utils.spylogger.md) | |
| [spyLogger(spies)](./js-utils.spylogger.md) | Create a spy logger using the provided methods, which returns itself as a child. |
| [timeout(ms, oper)](./js-utils.timeout.md) | Reject after a set amount of time if the original promise has not yet resolved. |
| [trim(val, max, tail)](./js-utils.trim.md) | |
| [waitForChild(child)](./js-utils.waitforchild.md) | |
| [writePid(path)](./js-utils.writepid.md) | |
| [waitForChild(child)](./js-utils.waitforchild.md) | Wait for a child process to exit, collecting output, errors, and exit status. |
| [writePid(path)](./js-utils.writepid.md) | Write the current process ID to a file at the given <code>path</code>. |
| [writeValue(stream, value)](./js-utils.writevalue.md) | |

## Interfaces
Expand Down
4 changes: 3 additions & 1 deletion docs/api/js-utils.missingkeyerror.md
Expand Up @@ -4,10 +4,12 @@

## MissingKeyError class

Error indicating that a required key did not exist in a map-like.

<b>Signature:</b>

```typescript
export declare class MissingKeyError extends BaseError
export declare class MissingKeyError extends NotFoundError
```
## Constructors
Expand Down
2 changes: 1 addition & 1 deletion docs/api/js-utils.mustcoalesce.md
Expand Up @@ -6,7 +6,7 @@

Return the first value that is not nil.

TODO: rename to mustDefault
@<!-- -->todo: rename to mustDefault

<b>Signature:</b>

Expand Down
5 changes: 5 additions & 0 deletions docs/api/js-utils.normalizemap.md
Expand Up @@ -4,6 +4,11 @@

## normalizeMap() function

> This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
>
Normalize a map-like of values into a dict of lists of strings.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.notfounderror.md
Expand Up @@ -4,6 +4,8 @@

## NotFoundError class

Error indicating that some value was not found.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.notimplementederror.md
Expand Up @@ -4,6 +4,8 @@

## NotImplementedError class

Error indicating that a function has not been implemented yet.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.removepid.md
Expand Up @@ -4,6 +4,8 @@

## removePid() function

Remove the file at the given `path`<!-- -->.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.spylogger.md
Expand Up @@ -4,6 +4,8 @@

## spyLogger() function

Create a spy logger using the provided methods, which returns itself as a child.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.timeouterror.md
Expand Up @@ -4,6 +4,8 @@

## TimeoutError class

Error indicating that a promise timed out.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.waitforchild.md
Expand Up @@ -4,6 +4,8 @@

## waitForChild() function

Wait for a child process to exit, collecting output, errors, and exit status.

<b>Signature:</b>

```typescript
Expand Down
2 changes: 2 additions & 0 deletions docs/api/js-utils.writepid.md
Expand Up @@ -4,6 +4,8 @@

## writePid() function

Write the current process ID to a file at the given `path`<!-- -->.

<b>Signature:</b>

```typescript
Expand Down
7 changes: 7 additions & 0 deletions src/ArrayMapper.ts
Expand Up @@ -18,6 +18,8 @@ export interface ArrayMapperOptions {
/**
* Map an array of items into a map of arrays using the specified keys, able to `skip` initial items and gather
* remaining items into a `rest` key.
*
* @public
*/
export class ArrayMapper {
public readonly rest: string;
Expand All @@ -30,6 +32,11 @@ export class ArrayMapper {
this.take = Array.from(options.take);
}

/**
* Transform the input list into a map, extracting elements using the mapper's options.
*
* @public
*/
public map(input: Array<string>): Map<string, Array<string>> {
const result = new Map();
input.forEach((it, idx) => {
Expand Down
7 changes: 7 additions & 0 deletions src/Async.ts
Expand Up @@ -3,6 +3,7 @@ import { PredicateC0 } from './utils';

/**
* Resolve after a set amount of time.
* @public
*/
export function defer<T = undefined>(ms: number, val?: T): Promise<T> {
return new Promise((res, rej) => {
Expand All @@ -14,6 +15,7 @@ export function defer<T = undefined>(ms: number, val?: T): Promise<T> {

/**
* Reject after a set amount of time if the original promise has not yet resolved.
* @public
*/
export function timeout<T>(ms: number, oper: Promise<T>): Promise<T> {
const limit = new Promise<T>((res, rej) => {
Expand All @@ -25,6 +27,11 @@ export function timeout<T>(ms: number, oper: Promise<T>): Promise<T> {
return Promise.race([limit, oper]);
}

/**
* Reject after a set number of attempts if the given predicate does not return true.
* @public
* @throws TimeoutError
*/
export async function waitFor(cb: PredicateC0, step: number, count: number): Promise<void> {
let accum = 0;
while (accum < count) {
Expand Down

0 comments on commit e4958ee

Please sign in to comment.