feat: export async tracker, checklist
This commit is contained in:
parent
6ac9f3314a
commit
e68d7f97d2
|
@ -0,0 +1,20 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [Checklist](./js-utils.checklist.md) > [(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<T></code> | |
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [Checklist](./js-utils.checklist.md) > [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`
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [Checklist](./js-utils.checklist.md) > [data](./js-utils.checklist.data.md)
|
||||
|
||||
## Checklist.data property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readonly data: Array<T>;
|
||||
```
|
|
@ -0,0 +1,31 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [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<T></code> | |
|
||||
| [mode](./js-utils.checklist.mode.md) | | <code>ChecklistMode</code> | |
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [check(value)](./js-utils.checklist.check.md) | | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [Checklist](./js-utils.checklist.md) > [mode](./js-utils.checklist.mode.md)
|
||||
|
||||
## Checklist.mode property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
readonly mode: ChecklistMode;
|
||||
```
|
|
@ -0,0 +1,19 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChecklistMode](./js-utils.checklistmode.md)
|
||||
|
||||
## ChecklistMode enum
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare enum ChecklistMode
|
||||
```
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
| Member | Value | Description |
|
||||
| --- | --- | --- |
|
||||
| EXCLUDE | <code>"exclude"</code> | |
|
||||
| INCLUDE | <code>"include"</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChecklistOptions](./js-utils.checklistoptions.md) > [data](./js-utils.checklistoptions.data.md)
|
||||
|
||||
## ChecklistOptions.data property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
data: Array<T>;
|
||||
```
|
|
@ -0,0 +1,19 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [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<T></code> | |
|
||||
| [mode](./js-utils.checklistoptions.mode.md) | <code>ChecklistMode</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChecklistOptions](./js-utils.checklistoptions.md) > [mode](./js-utils.checklistoptions.mode.md)
|
||||
|
||||
## ChecklistOptions.mode property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
mode: ChecklistMode;
|
||||
```
|
|
@ -10,6 +10,7 @@
|
|||
| --- | --- |
|
||||
| [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 |
|
||||
| [Checklist](./js-utils.checklist.md) | |
|
||||
| [ChildProcessError](./js-utils.childprocesserror.md) | |
|
||||
| [InvalidArgumentError](./js-utils.invalidargumenterror.md) | |
|
||||
| [MissingKeyError](./js-utils.missingkeyerror.md) | |
|
||||
|
@ -17,6 +18,12 @@
|
|||
| [NotImplementedError](./js-utils.notimplementederror.md) | |
|
||||
| [TimeoutError](./js-utils.timeouterror.md) | |
|
||||
|
||||
## Enumerations
|
||||
|
||||
| Enumeration | Description |
|
||||
| --- | --- |
|
||||
| [ChecklistMode](./js-utils.checklistmode.md) | |
|
||||
|
||||
## Functions
|
||||
|
||||
| Function | Description |
|
||||
|
@ -65,6 +72,7 @@
|
|||
| Interface | Description |
|
||||
| --- | --- |
|
||||
| [ArrayMapperOptions](./js-utils.arraymapperoptions.md) | |
|
||||
| [ChecklistOptions](./js-utils.checklistoptions.md) | |
|
||||
| [ChildOptions](./js-utils.childoptions.md) | |
|
||||
| [ChildResult](./js-utils.childresult.md) | |
|
||||
| [Dict](./js-utils.dict.md) | |
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { AsyncHook, createHook } from 'async_hooks';
|
||||
|
||||
import { isNil } from '../utils';
|
||||
import { isDebug } from '../utils/Env';
|
||||
import { isNil } from './utils';
|
||||
import { isDebug } from './utils/Env';
|
||||
|
||||
export interface TrackedResource {
|
||||
source: string;
|
|
@ -7,11 +7,11 @@ export { TimeoutError } from './error/TimeoutError';
|
|||
|
||||
export {
|
||||
AsyncTracker,
|
||||
} from './test/AsyncTracker';
|
||||
} from './AsyncTracker';
|
||||
export {
|
||||
getTestLogger,
|
||||
spyLogger,
|
||||
} from './test/Logger';
|
||||
} from './Logger';
|
||||
|
||||
export {
|
||||
Nil,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AsyncTracker } from '../../src/test/AsyncTracker';
|
||||
import { AsyncTracker } from '../../src/AsyncTracker';
|
||||
import { isNil } from '../../src/utils';
|
||||
import { isDebug } from '../../src/utils/Env';
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue