1
0
Fork 0

fix: export missing symbols

This commit is contained in:
ssube 2021-08-01 09:47:48 -05:00
parent e18f65a049
commit 52e08220e8
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
23 changed files with 397 additions and 20 deletions

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; [AllowedBufferEncoding](./js-utils.allowedbufferencoding.md)
## AllowedBufferEncoding type
<b>Signature:</b>
```typescript
export declare type AllowedBufferEncoding = 'ascii' | 'utf-8';
```

View File

@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [deferValue](./js-utils.defervalue.md)
## deferValue() function
<b>Signature:</b>
```typescript
export declare function deferValue<T>(ms: number, val: T): Promise<T>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| ms | number | |
| val | T | |
<b>Returns:</b>
Promise&lt;T&gt;

View File

@ -17,7 +17,7 @@ export declare function encode(chunks: Array<Buffer>, encoding: AllowedBufferEnc
| Parameter | Type | Description |
| --- | --- | --- |
| chunks | Array&lt;Buffer&gt; | |
| encoding | AllowedBufferEncoding | |
| encoding | [AllowedBufferEncoding](./js-utils.allowedbufferencoding.md) | |
<b>Returns:</b>

View File

@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [filterZip](./js-utils.filterzip.md)
## filterZip() function
<b>Signature:</b>
```typescript
export declare function filterZip<T1>(cb: (a: T1) => boolean, l1: Array<T1>): Array<T1>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| cb | (a: T1) =&gt; boolean | |
| l1 | Array&lt;T1&gt; | |
<b>Returns:</b>
Array&lt;T1&gt;

View File

@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [filterZip](./js-utils.filterzip_1.md)
## filterZip() function
<b>Signature:</b>
```typescript
export declare function filterZip<T1, T2>(cb: (a: T1, b: T2) => boolean, l1: Array<T1>, l2: Array<T2>): [Array<T1>, Array<T2>];
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| cb | (a: T1, b: T2) =&gt; boolean | |
| l1 | Array&lt;T1&gt; | |
| l2 | Array&lt;T2&gt; | |
<b>Returns:</b>
\[Array&lt;T1&gt;, Array&lt;T2&gt;\]

View File

@ -0,0 +1,25 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [filterZip](./js-utils.filterzip_2.md)
## filterZip() function
<b>Signature:</b>
```typescript
export declare function filterZip<T1, T2, T3>(cb: (a: T1, b: T2) => boolean, l1: Array<T1>, l2: Array<T2>, l3: Array<T3>): [Array<T1>, Array<T2>, Array<T3>];
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| cb | (a: T1, b: T2) =&gt; boolean | |
| l1 | Array&lt;T1&gt; | |
| l2 | Array&lt;T2&gt; | |
| l3 | Array&lt;T3&gt; | |
<b>Returns:</b>
\[Array&lt;T1&gt;, Array&lt;T2&gt;, Array&lt;T3&gt;\]

View File

@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [filterZip](./js-utils.filterzip_3.md)
## filterZip() function
<b>Signature:</b>
```typescript
export declare function filterZip<T1, T2, T3, T4>(cb: (a: T1, b: T2) => boolean, l1: Array<T1>, l2: Array<T2>, l3: Array<T3>, l4: Array<T4>): [Array<T1>, Array<T2>, Array<T3>, Array<T4>];
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| cb | (a: T1, b: T2) =&gt; boolean | |
| l1 | Array&lt;T1&gt; | |
| l2 | Array&lt;T2&gt; | |
| l3 | Array&lt;T3&gt; | |
| l4 | Array&lt;T4&gt; | |
<b>Returns:</b>
\[Array&lt;T1&gt;, Array&lt;T2&gt;, Array&lt;T3&gt;, Array&lt;T4&gt;\]

View File

@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [isArray](./js-utils.isarray.md)
## isArray() function
Wrapper for `Array.isArray` with better readonly type handling.
<b>Signature:</b>
```typescript
export declare function isArray<TVal>(list: TVal | Array<TVal>): list is Array<TVal>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| list | TVal \| Array&lt;TVal&gt; | |
<b>Returns:</b>
list is Array&lt;TVal&gt;

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; [isArray](./js-utils.isarray_1.md)
## isArray() function
<b>Signature:</b>
```typescript
export declare function isArray<TVal>(list: TVal | ReadonlyArray<TVal>): list is ReadonlyArray<TVal>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| list | TVal \| ReadonlyArray&lt;TVal&gt; | |
<b>Returns:</b>
list is ReadonlyArray&lt;TVal&gt;

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; [isEmpty](./js-utils.isempty.md)
## isEmpty() function
<b>Signature:</b>
```typescript
export declare function isEmpty(val: Maybe<Array<unknown> | ReadonlyArray<unknown>>): boolean;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| val | [Maybe](./js-utils.maybe.md)<!-- -->&lt;Array&lt;unknown&gt; \| ReadonlyArray&lt;unknown&gt;&gt; | |
<b>Returns:</b>
boolean

