1
0
Fork 0

feat: export async tracker, checklist

This commit is contained in:
ssube 2020-03-29 09:52:40 -05:00
parent 6ac9f3314a
commit e68d7f97d2
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
15 changed files with 215 additions and 5 deletions

View File

@ -0,0 +1,20 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [Checklist](./js-utils.checklist.md) &gt; [(constructor)](./js-utils.checklist._constructor_.md)
## Checklist.(constructor)
Constructs a new instance of the `Checklist` class
<b>Signature:</b>
```typescript
constructor(options: ChecklistOptions<T>);
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| options | <code>ChecklistOptions&lt;T&gt;</code> | |

View File

@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [Checklist](./js-utils.checklist.md) &gt; [check](./js-utils.checklist.check.md)
## Checklist.check() method
<b>Signature:</b>
```typescript
check(value: T): boolean;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| value | <code>T</code> | |
<b>Returns:</b>
`boolean`

View File

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [Checklist](./js-utils.checklist.md) &gt; [data](./js-utils.checklist.data.md)
## Checklist.data property
<b>Signature:</b>
```typescript
readonly data: Array<T>;
```

View File

@ -0,0 +1,31 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [Checklist](./js-utils.checklist.md)
## Checklist class
<b>Signature:</b>
```typescript
export declare class Checklist<T> implements ChecklistOptions<T>
```
## Constructors
| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)(options)](./js-utils.checklist._constructor_.md) | | Constructs a new instance of the <code>Checklist</code> class |
## Properties
| Property | Modifiers | Type | Description |
| --- | --- | --- | --- |
| [data](./js-utils.checklist.data.md) | | <code>Array&lt;T&gt;</code> | |
| [mode](./js-utils.checklist.mode.md) | | <code>ChecklistMode</code> | |
## Methods
| Method | Modifiers | Description |
| --- | --- | --- |
| [check(value)](./js-utils.checklist.check.md) | | |

View File

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [Checklist](./js-utils.checklist.md) &gt; [mode](./js-utils.checklist.mode.md)
## Checklist.mode property
<b>Signature:</b>
```typescript
readonly mode: ChecklistMode;
```

View File

@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [ChecklistMode](./js-utils.checklistmode.md)
## ChecklistMode enum
<b>Signature:</b>
```typescript
export declare enum ChecklistMode
```
## Enumeration Members
| Member | Value | Description |
| --- | --- | --- |
| EXCLUDE | <code>&quot;exclude&quot;</code> | |
| INCLUDE | <code>&quot;include&quot;</code> | |

View File

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [ChecklistOptions](./js-utils.checklistoptions.md) &gt; [data](./js-utils.checklistoptions.data.md)
## ChecklistOptions.data property
<b>Signature:</b>
```typescript
data: Array<T>;
```

View File

