Skip to content

Commit

Permalink
fix: better support for readonly arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Jun 30, 2020
1 parent e34641a commit a4b8bf2
Show file tree
Hide file tree
Showing 24 changed files with 124 additions and 234 deletions.
2 changes: 1 addition & 1 deletion config/rollup-external.json
@@ -1,7 +1,7 @@
{
"names": [
"async_hooks",
"chai",
"fs",
"mock-fs",
"sinon"
]
Expand Down
12 changes: 8 additions & 4 deletions config/rollup.js
Expand Up @@ -42,9 +42,9 @@ const bundle = {
return 'vendor';
}

/* if (id.includes(`chai`) || id.includes(`sinon`)) {
if (id.includes(`chai`) || id.includes(`sinon`) || id.includes('source-map')) {
return 'test';
} */
}

if (id.includes(`${sep}node_modules${sep}`)) {
return 'vendor';
Expand All @@ -58,14 +58,18 @@ const bundle = {
return 'main';
}

if (flag_debug) {
console.log('file does not belong to any chunk:', id);
if (id.includes(process.env['HOME'])) {
return 'linked';
}

if (id.length === 30 && id.match(/^[a-f0-9]+$/)) {
return 'vendor';
}

if (flag_debug) {
console.log('file does not belong to any chunk:', id);
}

return 'nochunk';
},
output: {
Expand Down
13 changes: 0 additions & 13 deletions docs/api/js-utils.asynctracker._constructor_.md

This file was deleted.

15 changes: 0 additions & 15 deletions docs/api/js-utils.asynctracker.clear.md

This file was deleted.

15 changes: 0 additions & 15 deletions docs/api/js-utils.asynctracker.disable.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/api/js-utils.asynctracker.dump.md

This file was deleted.

15 changes: 0 additions & 15 deletions docs/api/js-utils.asynctracker.enable.md

This file was deleted.

11 changes: 0 additions & 11 deletions docs/api/js-utils.asynctracker.filter.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/api/js-utils.asynctracker.getstack.md

This file was deleted.

39 changes: 0 additions & 39 deletions docs/api/js-utils.asynctracker.md

This file was deleted.

11 changes: 0 additions & 11 deletions docs/api/js-utils.asynctracker.size.md

This file was deleted.

22 changes: 22 additions & 0 deletions docs/api/js-utils.ensurearray_1.md
@@ -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; [ensureArray](./js-utils.ensurearray_1.md)

## ensureArray() function

<b>Signature:</b>

```typescript
export declare function ensureArray<T>(val: Optional<ReadonlyArray<T>>): ReadonlyArray<T>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| val | [Optional](./js-utils.optional.md)<!-- -->&lt;ReadonlyArray&lt;T&gt;&gt; | |

<b>Returns:</b>

ReadonlyArray&lt;T&gt;

4 changes: 2 additions & 2 deletions docs/api/js-utils.gethead.md
Expand Up @@ -9,14 +9,14 @@ Get the first element from the specified key within a map of lists.
<b>Signature:</b>

```typescript
export declare function getHead<TKey, TVal>(map: Map<TKey, Array<TVal>>, key: TKey): TVal;
export declare function getHead<TKey, TVal>(map: Map<TKey, ReadonlyArray<TVal>>, key: TKey): TVal;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| map | Map&lt;TKey, Array&lt;TVal&gt;&gt; | |
| map | Map&lt;TKey, ReadonlyArray&lt;TVal&gt;&gt; | |
| key | TKey | |

<b>Returns:</b>
Expand Down
4 changes: 2 additions & 2 deletions docs/api/js-utils.getheadordefault.md
Expand Up @@ -9,14 +9,14 @@ Get the first element from the specified key, within a map of lists, or a defaul
<b>Signature:</b>

```typescript
export declare function getHeadOrDefault<TKey, TVal>(map: Map<TKey, Array<Optional<TVal>>>, key: TKey, defaultValue: TVal): TVal;
export declare function getHeadOrDefault<TKey, TVal>(map: Map<TKey, ReadonlyArray<Optional<TVal>>>, key: TKey, defaultValue: TVal): TVal;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| map | Map&lt;TKey, Array&lt;[Optional](./js-utils.optional.md)<!-- -->&lt;TVal&gt;&gt;&gt; | |
| map | Map&lt;TKey, ReadonlyArray&lt;[Optional](./js-utils.optional.md)<!-- -->&lt;TVal&gt;&gt;&gt; | |
| key | TKey | |
| defaultValue | TVal | |

Expand Down
6 changes: 3 additions & 3 deletions docs/api/js-utils.md
Expand Up @@ -9,7 +9,6 @@
| Class | Description |
| --- | --- |
| [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) | 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. |
Expand All @@ -36,6 +35,7 @@
| [doesExist(val)](./js-utils.doesexist.md) | Check if a variable is not nil. |
| [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. |
| [filterNil(list)](./js-utils.filternil.md) | Remove any null or undefined items from the list. |
| [getConstructor(val)](./js-utils.getconstructor.md) | Get the constructor from an instance. |
Expand All @@ -52,6 +52,7 @@
| [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. |
| [mergeList(parts)](./js-utils.mergelist_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. |
| [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. |
Expand All @@ -60,14 +61,13 @@
| [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) | Remove the file at the given <code>path</code>. |
| [pushMergeMap(args)](./js-utils.pushmergemap_1.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) | 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) | 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
22 changes: 22 additions & 0 deletions docs/api/js-utils.mergelist_1.md
@@ -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; [mergeList](./js-utils.mergelist_1.md)

## mergeList() function

<b>Signature:</b>

```typescript
export declare function mergeList<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;

4 changes: 2 additions & 2 deletions docs/api/js-utils.mergemap.md
Expand Up @@ -9,15 +9,15 @@ Merge the `source` map into the `target` map, replacing keys that already exist.
<b>Signature:</b>

```typescript
export declare function mergeMap<TKey, TVal>(target: Map<TKey, TVal>, source: Map<TKey, TVal> | Array<[TKey, TVal]>): Map<TKey, TVal>;
export declare function mergeMap<TKey, TVal>(target: Map<TKey, TVal>, source: Map<TKey, TVal> | ReadonlyArray<[TKey, TVal]>): Map<TKey, TVal>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| target | Map&lt;TKey, TVal&gt; | |
| source | Map&lt;TKey, TVal&gt; \| Array&lt;\[TKey, TVal\]&gt; | |
| source | Map&lt;TKey, TVal&gt; \| ReadonlyArray&lt;\[TKey, TVal\]&gt; | |

<b>Returns:</b>

Expand Down
4 changes: 2 additions & 2 deletions docs/api/js-utils.pairstomap.md
Expand Up @@ -9,14 +9,14 @@ Turns a list of name-value pairs into a map.
<b>Signature:</b>

```typescript
export declare function pairsToMap<TVal>(pairs: Array<NameValuePair<TVal>>): Map<string, TVal>;
export declare function pairsToMap<TVal>(pairs: ReadonlyArray<NameValuePair<TVal>>): Map<string, TVal>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| pairs | Array&lt;NameValuePair&lt;TVal&gt;&gt; | |
| pairs | ReadonlyArray&lt;NameValuePair&lt;TVal&gt;&gt; | |

<b>Returns:</b>

Expand Down
22 changes: 22 additions & 0 deletions docs/api/js-utils.pushmergemap_1.md
@@ -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; [pushMergeMap](./js-utils.pushmergemap_1.md)

## pushMergeMap() function

<b>Signature:</b>

```typescript
export declare function pushMergeMap<TKey, TVal>(...args: ReadonlyArray<Map<TKey, TVal | ReadonlyArray<TVal>>>): Map<TKey, ReadonlyArray<TVal>>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| args | ReadonlyArray&lt;Map&lt;TKey, TVal \| ReadonlyArray&lt;TVal&gt;&gt;&gt; | |

<b>Returns:</b>

Map&lt;TKey, ReadonlyArray&lt;TVal&gt;&gt;

0 comments on commit a4b8bf2

Please sign in to comment.