View File

@ -31,11 +31,16 @@
| [constructorName(val)](./js-utils.constructorname.md) | Get the constructor name from an instance. |
| [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)](./js-utils.defer.md) | Resolve after a set amount of time. |
| [deferValue(ms, val)](./js-utils.defervalue.md) | |
| [doesExist(val)](./js-utils.doesexist.md) | Check if a variable is some <code>T</code>. |
| [encode(chunks, encoding)](./js-utils.encode.md) | Concatenate then encode a list of buffers. |
| [ensureArray(val)](./js-utils.ensurearray.md) | |
| [ensureArray(val)](./js-utils.ensurearray_1.md) | |
| [entriesOf(map)](./js-utils.entriesof.md) | Get entries of a map-like. |
| [filterZip(cb, l1)](./js-utils.filterzip.md) | |
| [filterZip(cb, l1, l2)](./js-utils.filterzip_1.md) | |
| [filterZip(cb, l1, l2, l3)](./js-utils.filterzip_2.md) | |
| [filterZip(cb, l1, l2, l3, l4)](./js-utils.filterzip_3.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. |
@ -44,7 +49,10 @@
| [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. |
| [hasItems(val)](./js-utils.hasitems.md) | Test if a value is an array with some items (length &gt; 0).<!-- -->This is not a general replacement for <code>.length &gt; 0</code>, since it is also a typeguard: <code>if (hasItems(val)) else { val }</code> will complain that <code>val</code> is <code>never</code> in the <code>else</code> branch, since it was proven not to be an array by this function, even if <code>val</code> is simply empty. |
| [hasItems(val)](./js-utils.hasitems_1.md) | |
| [isArray(list)](./js-utils.isarray.md) | Wrapper for <code>Array.isArray</code> with better readonly type handling. |
| [isArray(list)](./js-utils.isarray_1.md) | |
| [isDebug()](./js-utils.isdebug.md) | Test if DEBUG mode is set.<!-- -->TODO: check variable value as well |
| [isEmpty(val)](./js-utils.isempty.md) | |
| [isNil(val)](./js-utils.isnil.md) | Check if a value is nil. |
| [isNone(val)](./js-utils.isnone.md) | |
| [isSome(val)](./js-utils.issome.md) | |
@ -52,6 +60,8 @@
| [lengthOf(val)](./js-utils.lengthof.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. |
| [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. |
| [mergeArray(parts)](./js-utils.mergearray.md) | Merge arguments, which may or may not be arrays, into one return that is definitely an array. |
| [mergeArray(parts)](./js-utils.mergearray_1.md) | |
| [mergeArrays(parts)](./js-utils.mergearrays.md) | |
| [mergeArrays(parts)](./js-utils.mergearrays_1.md) | |
| [mergeMap(target, source)](./js-utils.mergemap.md) | Merge the <code>source</code> map into the <code>target</code> map, replacing keys that already exist. |
@ -68,8 +78,12 @@
| [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) | Create a spy logger using the provided methods, which returns itself as a child. |
| [sum(a, b)](./js-utils.sum.md) | Add numbers. PredicateR2<!-- -->&lt;<!-- -->number, number<!-- -->&gt; |
| [timeout(ms, oper)](./js-utils.timeout.md) | Reject after a set amount of time if the original promise has not yet resolved. |
| [toArray(val)](./js-utils.toarray.md) | |
| [toArray(val)](./js-utils.toarray_1.md) | |
| [trim(val, max, tail)](./js-utils.trim.md) | |
| [waitFor(cb, step, count)](./js-utils.waitfor.md) | Reject after a set number of attempts if the given predicate does not return true. |
| [waitForChild(child)](./js-utils.waitforchild.md) | Wait for a child process to exit, collecting output, errors, and exit status. |
| [writeValue(stream, value)](./js-utils.writevalue.md) | |
@ -96,6 +110,7 @@
| Type Alias | Description |
| --- | --- |
| [AllowedBufferEncoding](./js-utils.allowedbufferencoding.md) | |
| [ChildSpawner](./js-utils.childspawner.md) | |
| [MapLike](./js-utils.maplike.md) | A <code>Map</code> or dictionary object with string keys and <code>TVal</code> values. |
| [Maybe](./js-utils.maybe.md) | Value that may be nil. |

View File

@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [mergeArray](./js-utils.mergearray.md)
## mergeArray() function
Merge arguments, which may or may not be arrays, into one return that is definitely an array.
<b>Signature:</b>
```typescript
export declare function mergeArray<TItem>(...parts: Array<TItem | Array<TItem>>): Array<TItem>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| parts | Array&lt;TItem \| Array&lt;TItem&gt;&gt; | |
<b>Returns:</b>
Array&lt;TItem&gt;

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; [mergeArray](./js-utils.mergearray_1.md)
## mergeArray() function
<b>Signature:</b>
```typescript
export declare function mergeArray<TItem>(...parts: ReadonlyArray<TItem | ReadonlyArray<TItem>>): ReadonlyArray<TItem>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| parts | ReadonlyArray&lt;TItem \| ReadonlyArray&lt;TItem&gt;&gt; | |
<b>Returns:</b>
ReadonlyArray&lt;TItem&gt;

27
docs/api/js-utils.sum.md Normal file
View File

@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [sum](./js-utils.sum.md)
## sum() function
Add numbers.
PredicateR2<!-- -->&lt;<!-- -->number, number<!-- -->&gt;
<b>Signature:</b>
```typescript
export declare function sum(a: number, b: number): number;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| a | number | |
| b | number | |
<b>Returns:</b>
number

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; [toArray](./js-utils.toarray.md)
## toArray() function
<b>Signature:</b>
```typescript
export declare function toArray<TVal>(val: Maybe<TVal | Array<TVal>>): Array<TVal>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| val | [Maybe](./js-utils.maybe.md)<!-- -->&lt;TVal \| Array&lt;TVal&gt;&gt; | |
<b>Returns:</b>
Array&lt;TVal&gt;

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; [toArray](./js-utils.toarray_1.md)
## toArray() function
<b>Signature:</b>
```typescript
export declare function toArray<TVal>(val: Maybe<TVal | ReadonlyArray<TVal>>): ReadonlyArray<TVal>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| val | [Maybe](./js-utils.maybe.md)<!-- -->&lt;TVal \| ReadonlyArray&lt;TVal&gt;&gt; | |
<b>Returns:</b>
ReadonlyArray&lt;TVal&gt;

View File

@ -0,0 +1,30 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [waitFor](./js-utils.waitfor.md)
## waitFor() function
Reject after a set number of attempts if the given predicate does not return true.
<b>Signature:</b>
```typescript
export declare function waitFor(cb: PredicateC0, step: number, count: number): Promise<void>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| cb | PredicateC0 | |
| step | number | |
| count | number | |
<b>Returns:</b>
Promise&lt;void&gt;
## Exceptions
TimeoutError

View File

@ -1,4 +1,4 @@
import { sum } from './Predicate';
import { sum } from './Math';
export type AllowedBufferEncoding = 'ascii' | 'utf-8';

8
src/Math.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* Add numbers.
*
* @implements PredicateR2<number, number>
*/
export function sum(a: number, b: number): number {
return a + b;
}

View File

@ -47,12 +47,3 @@ export type PredicateR1<RVal, TVal = RVal> = (val: TVal, idx: number, list: Arra
* @beta
*/
export type PredicateR2<RVal, TVal = RVal> = (pval: TVal, nval: TVal, idx: number, list: Array<TVal>) => RVal;
/**
* Add numbers.
*
* @implements PredicateR2<number, number>
*/
export function sum(a: number, b: number): number {
return a + b;
}

View File

@ -5,15 +5,29 @@ export { NotFoundError } from './error/NotFoundError';
export { NotImplementedError } from './error/NotImplementedError';
export { TimeoutError } from './error/TimeoutError';
export {
mergeArray,
mergeArrays,
hasItems,
ensureArray,
toArray,
isArray,
isEmpty,
filterZip,
lengthOf,
} from './Array';
export {
ArrayMapper,
ArrayMapperOptions,
} from './ArrayMapper';
export {
defer,
deferValue,
timeout,
waitFor,
} from './Async';
export {
AllowedBufferEncoding,
concat,
encode,
} from './Buffer';
@ -29,14 +43,13 @@ export {
waitForChild,
writeValue,
} from './Child';
export { ExternalModule, ModuleCtor } from './ExternalModule';
export { isDebug } from './Env';
export {
ensureArray,
hasItems,
lengthOf,
mergeArrays,
} from './Array';
isDebug
} from './Env';
export {
ExternalModule,
ModuleCtor,
} from './ExternalModule';
export {
getTestLogger,
spyLogger,
@ -57,6 +70,9 @@ export {
pushMergeMap,
setOrPush,
} from './Map';
export {
sum,
} from './Math';
export {
Maybe,
None,

View File

@ -6,7 +6,7 @@ import sinon from 'sinon';
import { isNone } from '../../src';
import { ensureArray, filterZip, hasItems, isEmpty, lengthOf, mergeArray, toArray } from '../../src/Array';
import { sum } from '../../src/Predicate';
import { sum } from '../../src/Math';
const { match, stub } = sinon;

View File

@ -3,7 +3,7 @@ import { array, uint8Array } from 'fast-check';
import { over } from 'mocha-foam';
import { concat, encode } from '../../src/Buffer';
import { sum } from '../../src/Predicate';
import { sum } from '../../src/Math';
describe('buffer utils', async () => {
describe('concat', async () => {