@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [ChecklistOptions](./js-utils.checklistoptions.md)
## ChecklistOptions interface
<b>Signature:</b>
```typescript
export interface ChecklistOptions<T>
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [data](./js-utils.checklistoptions.data.md) | <code>Array&lt;T&gt;</code> | |
| [mode](./js-utils.checklistoptions.mode.md) | <code>ChecklistMode</code> | |

View File

@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [ChecklistOptions](./js-utils.checklistoptions.md) &gt; [mode](./js-utils.checklistoptions.mode.md)
## ChecklistOptions.mode property
<b>Signature:</b>
```typescript
mode: ChecklistMode;
```

View File

@ -10,6 +10,7 @@
| --- | --- | | --- | --- |
| [ArrayMapper](./js-utils.arraymapper.md) | | | [ArrayMapper](./js-utils.arraymapper.md) | |
| [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 | | [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) | | | [ChildProcessError](./js-utils.childprocesserror.md) | |
| [InvalidArgumentError](./js-utils.invalidargumenterror.md) | | | [InvalidArgumentError](./js-utils.invalidargumenterror.md) | |
| [MissingKeyError](./js-utils.missingkeyerror.md) | | | [MissingKeyError](./js-utils.missingkeyerror.md) | |
@ -17,6 +18,12 @@
| [NotImplementedError](./js-utils.notimplementederror.md) | | | [NotImplementedError](./js-utils.notimplementederror.md) | |
| [TimeoutError](./js-utils.timeouterror.md) | | | [TimeoutError](./js-utils.timeouterror.md) | |
## Enumerations
| Enumeration | Description |
| --- | --- |
| [ChecklistMode](./js-utils.checklistmode.md) | |
## Functions ## Functions
| Function | Description | | Function | Description |
@ -65,6 +72,7 @@
| Interface | Description | | Interface | Description |
| --- | --- | | --- | --- |
| [ArrayMapperOptions](./js-utils.arraymapperoptions.md) | | | [ArrayMapperOptions](./js-utils.arraymapperoptions.md) | |
| [ChecklistOptions](./js-utils.checklistoptions.md) | |
| [ChildOptions](./js-utils.childoptions.md) | | | [ChildOptions](./js-utils.childoptions.md) | |
| [ChildResult](./js-utils.childresult.md) | | | [ChildResult](./js-utils.childresult.md) | |
| [Dict](./js-utils.dict.md) | | | [Dict](./js-utils.dict.md) | |

View File

@ -1,7 +1,7 @@
import { AsyncHook, createHook } from 'async_hooks'; import { AsyncHook, createHook } from 'async_hooks';
import { isNil } from '../utils'; import { isNil } from './utils';
import { isDebug } from '../utils/Env'; import { isDebug } from './utils/Env';
export interface TrackedResource { export interface TrackedResource {
source: string; source: string;

View File

@ -7,11 +7,11 @@ export { TimeoutError } from './error/TimeoutError';
export { export {
AsyncTracker, AsyncTracker,
} from './test/AsyncTracker'; } from './AsyncTracker';
export { export {
getTestLogger, getTestLogger,
spyLogger, spyLogger,
} from './test/Logger'; } from './Logger';
export { export {
Nil, Nil,

View File

@ -1,4 +1,4 @@
import { AsyncTracker } from '../../src/test/AsyncTracker'; import { AsyncTracker } from '../../src/AsyncTracker';
import { isNil } from '../../src/utils'; import { isNil } from '../../src/utils';
import { isDebug } from '../../src/utils/Env'; import { isDebug } from '../../src/utils/Env';

View File

@ -0,0 +1,47 @@
import { expect } from 'chai';
import { Checklist, ChecklistMode } from '../../src/utils/Checklist';
import { describeLeaks, itLeaks } from '../helpers/async';
const EXISTING_ITEM = 'foo';
const MISSING_ITEM = 'bin';
const TEST_DATA = [EXISTING_ITEM, 'bar'];
// tslint:disable:no-duplicate-functions
describeLeaks('checklist', async () => {
describeLeaks('exclude mode', async () => {
itLeaks('should check for present values', async () => {
const list = new Checklist({
data: TEST_DATA,
mode: ChecklistMode.EXCLUDE,
});
expect(list.check(EXISTING_ITEM)).to.equal(false);
});
itLeaks('should check for missing values', async () => {
const list = new Checklist({
data: TEST_DATA,
mode: ChecklistMode.EXCLUDE,
});
expect(list.check(MISSING_ITEM)).to.equal(true);
});
});
describeLeaks('include mode', async () => {
itLeaks('should check for present values', async () => {
const list = new Checklist<string>({
data: TEST_DATA,
mode: ChecklistMode.INCLUDE,
});
expect(list.check(EXISTING_ITEM)).to.equal(true);
});
itLeaks('should check for missing values', async () => {
const list = new Checklist<string>({
data: TEST_DATA,
mode: ChecklistMode.INCLUDE,
});
expect(list.check(MISSING_ITEM)).to.equal(false);
});
});
});