Skip to content

Commit

Permalink
allow Readonly<Partial<T>> in mergeDeep (not just PartialDeep) and ex…
Browse files Browse the repository at this point in the history
…pand internal array properly
  • Loading branch information
electrovir committed Oct 15, 2023
1 parent f7309eb commit ce98fab
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 61 deletions.
60 changes: 30 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "augment-vir",
"version": "21.3.1",
"version": "21.3.2",
"private": true,
"homepage": "https://github.com/electrovir/augment-vir",
"bugs": {
Expand Down
6 changes: 3 additions & 3 deletions packages/browser-testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/browser-testing",
"version": "21.3.1",
"version": "21.3.2",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
"bugs": {
"url": "https://github.com/electrovir/augment-vir/issues"
Expand All @@ -23,8 +23,8 @@
"test:coverage": "npm test"
},
"dependencies": {
"@augment-vir/common": "^21.3.1",
"@augment-vir/testing": "^21.3.1",
"@augment-vir/common": "^21.3.2",
"@augment-vir/testing": "^21.3.2",
"@open-wc/testing": "^3.2.0",
"@types/mocha": "^10.0.2",
"@web/test-runner-commands": "^0.8.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/browser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/browser",
"version": "21.3.1",
"version": "21.3.2",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/browser",
"bugs": {
"url": "https://github.com/electrovir/augment-vir/issues"
Expand All @@ -24,12 +24,12 @@
"test:watch": "web-test-runner --color --config configs/web-test-runner.config.mjs --watch"
},
"dependencies": {
"@augment-vir/common": "^21.3.1",
"@augment-vir/common": "^21.3.2",
"element-vir": "^16.4.7",
"html-spec-tags": "^1.0.0"
},
"devDependencies": {
"@augment-vir/browser-testing": "^21.3.1",
"@augment-vir/browser-testing": "^21.3.2",
"@open-wc/testing": "^3.2.0",
"@types/chai": "^4.3.8",
"@types/mocha": "^10.0.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/chai/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/chai",
"version": "21.3.1",
"version": "21.3.2",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
"bugs": {
"url": "https://github.com/electrovir/augment-vir/issues"
Expand All @@ -23,8 +23,8 @@
"test:coverage": "npm test"
},
"dependencies": {
"@augment-vir/common": "^21.3.1",
"@augment-vir/testing": "^21.3.1",
"@augment-vir/common": "^21.3.2",
"@augment-vir/testing": "^21.3.2",
"type-fest": "^4.4.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/common-tests/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/common-tests",
"version": "21.3.1",
"version": "21.3.2",
"private": true,
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common-tests",
"bugs": {
Expand All @@ -22,9 +22,9 @@
"test:types": "tsc --noEmit"
},
"devDependencies": {
"@augment-vir/chai": "^21.3.1",
"@augment-vir/common": "^21.3.1",
"@augment-vir/node-js": "^21.3.1",
"@augment-vir/chai": "^21.3.2",
"@augment-vir/common": "^21.3.2",
"@augment-vir/node-js": "^21.3.2",
"@electrovir/nyc": "^15.1.0-fix0",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/chai": "^4.3.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/common",
"version": "21.3.1",
"version": "21.3.2",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",
"bugs": {
"url": "https://github.com/electrovir/augment-vir/issues"
Expand Down
12 changes: 10 additions & 2 deletions packages/common/src/augments/object/merge-deep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import {isObject} from './object';
* Note that order matters! Each input object will overwrite the properties of the previous objects.
*/
export function mergeDeep<const T extends object>(
...inputs: (Readonly<T> | Readonly<PartialDeep<T, {recurseIntoArrays: true}>>)[]
...inputs: (
| Readonly<T>
| Readonly<PartialDeep<T, {recurseIntoArrays: true}>>
| Readonly<Partial<T>>
)[]
): T {
if (!isLengthAtLeast(inputs, 1)) {
// nothing to merge if no inputs
Expand Down Expand Up @@ -52,7 +56,11 @@ export function mergeDeep<const T extends object>(
};
}
} else {
result = {...individualInput};
if (isRuntimeTypeOf(individualInput, 'array')) {
result = [...individualInput];
} else {
result = {...individualInput};
}
}
} catch (error) {
/** Ignore errors, such as individualInput not actually being an object. */
Expand Down
6 changes: 3 additions & 3 deletions packages/docker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/docker",
"version": "21.3.1",
"version": "21.3.2",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/docker",
"bugs": {
"url": "https://github.com/electrovir/augment-vir/issues"
Expand All @@ -22,8 +22,8 @@
"test:coverage": "npm test"
},
"dependencies": {
"@augment-vir/common": "^21.3.1",
"@augment-vir/node-js": "^21.3.1"
"@augment-vir/common": "^21.3.2",
"@augment-vir/node-js": "^21.3.2"
},
"devDependencies": {
"typescript": "^5.2.2"
Expand Down
6 changes: 3 additions & 3 deletions packages/node-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/node-js",
"version": "21.3.1",
"version": "21.3.2",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/node-js",
"bugs": {
"url": "https://github.com/electrovir/augment-vir/issues"
Expand All @@ -22,15 +22,15 @@
"test:coverage": "npm test coverage"
},
"dependencies": {
"@augment-vir/common": "^21.3.1",
"@augment-vir/common": "^21.3.2",
"ansi-colors": "^4.1.3",
"axios": "^1.5.1",
"fs-extra": "^11.1.1",
"ts-node": "^10.9.1",
"type-fest": "^4.4.0"
},
"devDependencies": {
"@augment-vir/chai": "^21.3.1",
"@augment-vir/chai": "^21.3.2",
"@electrovir/nyc": "^15.1.0-fix0",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/chai": "^4.3.8",
Expand Down
6 changes: 3 additions & 3 deletions packages/prisma-node-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/prisma-node-js",
"version": "21.3.1",
"version": "21.3.2",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/prisma-node-js",
"bugs": {
"url": "https://github.com/electrovir/augment-vir/issues"
Expand All @@ -22,8 +22,8 @@
"test:coverage": "npm test"
},
"dependencies": {
"@augment-vir/common": "^21.3.1",
"@augment-vir/node-js": "^21.3.1"
"@augment-vir/common": "^21.3.2",
"@augment-vir/node-js": "^21.3.2"
},
"devDependencies": {
"istanbul-smart-text-reporter": "^1.1.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/scripts",
"version": "21.3.1",
"version": "21.3.2",
"private": true,
"license": "MIT",
"author": {
Expand All @@ -14,8 +14,8 @@
"verify": "ts-node src/index.ts"
},
"dependencies": {
"@augment-vir/common": "^21.3.1",
"@augment-vir/node-js": "^21.3.1"
"@augment-vir/common": "^21.3.2",
"@augment-vir/node-js": "^21.3.2"
},
"devDependencies": {
"@electrovir/nyc": "^15.1.0-fix0",
Expand Down
4 changes: 2 additions & 2 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@augment-vir/testing",
"version": "21.3.1",
"version": "21.3.2",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/testing",
"bugs": {
"url": "https://github.com/electrovir/augment-vir/issues"
Expand All @@ -23,7 +23,7 @@
"test:coverage": "npm test coverage"
},
"dependencies": {
"@augment-vir/common": "^21.3.1",
"@augment-vir/common": "^21.3.2",
"expect-type": "^0.15.0",
"type-fest": "^4.4.0"
},
Expand Down

0 comments on commit ce98fab

Please sign in to comment.