diff --git a/docs/api/js-utils.arraymapperoptions.md b/docs/api/js-utils.arraymapperoptions.md
new file mode 100644
index 0000000..453ed0d
--- /dev/null
+++ b/docs/api/js-utils.arraymapperoptions.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ArrayMapperOptions](./js-utils.arraymapperoptions.md)
+
+## ArrayMapperOptions interface
+
+Signature:
+
+```typescript
+export interface ArrayMapperOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [rest](./js-utils.arraymapperoptions.rest.md) | string
| |
+| [skip](./js-utils.arraymapperoptions.skip.md) | number
| |
+| [take](./js-utils.arraymapperoptions.take.md) | Array<string>
| |
+
diff --git a/docs/api/js-utils.arraymapperoptions.rest.md b/docs/api/js-utils.arraymapperoptions.rest.md
new file mode 100644
index 0000000..2e807ab
--- /dev/null
+++ b/docs/api/js-utils.arraymapperoptions.rest.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ArrayMapperOptions](./js-utils.arraymapperoptions.md) > [rest](./js-utils.arraymapperoptions.rest.md)
+
+## ArrayMapperOptions.rest property
+
+Signature:
+
+```typescript
+rest: string;
+```
diff --git a/docs/api/js-utils.arraymapperoptions.skip.md b/docs/api/js-utils.arraymapperoptions.skip.md
new file mode 100644
index 0000000..b9ebd0e
--- /dev/null
+++ b/docs/api/js-utils.arraymapperoptions.skip.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ArrayMapperOptions](./js-utils.arraymapperoptions.md) > [skip](./js-utils.arraymapperoptions.skip.md)
+
+## ArrayMapperOptions.skip property
+
+Signature:
+
+```typescript
+skip: number;
+```
diff --git a/docs/api/js-utils.arraymapperoptions.take.md b/docs/api/js-utils.arraymapperoptions.take.md
new file mode 100644
index 0000000..adb4a64
--- /dev/null
+++ b/docs/api/js-utils.arraymapperoptions.take.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ArrayMapperOptions](./js-utils.arraymapperoptions.md) > [take](./js-utils.arraymapperoptions.take.md)
+
+## ArrayMapperOptions.take property
+
+Signature:
+
+```typescript
+take: Array;
+```
diff --git a/docs/api/js-utils.childoptions.args.md b/docs/api/js-utils.childoptions.args.md
new file mode 100644
index 0000000..eb8bd87
--- /dev/null
+++ b/docs/api/js-utils.childoptions.args.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildOptions](./js-utils.childoptions.md) > [args](./js-utils.childoptions.args.md)
+
+## ChildOptions.args property
+
+Signature:
+
+```typescript
+args: Array;
+```
diff --git a/docs/api/js-utils.childoptions.command.md b/docs/api/js-utils.childoptions.command.md
new file mode 100644
index 0000000..d479e68
--- /dev/null
+++ b/docs/api/js-utils.childoptions.command.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildOptions](./js-utils.childoptions.md) > [command](./js-utils.childoptions.command.md)
+
+## ChildOptions.command property
+
+Signature:
+
+```typescript
+command: string;
+```
diff --git a/docs/api/js-utils.childoptions.cwd.md b/docs/api/js-utils.childoptions.cwd.md
new file mode 100644
index 0000000..690079b
--- /dev/null
+++ b/docs/api/js-utils.childoptions.cwd.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildOptions](./js-utils.childoptions.md) > [cwd](./js-utils.childoptions.cwd.md)
+
+## ChildOptions.cwd property
+
+Signature:
+
+```typescript
+cwd: string;
+```
diff --git a/docs/api/js-utils.childoptions.env.md b/docs/api/js-utils.childoptions.env.md
new file mode 100644
index 0000000..f93e870
--- /dev/null
+++ b/docs/api/js-utils.childoptions.env.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildOptions](./js-utils.childoptions.md) > [env](./js-utils.childoptions.env.md)
+
+## ChildOptions.env property
+
+Signature:
+
+```typescript
+env: Array>;
+```
diff --git a/docs/api/js-utils.childoptions.md b/docs/api/js-utils.childoptions.md
new file mode 100644
index 0000000..02bb559
--- /dev/null
+++ b/docs/api/js-utils.childoptions.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildOptions](./js-utils.childoptions.md)
+
+## ChildOptions interface
+
+Signature:
+
+```typescript
+export interface ChildOptions
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [args](./js-utils.childoptions.args.md) | Array<string>
| |
+| [command](./js-utils.childoptions.command.md) | string
| |
+| [cwd](./js-utils.childoptions.cwd.md) | string
| |
+| [env](./js-utils.childoptions.env.md) | Array<NameValuePair<string>>
| |
+| [timeout](./js-utils.childoptions.timeout.md) | number
| |
+
diff --git a/docs/api/js-utils.childoptions.timeout.md b/docs/api/js-utils.childoptions.timeout.md
new file mode 100644
index 0000000..77f66c8
--- /dev/null
+++ b/docs/api/js-utils.childoptions.timeout.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildOptions](./js-utils.childoptions.md) > [timeout](./js-utils.childoptions.timeout.md)
+
+## ChildOptions.timeout property
+
+Signature:
+
+```typescript
+timeout: number;
+```
diff --git a/docs/api/js-utils.childresult.md b/docs/api/js-utils.childresult.md
new file mode 100644
index 0000000..6cba88f
--- /dev/null
+++ b/docs/api/js-utils.childresult.md
@@ -0,0 +1,20 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildResult](./js-utils.childresult.md)
+
+## ChildResult interface
+
+Signature:
+
+```typescript
+export interface ChildResult
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [status](./js-utils.childresult.status.md) | number
| |
+| [stderr](./js-utils.childresult.stderr.md) | string
| |
+| [stdout](./js-utils.childresult.stdout.md) | string
| |
+
diff --git a/docs/api/js-utils.childresult.status.md b/docs/api/js-utils.childresult.status.md
new file mode 100644
index 0000000..366e8b2
--- /dev/null
+++ b/docs/api/js-utils.childresult.status.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildResult](./js-utils.childresult.md) > [status](./js-utils.childresult.status.md)
+
+## ChildResult.status property
+
+Signature:
+
+```typescript
+status: number;
+```
diff --git a/docs/api/js-utils.childresult.stderr.md b/docs/api/js-utils.childresult.stderr.md
new file mode 100644
index 0000000..74a505c
--- /dev/null
+++ b/docs/api/js-utils.childresult.stderr.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildResult](./js-utils.childresult.md) > [stderr](./js-utils.childresult.stderr.md)
+
+## ChildResult.stderr property
+
+Signature:
+
+```typescript
+stderr: string;
+```
diff --git a/docs/api/js-utils.childresult.stdout.md b/docs/api/js-utils.childresult.stdout.md
new file mode 100644
index 0000000..bfdc659
--- /dev/null
+++ b/docs/api/js-utils.childresult.stdout.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildResult](./js-utils.childresult.md) > [stdout](./js-utils.childresult.stdout.md)
+
+## ChildResult.stdout property
+
+Signature:
+
+```typescript
+stdout: string;
+```
diff --git a/docs/api/js-utils.childspawner.md b/docs/api/js-utils.childspawner.md
new file mode 100644
index 0000000..4d062bd
--- /dev/null
+++ b/docs/api/js-utils.childspawner.md
@@ -0,0 +1,11 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ChildSpawner](./js-utils.childspawner.md)
+
+## ChildSpawner type
+
+Signature:
+
+```typescript
+export declare type ChildSpawner = typeof spawn;
+```
diff --git a/docs/api/js-utils.constructorname.md b/docs/api/js-utils.constructorname.md
new file mode 100644
index 0000000..85967a8
--- /dev/null
+++ b/docs/api/js-utils.constructorname.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [constructorName](./js-utils.constructorname.md)
+
+## constructorName() function
+
+Signature:
+
+```typescript
+export declare function constructorName(val: object): string;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| val | object
| |
+
+Returns:
+
+`string`
+
diff --git a/docs/api/js-utils.getconstructor.md b/docs/api/js-utils.getconstructor.md
new file mode 100644
index 0000000..357efc6
--- /dev/null
+++ b/docs/api/js-utils.getconstructor.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [getConstructor](./js-utils.getconstructor.md)
+
+## getConstructor() function
+
+Signature:
+
+```typescript
+export declare function getConstructor(val: object): Function;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| val | object
| |
+
+Returns:
+
+`Function`
+
diff --git a/docs/api/js-utils.gethead.md b/docs/api/js-utils.gethead.md
new file mode 100644
index 0000000..d0703f9
--- /dev/null
+++ b/docs/api/js-utils.gethead.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [getHead](./js-utils.gethead.md)
+
+## getHead() function
+
+Signature:
+
+```typescript
+export declare function getHead(map: Map>, key: TKey): TVal;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| map | Map<TKey, Array<TVal>>
| |
+| key | TKey
| |
+
+Returns:
+
+`TVal`
+
diff --git a/docs/api/js-utils.getheadordefault.md b/docs/api/js-utils.getheadordefault.md
new file mode 100644
index 0000000..b77594d
--- /dev/null
+++ b/docs/api/js-utils.getheadordefault.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [getHeadOrDefault](./js-utils.getheadordefault.md)
+
+## getHeadOrDefault() function
+
+Signature:
+
+```typescript
+export declare function getHeadOrDefault(map: Map>>, key: TKey, defaultValue: TVal): TVal;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| map | Map<TKey, Array<Optional<TVal>>>
| |
+| key | TKey
| |
+| defaultValue | TVal
| |
+
+Returns:
+
+`TVal`
+
diff --git a/docs/api/js-utils.getmethods.md b/docs/api/js-utils.getmethods.md
new file mode 100644
index 0000000..559d1e9
--- /dev/null
+++ b/docs/api/js-utils.getmethods.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [getMethods](./js-utils.getmethods.md)
+
+## getMethods() function
+
+Signature:
+
+```typescript
+export declare function getMethods(value: TValue): Set;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| value | TValue
| |
+
+Returns:
+
+`Set`
+
diff --git a/docs/api/js-utils.getordefault.md b/docs/api/js-utils.getordefault.md
new file mode 100644
index 0000000..2af9fa9
--- /dev/null
+++ b/docs/api/js-utils.getordefault.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [getOrDefault](./js-utils.getordefault.md)
+
+## getOrDefault() function
+
+Signature:
+
+```typescript
+export declare function getOrDefault(map: Map, key: TKey, defaultValue: TVal): TVal;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| map | Map<TKey, TVal>
| |
+| key | TKey
| |
+| defaultValue | TVal
| |
+
+Returns:
+
+`TVal`
+
diff --git a/docs/api/js-utils.leftpad.md b/docs/api/js-utils.leftpad.md
new file mode 100644
index 0000000..5ed95d2
--- /dev/null
+++ b/docs/api/js-utils.leftpad.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [leftPad](./js-utils.leftpad.md)
+
+## leftPad() function
+
+Signature:
+
+```typescript
+export declare function leftPad(val: string, min?: number, fill?: string): string;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| val | string
| |
+| min | number
| |
+| fill | string
| |
+
+Returns:
+
+`string`
+
diff --git a/docs/api/js-utils.md b/docs/api/js-utils.md
index 6369b93..d568878 100644
--- a/docs/api/js-utils.md
+++ b/docs/api/js-utils.md
@@ -22,6 +22,7 @@
| Function | Description |
| --- | --- |
| [concat(chunks)](./js-utils.concat.md) | |
+| [constructorName(val)](./js-utils.constructorname.md) | |
| [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) | |
| [defer(ms, val)](./js-utils.defer.md) | Resolve after a set amount of time. |
@@ -29,9 +30,15 @@
| [encode(chunks, encoding)](./js-utils.encode.md) | |
| [entriesOf(map)](./js-utils.entriesof.md) | |
| [filterNil(list)](./js-utils.filternil.md) | Remove any null or undefined items from the list. |
+| [getConstructor(val)](./js-utils.getconstructor.md) | |
+| [getHead(map, key)](./js-utils.gethead.md) | |
+| [getHeadOrDefault(map, key, defaultValue)](./js-utils.getheadordefault.md) | |
+| [getMethods(value)](./js-utils.getmethods.md) | |
+| [getOrDefault(map, key, defaultValue)](./js-utils.getordefault.md) | |
| [getTestLogger(verbose)](./js-utils.gettestlogger.md) | |
| [isDebug()](./js-utils.isdebug.md) | |
| [isNil(val)](./js-utils.isnil.md) | |
+| [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. |
@@ -40,19 +47,26 @@
| [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) | |
+| [pairsToMap(pairs)](./js-utils.pairstomap.md) | |
| [pushMergeMap(args)](./js-utils.pushmergemap.md) | |
| [removePid(path)](./js-utils.removepid.md) | |
| [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) | |
| [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) | |
+| [writeValue(stream, value)](./js-utils.writevalue.md) | |
## Interfaces
| Interface | Description |
| --- | --- |
+| [ArrayMapperOptions](./js-utils.arraymapperoptions.md) | |
+| [ChildOptions](./js-utils.childoptions.md) | |
+| [ChildResult](./js-utils.childresult.md) | |
| [Dict](./js-utils.dict.md) | |
| [ExternalModule](./js-utils.externalmodule.md) | |
@@ -68,6 +82,7 @@
| Type Alias | Description |
| --- | --- |
+| [ChildSpawner](./js-utils.childspawner.md) | |
| [MapLike](./js-utils.maplike.md) | A Map
or dictionary object with string keys and TVal
values. |
| [ModuleCtor](./js-utils.modulector.md) | |
| [Nil](./js-utils.nil.md) | Unset value. |
diff --git a/docs/api/js-utils.normalizemap.md b/docs/api/js-utils.normalizemap.md
new file mode 100644
index 0000000..cae9d45
--- /dev/null
+++ b/docs/api/js-utils.normalizemap.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [normalizeMap](./js-utils.normalizemap.md)
+
+## normalizeMap() function
+
+Signature:
+
+```typescript
+export declare function normalizeMap(map: MapLike): Dict>;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| map | MapLike<unknown>
| |
+
+Returns:
+
+`Dict>`
+
diff --git a/docs/api/js-utils.pairstomap.md b/docs/api/js-utils.pairstomap.md
new file mode 100644
index 0000000..52720a4
--- /dev/null
+++ b/docs/api/js-utils.pairstomap.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [pairsToMap](./js-utils.pairstomap.md)
+
+## pairsToMap() function
+
+Signature:
+
+```typescript
+export declare function pairsToMap(pairs: Array>): Map;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| pairs | Array<NameValuePair<TVal>>
| |
+
+Returns:
+
+`Map`
+
diff --git a/docs/api/js-utils.trim.md b/docs/api/js-utils.trim.md
new file mode 100644
index 0000000..c3a56d6
--- /dev/null
+++ b/docs/api/js-utils.trim.md
@@ -0,0 +1,24 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [trim](./js-utils.trim.md)
+
+## trim() function
+
+Signature:
+
+```typescript
+export declare function trim(val: string, max: number, tail?: string): string;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| val | string
| |
+| max | number
| |
+| tail | string
| |
+
+Returns:
+
+`string`
+
diff --git a/docs/api/js-utils.writevalue.md b/docs/api/js-utils.writevalue.md
new file mode 100644
index 0000000..c03ee1b
--- /dev/null
+++ b/docs/api/js-utils.writevalue.md
@@ -0,0 +1,23 @@
+
+
+[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [writeValue](./js-utils.writevalue.md)
+
+## writeValue() function
+
+Signature:
+
+```typescript
+export declare function writeValue(stream: Writable, value: string): Promise;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| stream | Writable
| |
+| value | string
| |
+
+Returns:
+
+`Promise`
+
diff --git a/src/index.ts b/src/index.ts
index 4a52c98..75a3ac4 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -28,6 +28,7 @@ export {
} from './utils';
export {
ArrayMapper,
+ ArrayMapperOptions,
} from './utils/ArrayMapper';
export {
defer,
@@ -37,17 +38,33 @@ export {
concat,
encode,
} from './utils/Buffer';
-export { waitForChild } from './utils/Child';
+export {
+ Checklist,
+ ChecklistMode,
+ ChecklistOptions,
+} from './utils/Checklist';
+export {
+ ChildOptions,
+ ChildResult,
+ ChildSpawner,
+ waitForChild,
+ writeValue,
+} from './utils/Child';
export { ExternalModule, ModuleCtor } from './utils/ExternalModule';
export { isDebug } from './utils/Env';
export {
Dict,
MapLike,
entriesOf,
+ getHead,
+ getHeadOrDefault,
+ getOrDefault,
makeDict,
makeMap,
mergeMap,
mustGet,
+ normalizeMap,
+ pairsToMap,
pushMergeMap,
setOrPush,
} from './utils/Map';
@@ -56,6 +73,7 @@ export {
writePid,
} from './utils/PidFile';
export {
+ constructorName,
getConstructor,
getMethods,
} from './utils/Reflect';
@@ -65,3 +83,7 @@ export {
SIGNAL_STOP,
signal,
} from './utils/Signal';
+export {
+ leftPad,
+ trim,
+} from './utils/String';
diff --git a/src/utils/Checklist.ts b/src/utils/Checklist.ts
new file mode 100644
index 0000000..8256d84
--- /dev/null
+++ b/src/utils/Checklist.ts
@@ -0,0 +1,31 @@
+export enum ChecklistMode {
+ INCLUDE = 'include',
+ EXCLUDE = 'exclude',
+}
+
+export interface ChecklistOptions {
+ data: Array;
+ mode: ChecklistMode;
+}
+
+export class Checklist implements ChecklistOptions {
+ public readonly data: Array;
+ public readonly mode: ChecklistMode;
+
+ constructor(options: ChecklistOptions) {
+ this.data = Array.from(options.data);
+ this.mode = options.mode;
+ }
+
+ public check(value: T): boolean {
+ if (this.mode === ChecklistMode.INCLUDE) {
+ return this.data.includes(value);
+ }
+
+ if (this.mode === ChecklistMode.EXCLUDE) {
+ return !this.data.includes(value);
+ }
+
+ return false;
+ }
+}