renommage de lib, rendre buildable
This commit is contained in:
parent
1706c64713
commit
a89007a81b
9896 changed files with 478996 additions and 496 deletions
390
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/CHANGELOG.md
generated
vendored
Normal file
390
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,390 @@
|
|||
# Changelog
|
||||
All notable changes to this project will be documented in this file. Dates are displayed in UTC.
|
||||
|
||||
## [7.1.5](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.1.4...v7.1.5) (2025-02-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* improve type merging of nested optional properties ([#530](https://github.com/RebeccaStevens/deepmerge-ts/issues/530)) ([349fd14](https://github.com/RebeccaStevens/deepmerge-ts/commit/349fd14d20405f2a56ff9ce788959db38fc970f4))
|
||||
|
||||
## [7.1.4](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.1.3...v7.1.4) (2025-01-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* apply filtering to types when selecting a leaf node ([#526](https://github.com/RebeccaStevens/deepmerge-ts/issues/526)) ([6d85163](https://github.com/RebeccaStevens/deepmerge-ts/commit/6d85163aecce3981b3a2f5378cb17f471fa7566b)), closes [#524](https://github.com/RebeccaStevens/deepmerge-ts/issues/524)
|
||||
|
||||
## [7.1.3](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.1.2...v7.1.3) (2024-10-08)
|
||||
|
||||
## [7.1.2](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.1.1...v7.1.2) (2024-10-08)
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* use more performant data structures ([#519](https://github.com/RebeccaStevens/deepmerge-ts/issues/519)) ([a48f8c4](https://github.com/RebeccaStevens/deepmerge-ts/commit/a48f8c4ccc32ec8937cc7177991a072a93e329b2))
|
||||
|
||||
## [7.1.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.1.0...v7.1.1) (2024-10-04)
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* add explicit return type to speed up types ([8e1ff6d](https://github.com/RebeccaStevens/deepmerge-ts/commit/8e1ff6d04abe4ae0d541bba817054578924ca3db))
|
||||
|
||||
# [7.1.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.0.3...v7.1.0) (2024-07-20)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **benchmark:** add `defu` to compare with ([#486](https://github.com/RebeccaStevens/deepmerge-ts/issues/486)) ([93599b4](https://github.com/RebeccaStevens/deepmerge-ts/commit/93599b4bb6cd341cbaef156d619530a16e34550f))
|
||||
|
||||
## [7.0.3](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.0.2...v7.0.3) (2024-06-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* merge functions' types ([ca94270](https://github.com/RebeccaStevens/deepmerge-ts/commit/ca94270da73d0a071043ef0e8936b17c444e40ab))
|
||||
|
||||
## [7.0.2](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.0.1...v7.0.2) (2024-06-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* support older module resolutions ([063675e](https://github.com/RebeccaStevens/deepmerge-ts/commit/063675eccc19f0565527a2ec584d76801ccfe249)), closes [#480](https://github.com/RebeccaStevens/deepmerge-ts/issues/480)
|
||||
|
||||
## [7.0.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v7.0.0...v7.0.1) (2024-05-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* handling of partial types ([1832bd0](https://github.com/RebeccaStevens/deepmerge-ts/commit/1832bd071b925c49a2d5d1c944703916ee4348d4)), closes [#476](https://github.com/RebeccaStevens/deepmerge-ts/issues/476)
|
||||
|
||||
# [7.0.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v6.0.3...v7.0.0) (2024-05-20)
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* rename DeepMergeFunctionUtils to DeepMergeUtils ([e821255](https://github.com/RebeccaStevens/deepmerge-ts/commit/e821255380dd9307041e6749c43d363e4e2ae633))
|
||||
* rename DeepMergeMerge* to DeepMerge* ([fd4d2d4](https://github.com/RebeccaStevens/deepmerge-ts/commit/fd4d2d462eec14841adc45d741148cc7a9449a1f))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow filtering out values before merging them ([0784f63](https://github.com/RebeccaStevens/deepmerge-ts/commit/0784f63befc4ab4d66b6f3ae4b2076fba203fb48)), closes [#460](https://github.com/RebeccaStevens/deepmerge-ts/issues/460)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* rename DeepMergeFunctionUtils to DeepMergeUtils
|
||||
* rename DeepMergeMerge* to DeepMerge*
|
||||
* allow filtering out values before merging them
|
||||
|
||||
## [6.0.3](https://github.com/RebeccaStevens/deepmerge-ts/compare/v6.0.2...v6.0.3) (2024-05-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* deepmergeInto unsafe key value assignment ([6b04863](https://github.com/RebeccaStevens/deepmerge-ts/commit/6b048630ca13052927a85a802a9fe9977519db4c))
|
||||
|
||||
## [6.0.2](https://github.com/RebeccaStevens/deepmerge-ts/compare/v6.0.1...v6.0.2) (2024-05-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* return type when using empty records ([6b4ff3f](https://github.com/RebeccaStevens/deepmerge-ts/commit/6b4ff3f42951cd9b548d2b4adb184fed4e35be2d)), closes [#465](https://github.com/RebeccaStevens/deepmerge-ts/issues/465)
|
||||
|
||||
## [6.0.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v6.0.0...v6.0.1) (2024-05-20)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* type when merging index signatures ([5e8b9b6](https://github.com/RebeccaStevens/deepmerge-ts/commit/5e8b9b668a13ef51da10a5321d4698d01d872013)), closes [#459](https://github.com/RebeccaStevens/deepmerge-ts/issues/459)
|
||||
|
||||
# [6.0.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v5.1.0...v6.0.0) (2024-05-19)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* type when merging optional properties of a record ([fa9ace2](https://github.com/RebeccaStevens/deepmerge-ts/commit/fa9ace2a2b38030d12fa85634966d409b8bb123f))
|
||||
|
||||
|
||||
### Build System
|
||||
|
||||
* remove typing support for typescript<4.7 ([f2f5956](https://github.com/RebeccaStevens/deepmerge-ts/commit/f2f5956d653a672073fc3c0174f9d8d6ca9d4371))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow restricting what types can be passed in as parameters ([69e9ba3](https://github.com/RebeccaStevens/deepmerge-ts/commit/69e9ba3519319eb02763887f457549340e9a9c76)), closes [#305](https://github.com/RebeccaStevens/deepmerge-ts/issues/305)
|
||||
* remove deprecated type DeepMergeLeafHKT ([1982e56](https://github.com/RebeccaStevens/deepmerge-ts/commit/1982e56016cbbbfd07f78e8512b56e8294ff83c0))
|
||||
* undefined will no longer replace defined values by default ([9c86605](https://github.com/RebeccaStevens/deepmerge-ts/commit/9c866054cbade77118b5cd62b1e8e68033fe2879))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* remove BlacklistedRecordProps ([19d4944](https://github.com/RebeccaStevens/deepmerge-ts/commit/19d4944fa228d66d5af93f419526ffaf8b5a376b))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* remove deprecated type DeepMergeLeafHKT
|
||||
* undefined will no longer replace defined values by default
|
||||
* The order of the generics of `deepmergeCustom`
|
||||
and `deepmergeIntoCustom` have changed. If you are passing generics
|
||||
to these functions you need to update them.
|
||||
* remove typing support for typescript<4.7
|
||||
|
||||
# [5.1.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v5.0.0...v5.1.0) (2023-04-04)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* expose some of the internal utils ([a11a03d](https://github.com/RebeccaStevens/deepmerge-ts/commit/a11a03d0fcd5e1caad371c5eb5a19052b8980691))
|
||||
|
||||
# [5.0.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.3.0...v5.0.0) (2023-03-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add missing dev dep ([df4add2](https://github.com/RebeccaStevens/deepmerge-ts/commit/df4add2a0aba101b0b00527cb105d194e17bdfaf))
|
||||
* remove unneeded eslint disable ([be28290](https://github.com/RebeccaStevens/deepmerge-ts/commit/be28290a3efb533ab339ef88e297b3e057708603))
|
||||
* use default MM generics ([944b428](https://github.com/RebeccaStevens/deepmerge-ts/commit/944b428e3779904c32d071a2761753872ab717f4)), closes [#304](https://github.com/RebeccaStevens/deepmerge-ts/issues/304)
|
||||
|
||||
|
||||
### chore
|
||||
|
||||
* drop support for node 12 and 14 ([77016f7](https://github.com/RebeccaStevens/deepmerge-ts/commit/77016f70664b6f5857b9f278912a31aa219be80d))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* drop support for node 12 and 14
|
||||
|
||||
# [5.0.0-next.4](https://github.com/RebeccaStevens/deepmerge-ts/compare/v5.0.0-next.3...v5.0.0-next.4) (2023-03-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* remove unneeded eslint disable ([be28290](https://github.com/RebeccaStevens/deepmerge-ts/commit/be28290a3efb533ab339ef88e297b3e057708603))
|
||||
* use default MM generics ([944b428](https://github.com/RebeccaStevens/deepmerge-ts/commit/944b428e3779904c32d071a2761753872ab717f4)), closes [#304](https://github.com/RebeccaStevens/deepmerge-ts/issues/304)
|
||||
|
||||
# [5.0.0-next.3](https://github.com/RebeccaStevens/deepmerge-ts/compare/v5.0.0-next.2...v5.0.0-next.3) (2023-03-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add missing dev dep ([df4add2](https://github.com/RebeccaStevens/deepmerge-ts/commit/df4add2a0aba101b0b00527cb105d194e17bdfaf))
|
||||
|
||||
# [5.0.0-next.2](https://github.com/RebeccaStevens/deepmerge-ts/compare/v5.0.0-next.1...v5.0.0-next.2) (2023-02-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* create deepmergeInto function ([9c350a0](https://github.com/RebeccaStevens/deepmerge-ts/commit/9c350a051c16534907da459ff466a353b90d5505)), closes [#51](https://github.com/RebeccaStevens/deepmerge-ts/issues/51)
|
||||
|
||||
# [5.0.0-next.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.2.2...v5.0.0-next.1) (2023-02-02)
|
||||
|
||||
|
||||
### chore
|
||||
|
||||
* drop support for node 12 and 14 ([77016f7](https://github.com/RebeccaStevens/deepmerge-ts/commit/77016f70664b6f5857b9f278912a31aa219be80d))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* drop support for node 12 and 14
|
||||
# [4.3.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.2.2...v4.3.0) (2023-02-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* create deepmergeInto function ([9c350a0](https://github.com/RebeccaStevens/deepmerge-ts/commit/9c350a051c16534907da459ff466a353b90d5505)), closes [#51](https://github.com/RebeccaStevens/deepmerge-ts/issues/51)
|
||||
|
||||
## [4.2.2](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.2.1...v4.2.2) (2022-09-19)
|
||||
|
||||
## [4.2.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.2.0...v4.2.1) (2022-06-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* broken type info path ([#146](https://github.com/RebeccaStevens/deepmerge-ts/issues/146)) ([b875711](https://github.com/RebeccaStevens/deepmerge-ts/commit/b8757111ccff257e7403b5d91235b965b4542afd))
|
||||
|
||||
# [4.2.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.1.0...v4.2.0) (2022-06-15)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* export types for module resolution node 16 ([20241c5](https://github.com/RebeccaStevens/deepmerge-ts/commit/20241c5bdffcc77025ea778257193f1afbe40768))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **ts:** add variance annotations ([cecc9db](https://github.com/RebeccaStevens/deepmerge-ts/commit/cecc9dbcfc68335f04372e2fa339a347f71c90bc))
|
||||
* **ts:** use extends constraints on infer ([f053e76](https://github.com/RebeccaStevens/deepmerge-ts/commit/f053e76221fb790f1dead0b2b5c9a9f4432cb1d8))
|
||||
|
||||
# [4.1.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.0.4...v4.1.0) (2022-06-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* treat module imports as records ([20c0dfb](https://github.com/RebeccaStevens/deepmerge-ts/commit/20c0dfb82e4273b10e5a02ba0e74aada42b9bb7a)), closes [#133](https://github.com/RebeccaStevens/deepmerge-ts/issues/133)
|
||||
|
||||
## [4.0.4](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.0.3...v4.0.4) (2022-06-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* drop keys that have no enumerable properties ([3363570](https://github.com/RebeccaStevens/deepmerge-ts/commit/3363570fcc53488d22a2d4b778b558173c7ee5c9))
|
||||
|
||||
## [4.0.3](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.0.2...v4.0.3) (2022-04-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* use explict return types for function that return a HKT ([eb4183e](https://github.com/RebeccaStevens/deepmerge-ts/commit/eb4183e5441ea8b36bbb8f24ffa38ba850eb389c)), closes [#94](https://github.com/RebeccaStevens/deepmerge-ts/issues/94)
|
||||
|
||||
## [4.0.2](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.0.1...v4.0.2) (2022-03-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* protect against prototype pollution ([d637db7](https://github.com/RebeccaStevens/deepmerge-ts/commit/d637db7e4fb2bfb113cb4bc1c85a125936d7081b))
|
||||
|
||||
## [4.0.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v4.0.0...v4.0.1) (2022-03-14)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deno:** fix broken import in deno dist files ([#85](https://github.com/RebeccaStevens/deepmerge-ts/issues/85)) ([86faf2a](https://github.com/RebeccaStevens/deepmerge-ts/commit/86faf2a047488be2fbb1ff6a1edd005b5d4670cb))
|
||||
|
||||
# [4.0.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v3.0.1...v4.0.0) (2022-02-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* improve meta data typings ([#61](https://github.com/RebeccaStevens/deepmerge-ts/issues/61)) ([9a881d3](https://github.com/RebeccaStevens/deepmerge-ts/commit/9a881d3e55762da03b0d0f465d7e958d81fd0958))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow for default merging via a special return value ([658d1fd](https://github.com/RebeccaStevens/deepmerge-ts/commit/658d1fd454fe095e6c7f2be22ccf4823fe0ea6ef))
|
||||
* allow for implicit default merging ([1d5e617](https://github.com/RebeccaStevens/deepmerge-ts/commit/1d5e617bc4980f64a75fa9da1397979b2310fc06))
|
||||
* allow for skipping properties completely via a special return value ([#64](https://github.com/RebeccaStevens/deepmerge-ts/issues/64)) ([676f2f6](https://github.com/RebeccaStevens/deepmerge-ts/commit/676f2f6593d6baf0e1b31f29c83bac7c392e7ce2))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* MetaMetaData now must extends DeepMergeBuiltInMetaData
|
||||
|
||||
## [3.0.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v3.0.0...v3.0.1) (2022-02-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* allows readonly records in DeepMergeRecordsDefaultHKTInternalPropValueHelper ([#60](https://github.com/RebeccaStevens/deepmerge-ts/issues/60)) ([fc85dfa](https://github.com/RebeccaStevens/deepmerge-ts/commit/fc85dfa0cc579de127c8458e808f81cbca84d090))
|
||||
|
||||
# [3.0.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v2.0.1...v3.0.0) (2022-02-19)
|
||||
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
* unrequire unused types and values ([c78e373](https://github.com/RebeccaStevens/deepmerge-ts/commit/c78e3736fe725008b745a302233afacb2155db94))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* lone values will now be passed to mergeOthers rather than just returned ([#57](https://github.com/RebeccaStevens/deepmerge-ts/issues/57)) ([9c24584](https://github.com/RebeccaStevens/deepmerge-ts/commit/9c245846f8afbd8bc0fbe2a28626e6461f41ea53))
|
||||
* provide customizable meta data to custom merge functions ([3d96692](https://github.com/RebeccaStevens/deepmerge-ts/commit/3d96692386c363e3f4250b267cac1d78231457ff)), closes [#33](https://github.com/RebeccaStevens/deepmerge-ts/issues/33)
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* some types have changed for `deepmergeCustom`
|
||||
|
||||
## [2.0.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v2.0.0...v2.0.1) (2021-12-22)
|
||||
|
||||
# [2.0.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.7...v2.0.0) (2021-11-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add better support for readonly types ([#17](https://github.com/RebeccaStevens/deepmerge-ts/issues/17)) ([ee59064](https://github.com/RebeccaStevens/deepmerge-ts/commit/ee5906448bcc0fabef2a2b8e215d4c309d30b4db))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* interface DeepMergeMergeFunctionURItoKind's signature has changed
|
||||
|
||||
## [1.1.7](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.6...v1.1.7) (2021-11-22)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* incorrect resulting type when merging 3+ readonly tuples ([#20](https://github.com/RebeccaStevens/deepmerge-ts/issues/20)) ([696a1b2](https://github.com/RebeccaStevens/deepmerge-ts/commit/696a1b21ce225e11e38ee9ef3b92a28cf3ed6a4c))
|
||||
|
||||
## [1.1.6](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.5...v1.1.6) (2021-11-22)
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* convert recursive types to tail-recursive versions ([#15](https://github.com/RebeccaStevens/deepmerge-ts/issues/15)) ([4401ac2](https://github.com/RebeccaStevens/deepmerge-ts/commit/4401ac2d1651093ab855d3d4bdf6c9628c0767ab))
|
||||
|
||||
## [1.1.5](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.4...v1.1.5) (2021-10-18)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deno:** deno release fixup ([4b8ca98](https://github.com/RebeccaStevens/deepmerge-ts/commit/4b8ca9868de78228244b099dc2040c4cb16a649d))
|
||||
|
||||
## [1.1.4](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.3...v1.1.4) (2021-10-18)
|
||||
|
||||
## [1.1.3](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.2...v1.1.3) (2021-09-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* order of package exports ([#12](https://github.com/RebeccaStevens/deepmerge-ts/issues/12)) ([4117460](https://github.com/RebeccaStevens/deepmerge-ts/commit/41174607ee57568f123e1a5661f635d5d54f7c0c))
|
||||
|
||||
## [1.1.2](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.1...v1.1.2) (2021-09-17)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* current and legacy types trying to using the same file resulting in one being overridden ([#10](https://github.com/RebeccaStevens/deepmerge-ts/issues/10)) ([a5f334b](https://github.com/RebeccaStevens/deepmerge-ts/commit/a5f334b2c4f6735383ea419dd6d3206bcc0afe4a))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* add early escapes to loos when merging unknown types ([17a92e1](https://github.com/RebeccaStevens/deepmerge-ts/commit/17a92e1676a6b6c20f7e3fb1cc966ed5673dccf6))
|
||||
* directly request enumerable keys so that they don't need to then be filtered ([04a2a5f](https://github.com/RebeccaStevens/deepmerge-ts/commit/04a2a5fb24b1086c8130203451c2836f196e92c6))
|
||||
* use imperative loops when building merged result of records ([b36f7bc](https://github.com/RebeccaStevens/deepmerge-ts/commit/b36f7bcec43858658c06f8f4ac6deb17a9d7b2fe))
|
||||
|
||||
## [1.1.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.0...v1.1.1) (2021-09-16)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add legacy type information ([#6](https://github.com/RebeccaStevens/deepmerge-ts/issues/6)) ([c7e1019](https://github.com/RebeccaStevens/deepmerge-ts/commit/c7e1019f86818fe95b9f6291f2a09f077337a7f9))
|
||||
* only merge enumerable properties ([#8](https://github.com/RebeccaStevens/deepmerge-ts/issues/8)) ([0967070](https://github.com/RebeccaStevens/deepmerge-ts/commit/0967070d30427bb33f0c78793d61a9411dde3b49))
|
||||
|
||||
# [1.1.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.0.1...v1.1.0) (2021-09-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add support for custom merging ([#4](https://github.com/RebeccaStevens/deepmerge-ts/issues/4)) ([5413b81](https://github.com/RebeccaStevens/deepmerge-ts/commit/5413b81c0a568c798ff70081966dd9a0ace5fe3f))
|
||||
|
||||
## [1.0.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.0.0...v1.0.1) (2021-08-25)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* husky install no longer runs on postinstall ([7102229](https://github.com/RebeccaStevens/deepmerge-ts/commit/7102229a7078fef17ba2a24c9814a844fb525c67))
|
||||
|
||||
# 1.0.0 (2021-08-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add "module" property to package.json ([168747d](https://github.com/RebeccaStevens/deepmerge-ts/commit/168747daef0b49ab8ac3b0491fda965776eef2c2))
|
||||
* add basic functionality ([8e3ba66](https://github.com/RebeccaStevens/deepmerge-ts/commit/8e3ba66973d6e35cc421149a00a45b7c55c1de45))
|
29
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/LICENSE
generated
vendored
Normal file
29
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2021, Rebecca Stevens
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
185
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/README.md
generated
vendored
Normal file
185
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/README.md
generated
vendored
Normal file
|
@ -0,0 +1,185 @@
|
|||
<div align="center">
|
||||
|
||||
# DeepmergeTS
|
||||
|
||||
[](https://www.npmjs.com/package/deepmerge-ts)
|
||||
[](https://jsr.io/@rebeccastevens/deepmerge)
|
||||
[](https://github.com/RebeccaStevens/deepmerge-ts/actions/workflows/release.yml)
|
||||
[](https://codecov.io/gh/RebeccaStevens/deepmerge-ts)\
|
||||
[](https://github.com/prettier/prettier)
|
||||
[](https://github.com/RebeccaStevens/deepmerge-ts/discussions)
|
||||
[](https://opensource.org/licenses/BSD-3-Clause)
|
||||
[](https://commitizen.github.io/cz-cli/)
|
||||
[](https://github.com/semantic-release/semantic-release)
|
||||
|
||||
Deeply merge 2 or more objects respecting type information.
|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
## Donate
|
||||
|
||||
[Any donations would be much appreciated](./DONATIONS.md). 😄
|
||||
|
||||
### Enterprise Users
|
||||
|
||||
`deepmerge-ts` is available as part of the Tidelift Subscription.
|
||||
|
||||
Tidelift is working with the maintainers of `deepmerge-ts` and a growing network of open source maintainers to ensure
|
||||
your open source software supply chain meets enterprise standards now and into the future.
|
||||
[Learn more.](https://tidelift.com/subscription/pkg/npm-deepmerge-ts?utm_source=npm-deepmerge-ts&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
|
||||
## Installation
|
||||
|
||||
### npm
|
||||
|
||||
```sh
|
||||
# Install with npm
|
||||
npm install deepmerge-ts
|
||||
|
||||
# Install with pnpm
|
||||
pnpm add deepmerge-ts
|
||||
|
||||
# Install with yarn
|
||||
yarn add deepmerge-ts
|
||||
|
||||
# Install with bun
|
||||
bun add deepmerge-ts
|
||||
```
|
||||
|
||||
### jsr
|
||||
|
||||
```sh
|
||||
# Install in a node project
|
||||
npx jsr add @rebeccastevens/deepmerge
|
||||
|
||||
# Install in a deno project
|
||||
deno add jsr:@rebeccastevens/deepmerge
|
||||
|
||||
# Install in a bun project
|
||||
bunx jsr add @rebeccastevens/deepmerge
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Smart merging - High performance.
|
||||
- Merged output has correct typing.
|
||||
- Record merging support.
|
||||
- Array merging support.
|
||||
- Map and Set merging support.
|
||||
- Customized merging.
|
||||
|
||||
## Usage
|
||||
|
||||
### Example using default config
|
||||
|
||||
```js
|
||||
import { deepmerge } from "deepmerge-ts";
|
||||
|
||||
const x = {
|
||||
record: {
|
||||
prop1: "value1",
|
||||
prop2: "value2",
|
||||
},
|
||||
array: [1, 2, 3],
|
||||
set: new Set([1, 2, 3]),
|
||||
map: new Map([
|
||||
["key1", "value1"],
|
||||
["key2", "value2"],
|
||||
]),
|
||||
};
|
||||
|
||||
const y = {
|
||||
record: {
|
||||
prop1: "changed",
|
||||
prop3: "value3",
|
||||
},
|
||||
array: [2, 3, 4],
|
||||
set: new Set([2, 3, 4]),
|
||||
map: new Map([
|
||||
["key2", "changed"],
|
||||
["key3", "value3"],
|
||||
]),
|
||||
};
|
||||
|
||||
const z = {
|
||||
record: {
|
||||
prop1: undefined,
|
||||
prop3: undefined,
|
||||
prop2: undefined,
|
||||
prop4: undefined,
|
||||
},
|
||||
array: undefined,
|
||||
set: undefined,
|
||||
map: undefined,
|
||||
};
|
||||
|
||||
const merged = deepmerge(x, y, z);
|
||||
|
||||
console.log(merged);
|
||||
|
||||
// Prettierfied output:
|
||||
//
|
||||
// Object {
|
||||
// "record": Object {
|
||||
// "prop1": "changed",
|
||||
// "prop2": "value2",
|
||||
// "prop3": "value3",
|
||||
// "prop4": undefined,
|
||||
// },
|
||||
// "array": Array [1, 2, 3, 2, 3, 4],
|
||||
// "set": Set { 1, 2, 3, 4 },
|
||||
// "map": Map {
|
||||
// "key1" => "value1",
|
||||
// "key2" => "changed",
|
||||
// "key3" => "value3",
|
||||
// },
|
||||
// }
|
||||
```
|
||||
|
||||
You can try out this example at
|
||||
[codesandbox.io](https://codesandbox.io/s/deepmerge-ts-example-iltxby?file=/src/example.ts).
|
||||
|
||||
### Merging into a Target
|
||||
|
||||
You can use `deepmergeInto` if you want to update a target object with the merge result instead of creating a new
|
||||
object.
|
||||
|
||||
This function is best used with objects that are all of the same type.
|
||||
|
||||
Note: If the target object's type differs from the input objects, we'll assert that the target's type has changed
|
||||
(this is not done automatically with `deepmergeIntoCustom`).
|
||||
|
||||
### Customized the Merging Process
|
||||
|
||||
We provide a customizer function for each of our main deepmerge functions: `deepmergeCustom` and `deepmergeIntoCustom`.
|
||||
You can use these to customize the details of how values should be merged together.
|
||||
|
||||
See [deepmerge custom docs](./docs/deepmergeCustom.md) for more details.
|
||||
|
||||
## Performance
|
||||
|
||||
We use smart merging instead of the classic merging strategy which some alternative libraries use. This vastly improves
|
||||
performance, both in execution time and memory usage.
|
||||
|
||||
### Classic Merge (not what we do)
|
||||
|
||||
With classic merging, each input is merged with the next input until all inputs are merged.
|
||||
|
||||
This strategy has large performance issues when lots of items need to be merged.
|
||||
|
||||

|
||||
|
||||
### Smart Merge (what we do)
|
||||
|
||||
With our smart merging, we look ahead to see what can be merged and only merge those things.
|
||||
|
||||
In addition to performance improvements, this strategy merges multiple inputs at once; allowing for benefits such as
|
||||
taking averages of the inputs.
|
||||
|
||||

|
||||
|
||||
## API
|
||||
|
||||
See [API docs](./docs/API.md).
|
619
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/dist/index.cjs
generated
vendored
Normal file
619
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/dist/index.cjs
generated
vendored
Normal file
|
@ -0,0 +1,619 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Special values that tell deepmerge to perform a certain action.
|
||||
*/
|
||||
const actions = {
|
||||
defaultMerge: Symbol("deepmerge-ts: default merge"),
|
||||
skip: Symbol("deepmerge-ts: skip"),
|
||||
};
|
||||
/**
|
||||
* Special values that tell deepmergeInto to perform a certain action.
|
||||
*/
|
||||
const actionsInto = {
|
||||
defaultMerge: actions.defaultMerge,
|
||||
};
|
||||
|
||||
/**
|
||||
* The default function to update meta data.
|
||||
*
|
||||
* It doesn't update the meta data.
|
||||
*/
|
||||
function defaultMetaDataUpdater(previousMeta, metaMeta) {
|
||||
return metaMeta;
|
||||
}
|
||||
/**
|
||||
* The default function to filter values.
|
||||
*
|
||||
* It filters out undefined values.
|
||||
*/
|
||||
function defaultFilterValues(values, meta) {
|
||||
return values.filter((value) => value !== undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* The different types of objects deepmerge-ts support.
|
||||
*/
|
||||
var ObjectType;
|
||||
(function (ObjectType) {
|
||||
ObjectType[ObjectType["NOT"] = 0] = "NOT";
|
||||
ObjectType[ObjectType["RECORD"] = 1] = "RECORD";
|
||||
ObjectType[ObjectType["ARRAY"] = 2] = "ARRAY";
|
||||
ObjectType[ObjectType["SET"] = 3] = "SET";
|
||||
ObjectType[ObjectType["MAP"] = 4] = "MAP";
|
||||
ObjectType[ObjectType["OTHER"] = 5] = "OTHER";
|
||||
})(ObjectType || (ObjectType = {}));
|
||||
/**
|
||||
* Get the type of the given object.
|
||||
*
|
||||
* @param object - The object to get the type of.
|
||||
* @returns The type of the given object.
|
||||
*/
|
||||
function getObjectType(object) {
|
||||
if (typeof object !== "object" || object === null) {
|
||||
return 0 /* ObjectType.NOT */;
|
||||
}
|
||||
if (Array.isArray(object)) {
|
||||
return 2 /* ObjectType.ARRAY */;
|
||||
}
|
||||
if (isRecord(object)) {
|
||||
return 1 /* ObjectType.RECORD */;
|
||||
}
|
||||
if (object instanceof Set) {
|
||||
return 3 /* ObjectType.SET */;
|
||||
}
|
||||
if (object instanceof Map) {
|
||||
return 4 /* ObjectType.MAP */;
|
||||
}
|
||||
return 5 /* ObjectType.OTHER */;
|
||||
}
|
||||
/**
|
||||
* Get the keys of the given objects including symbol keys.
|
||||
*
|
||||
* Note: Only keys to enumerable properties are returned.
|
||||
*
|
||||
* @param objects - An array of objects to get the keys of.
|
||||
* @returns A set containing all the keys of all the given objects.
|
||||
*/
|
||||
function getKeys(objects) {
|
||||
const keys = new Set();
|
||||
for (const object of objects) {
|
||||
for (const key of [...Object.keys(object), ...Object.getOwnPropertySymbols(object)]) {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
/**
|
||||
* Does the given object have the given property.
|
||||
*
|
||||
* @param object - The object to test.
|
||||
* @param property - The property to test.
|
||||
* @returns Whether the object has the property.
|
||||
*/
|
||||
function objectHasProperty(object, property) {
|
||||
return typeof object === "object" && Object.prototype.propertyIsEnumerable.call(object, property);
|
||||
}
|
||||
/**
|
||||
* Get an iterable object that iterates over the given iterables.
|
||||
*/
|
||||
function getIterableOfIterables(iterables) {
|
||||
let mut_iterablesIndex = 0;
|
||||
let mut_iterator = iterables[0]?.[Symbol.iterator]();
|
||||
return {
|
||||
[Symbol.iterator]() {
|
||||
return {
|
||||
next() {
|
||||
do {
|
||||
if (mut_iterator === undefined) {
|
||||
return { done: true, value: undefined };
|
||||
}
|
||||
const result = mut_iterator.next();
|
||||
if (result.done === true) {
|
||||
mut_iterablesIndex += 1;
|
||||
mut_iterator = iterables[mut_iterablesIndex]?.[Symbol.iterator]();
|
||||
continue;
|
||||
}
|
||||
return {
|
||||
done: false,
|
||||
value: result.value,
|
||||
};
|
||||
} while (true);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
// eslint-disable-next-line unicorn/prefer-set-has -- Array is more performant for a low number of elements.
|
||||
const validRecordToStringValues = ["[object Object]", "[object Module]"];
|
||||
/**
|
||||
* Does the given object appear to be a record.
|
||||
*/
|
||||
function isRecord(value) {
|
||||
// All records are objects.
|
||||
if (!validRecordToStringValues.includes(Object.prototype.toString.call(value))) {
|
||||
return false;
|
||||
}
|
||||
const { constructor } = value;
|
||||
// If has modified constructor.
|
||||
// eslint-disable-next-line ts/no-unnecessary-condition
|
||||
if (constructor === undefined) {
|
||||
return true;
|
||||
}
|
||||
const prototype = constructor.prototype;
|
||||
// If has modified prototype.
|
||||
if (prototype === null ||
|
||||
typeof prototype !== "object" ||
|
||||
!validRecordToStringValues.includes(Object.prototype.toString.call(prototype))) {
|
||||
return false;
|
||||
}
|
||||
// If constructor does not have an Object-specific method.
|
||||
// eslint-disable-next-line sonar/prefer-single-boolean-return, no-prototype-builtins
|
||||
if (!prototype.hasOwnProperty("isPrototypeOf")) {
|
||||
return false;
|
||||
}
|
||||
// Most likely a record.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default strategy to merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecords$1(values, utils, meta) {
|
||||
const result = {};
|
||||
for (const key of getKeys(values)) {
|
||||
const propValues = [];
|
||||
for (const value of values) {
|
||||
if (objectHasProperty(value, key)) {
|
||||
propValues.push(value[key]);
|
||||
}
|
||||
}
|
||||
if (propValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updatedMeta = utils.metaDataUpdater(meta, {
|
||||
key,
|
||||
parents: values,
|
||||
});
|
||||
const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
|
||||
if (propertyResult === actions.skip) {
|
||||
continue;
|
||||
}
|
||||
if (key === "__proto__") {
|
||||
Object.defineProperty(result, key, {
|
||||
value: propertyResult,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
result[key] = propertyResult;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArrays$1(values) {
|
||||
return values.flat();
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSets$1(values) {
|
||||
return new Set(getIterableOfIterables(values));
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMaps$1(values) {
|
||||
return new Map(getIterableOfIterables(values));
|
||||
}
|
||||
/**
|
||||
* Get the last value in the given array.
|
||||
*/
|
||||
function mergeOthers$1(values) {
|
||||
return values.at(-1);
|
||||
}
|
||||
/**
|
||||
* The merge functions.
|
||||
*/
|
||||
const mergeFunctions = {
|
||||
mergeRecords: mergeRecords$1,
|
||||
mergeArrays: mergeArrays$1,
|
||||
mergeSets: mergeSets$1,
|
||||
mergeMaps: mergeMaps$1,
|
||||
mergeOthers: mergeOthers$1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
function deepmerge(...objects) {
|
||||
return deepmergeCustom({})(...objects);
|
||||
}
|
||||
function deepmergeCustom(options, rootMetaData) {
|
||||
const utils = getUtils(options, customizedDeepmerge);
|
||||
/**
|
||||
* The customized deepmerge function.
|
||||
*/
|
||||
function customizedDeepmerge(...objects) {
|
||||
return mergeUnknowns(objects, utils, rootMetaData);
|
||||
}
|
||||
return customizedDeepmerge;
|
||||
}
|
||||
/**
|
||||
* The the utils that are available to the merge functions.
|
||||
*
|
||||
* @param options - The options the user specified
|
||||
*/
|
||||
function getUtils(options, customizedDeepmerge) {
|
||||
return {
|
||||
defaultMergeFunctions: mergeFunctions,
|
||||
mergeFunctions: {
|
||||
...mergeFunctions,
|
||||
...Object.fromEntries(Object.entries(options)
|
||||
.filter(([key, option]) => Object.hasOwn(mergeFunctions, key))
|
||||
.map(([key, option]) => (option === false ? [key, mergeFunctions.mergeOthers] : [key, option]))),
|
||||
},
|
||||
metaDataUpdater: (options.metaDataUpdater ?? defaultMetaDataUpdater),
|
||||
deepmerge: customizedDeepmerge,
|
||||
useImplicitDefaultMerging: options.enableImplicitDefaultMerging ?? false,
|
||||
filterValues: options.filterValues === false ? undefined : (options.filterValues ?? defaultFilterValues),
|
||||
actions,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge unknown things.
|
||||
*
|
||||
* @param values - The values.
|
||||
*/
|
||||
function mergeUnknowns(values, utils, meta) {
|
||||
const filteredValues = utils.filterValues?.(values, meta) ?? values;
|
||||
if (filteredValues.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
if (filteredValues.length === 1) {
|
||||
return mergeOthers(filteredValues, utils, meta);
|
||||
}
|
||||
const type = getObjectType(filteredValues[0]);
|
||||
if (type !== 0 /* ObjectType.NOT */ && type !== 5 /* ObjectType.OTHER */) {
|
||||
for (let mut_index = 1; mut_index < filteredValues.length; mut_index++) {
|
||||
if (getObjectType(filteredValues[mut_index]) === type) {
|
||||
continue;
|
||||
}
|
||||
return mergeOthers(filteredValues, utils, meta);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case 1 /* ObjectType.RECORD */: {
|
||||
return mergeRecords(filteredValues, utils, meta);
|
||||
}
|
||||
case 2 /* ObjectType.ARRAY */: {
|
||||
return mergeArrays(filteredValues, utils, meta);
|
||||
}
|
||||
case 3 /* ObjectType.SET */: {
|
||||
return mergeSets(filteredValues, utils, meta);
|
||||
}
|
||||
case 4 /* ObjectType.MAP */: {
|
||||
return mergeMaps(filteredValues, utils, meta);
|
||||
}
|
||||
default: {
|
||||
return mergeOthers(filteredValues, utils, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecords(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeRecords(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeRecords !== utils.defaultMergeFunctions.mergeRecords)) {
|
||||
return utils.defaultMergeFunctions.mergeRecords(values, utils, meta);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArrays(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeArrays(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeArrays !== utils.defaultMergeFunctions.mergeArrays)) {
|
||||
return utils.defaultMergeFunctions.mergeArrays(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSets(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeSets(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeSets !== utils.defaultMergeFunctions.mergeSets)) {
|
||||
return utils.defaultMergeFunctions.mergeSets(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMaps(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeMaps(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeMaps !== utils.defaultMergeFunctions.mergeMaps)) {
|
||||
return utils.defaultMergeFunctions.mergeMaps(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge other things.
|
||||
*
|
||||
* @param values - The other things.
|
||||
*/
|
||||
function mergeOthers(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeOthers(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeOthers !== utils.defaultMergeFunctions.mergeOthers)) {
|
||||
return utils.defaultMergeFunctions.mergeOthers(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default strategy to merge records into a target record.
|
||||
*
|
||||
* @param mut_target - The result will be mutated into this record
|
||||
* @param values - The records (including the target's value if there is one).
|
||||
*/
|
||||
function mergeRecordsInto$1(mut_target, values, utils, meta) {
|
||||
for (const key of getKeys(values)) {
|
||||
const propValues = [];
|
||||
for (const value of values) {
|
||||
if (objectHasProperty(value, key)) {
|
||||
propValues.push(value[key]);
|
||||
}
|
||||
}
|
||||
if (propValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updatedMeta = utils.metaDataUpdater(meta, {
|
||||
key,
|
||||
parents: values,
|
||||
});
|
||||
const propertyTarget = { value: propValues[0] };
|
||||
mergeUnknownsInto(propertyTarget, propValues, utils, updatedMeta);
|
||||
if (key === "__proto__") {
|
||||
Object.defineProperty(mut_target.value, key, {
|
||||
value: propertyTarget.value,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
mut_target.value[key] = propertyTarget.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge arrays into a target array.
|
||||
*
|
||||
* @param mut_target - The result will be mutated into this array
|
||||
* @param values - The arrays (including the target's value if there is one).
|
||||
*/
|
||||
function mergeArraysInto$1(mut_target, values) {
|
||||
mut_target.value.push(...values.slice(1).flat());
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge sets into a target set.
|
||||
*
|
||||
* @param mut_target - The result will be mutated into this set
|
||||
* @param values - The sets (including the target's value if there is one).
|
||||
*/
|
||||
function mergeSetsInto$1(mut_target, values) {
|
||||
for (const value of getIterableOfIterables(values.slice(1))) {
|
||||
mut_target.value.add(value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge maps into a target map.
|
||||
*
|
||||
* @param mut_target - The result will be mutated into this map
|
||||
* @param values - The maps (including the target's value if there is one).
|
||||
*/
|
||||
function mergeMapsInto$1(mut_target, values) {
|
||||
for (const [key, value] of getIterableOfIterables(values.slice(1))) {
|
||||
mut_target.value.set(key, value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the target to the last value.
|
||||
*/
|
||||
function mergeOthersInto$1(mut_target, values) {
|
||||
mut_target.value = values.at(-1);
|
||||
}
|
||||
/**
|
||||
* The merge functions.
|
||||
*/
|
||||
const mergeIntoFunctions = {
|
||||
mergeRecords: mergeRecordsInto$1,
|
||||
mergeArrays: mergeArraysInto$1,
|
||||
mergeSets: mergeSetsInto$1,
|
||||
mergeMaps: mergeMapsInto$1,
|
||||
mergeOthers: mergeOthersInto$1,
|
||||
};
|
||||
|
||||
function deepmergeInto(target, ...objects) {
|
||||
return void deepmergeIntoCustom({})(target, ...objects);
|
||||
}
|
||||
function deepmergeIntoCustom(options, rootMetaData) {
|
||||
const utils = getIntoUtils(options, customizedDeepmergeInto);
|
||||
/**
|
||||
* The customized deepmerge function.
|
||||
*/
|
||||
function customizedDeepmergeInto(target, ...objects) {
|
||||
mergeUnknownsInto({ value: target }, [target, ...objects], utils, rootMetaData);
|
||||
}
|
||||
return customizedDeepmergeInto;
|
||||
}
|
||||
/**
|
||||
* The the utils that are available to the merge functions.
|
||||
*
|
||||
* @param options - The options the user specified
|
||||
*/
|
||||
function getIntoUtils(options, customizedDeepmergeInto) {
|
||||
return {
|
||||
defaultMergeFunctions: mergeIntoFunctions,
|
||||
mergeFunctions: {
|
||||
...mergeIntoFunctions,
|
||||
...Object.fromEntries(Object.entries(options)
|
||||
.filter(([key, option]) => Object.hasOwn(mergeIntoFunctions, key))
|
||||
.map(([key, option]) => (option === false ? [key, mergeIntoFunctions.mergeOthers] : [key, option]))),
|
||||
},
|
||||
metaDataUpdater: (options.metaDataUpdater ?? defaultMetaDataUpdater),
|
||||
deepmergeInto: customizedDeepmergeInto,
|
||||
filterValues: options.filterValues === false ? undefined : (options.filterValues ?? defaultFilterValues),
|
||||
actions: actionsInto,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge unknown things into a target.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The values.
|
||||
*/
|
||||
function mergeUnknownsInto(mut_target, values, utils, meta) {
|
||||
const filteredValues = utils.filterValues?.(values, meta) ?? values;
|
||||
if (filteredValues.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (filteredValues.length === 1) {
|
||||
return void mergeOthersInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
const type = getObjectType(mut_target.value);
|
||||
if (type !== 0 /* ObjectType.NOT */ && type !== 5 /* ObjectType.OTHER */) {
|
||||
for (let mut_index = 1; mut_index < filteredValues.length; mut_index++) {
|
||||
if (getObjectType(filteredValues[mut_index]) === type) {
|
||||
continue;
|
||||
}
|
||||
return void mergeOthersInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case 1 /* ObjectType.RECORD */: {
|
||||
return void mergeRecordsInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
case 2 /* ObjectType.ARRAY */: {
|
||||
return void mergeArraysInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
case 3 /* ObjectType.SET */: {
|
||||
return void mergeSetsInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
case 4 /* ObjectType.MAP */: {
|
||||
return void mergeMapsInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
default: {
|
||||
return void mergeOthersInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge records into a target record.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecordsInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeRecords(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeRecords(mut_target, values, utils, meta);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge arrays into a target array.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArraysInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeArrays(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeArrays(mut_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge sets into a target set.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSetsInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeSets(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeSets(mut_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge maps into a target map.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMapsInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeMaps(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeMaps(mut_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge other things into a target.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The other things.
|
||||
*/
|
||||
function mergeOthersInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeOthers(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge || mut_target.value === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeOthers(mut_target, values);
|
||||
}
|
||||
}
|
||||
|
||||
exports.deepmerge = deepmerge;
|
||||
exports.deepmergeCustom = deepmergeCustom;
|
||||
exports.deepmergeInto = deepmergeInto;
|
||||
exports.deepmergeIntoCustom = deepmergeIntoCustom;
|
||||
exports.getKeys = getKeys;
|
||||
exports.getObjectType = getObjectType;
|
||||
exports.objectHasProperty = objectHasProperty;
|
832
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/dist/index.d.cts
generated
vendored
Normal file
832
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/dist/index.d.cts
generated
vendored
Normal file
|
@ -0,0 +1,832 @@
|
|||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
/**
|
||||
* Simplify a complex type such as a union or intersection of objects into a
|
||||
* single object.
|
||||
*/
|
||||
export type SimplifyObject<T extends {}> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
/**
|
||||
* Flatten a collection of tuples of tuples into a collection of tuples.
|
||||
*/
|
||||
export type FlattenTuples<T> = {
|
||||
[I in keyof T]: FlattenTuple<T[I]>;
|
||||
};
|
||||
/**
|
||||
* Flatten a tuple of tuples into a single tuple.
|
||||
*/
|
||||
export type FlattenTuple<T> = T extends readonly [
|
||||
] ? [
|
||||
] : T extends readonly [
|
||||
infer T0
|
||||
] ? [
|
||||
...FlattenTuple<T0>
|
||||
] : T extends readonly [
|
||||
infer T0,
|
||||
...infer Ts
|
||||
] ? [
|
||||
...FlattenTuple<T0>,
|
||||
...FlattenTuple<Ts>
|
||||
] : [
|
||||
T
|
||||
];
|
||||
/**
|
||||
* Safely test whether or not the first given types extends the second.
|
||||
*
|
||||
* Needed in particular for testing if a type is "never".
|
||||
*/
|
||||
export type Is<T1, T2> = [
|
||||
T1
|
||||
] extends [
|
||||
T2
|
||||
] ? true : false;
|
||||
/**
|
||||
* Safely test whether or not the given type is "never".
|
||||
*/
|
||||
export type IsNever<T> = Is<T, never>;
|
||||
/**
|
||||
* And operator for types.
|
||||
*/
|
||||
export type And<T1 extends boolean, T2 extends boolean> = T1 extends false ? false : T2;
|
||||
/**
|
||||
* Not operator for types.
|
||||
*/
|
||||
export type Not<T extends boolean> = T extends true ? false : true;
|
||||
/**
|
||||
* Check if a key is optional in the given object.
|
||||
*/
|
||||
export type KeyIsOptional<K extends PropertyKey, O extends {
|
||||
[Key in K]?: unknown;
|
||||
}> = O extends {
|
||||
[Key in K]: unknown;
|
||||
} ? false : true;
|
||||
/**
|
||||
* Returns whether or not the given type a record.
|
||||
*
|
||||
* Note: Does not pass for interfaces.
|
||||
*/
|
||||
export type IsRecord<T> = And<Not<IsNever<T>>, T extends Readonly<Record<PropertyKey, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are records.
|
||||
*/
|
||||
export type EveryIsRecord<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? IsRecord<Head> extends true ? Rest extends ReadonlyArray<unknown> ? EveryIsRecord<Rest> : true : false : true;
|
||||
/**
|
||||
* Returns whether or not the given type is an array.
|
||||
*/
|
||||
export type IsArray<T> = And<Not<IsNever<T>>, T extends ReadonlyArray<unknown> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are arrays.
|
||||
*/
|
||||
export type EveryIsArray<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer T1
|
||||
] ? IsArray<T1> : Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? IsArray<Head> extends true ? Rest extends readonly [
|
||||
unknown,
|
||||
...ReadonlyArray<unknown>
|
||||
] ? EveryIsArray<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an set.
|
||||
*
|
||||
* Note: This may also return true for Maps.
|
||||
*/
|
||||
export type IsSet<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlySet<unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are sets.
|
||||
*
|
||||
* Note: This may also return true if all are maps.
|
||||
*/
|
||||
export type EveryIsSet<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [
|
||||
infer T1
|
||||
]> ? IsSet<T1> : Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? IsSet<Head> extends true ? Rest extends readonly [
|
||||
unknown,
|
||||
...ReadonlyArray<unknown>
|
||||
] ? EveryIsSet<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an map.
|
||||
*/
|
||||
export type IsMap<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlyMap<unknown, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are maps.
|
||||
*/
|
||||
export type EveryIsMap<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [
|
||||
infer T1
|
||||
]> ? IsMap<T1> : Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? IsMap<Head> extends true ? Rest extends readonly [
|
||||
unknown,
|
||||
...ReadonlyArray<unknown>
|
||||
] ? EveryIsMap<Rest> : false : false : false;
|
||||
/**
|
||||
* Union of the sets' values' types
|
||||
*/
|
||||
export type UnionSetValues<Ts extends ReadonlyArray<unknown>> = UnionSetValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionSetValues.
|
||||
*/
|
||||
export type UnionSetValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Head extends Readonly<ReadonlySet<infer V1>> ? Rest extends ReadonlyArray<unknown> ? UnionSetValuesHelper<Rest, Acc | V1> : Acc | V1 : never : Acc;
|
||||
/**
|
||||
* Union of the maps' values' types
|
||||
*/
|
||||
export type UnionMapKeys<Ts extends ReadonlyArray<unknown>> = UnionMapKeysHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapKeys.
|
||||
*/
|
||||
export type UnionMapKeysHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Head extends Readonly<ReadonlyMap<infer K1, unknown>> ? Rest extends readonly [
|
||||
] ? Acc | K1 : UnionMapKeysHelper<Rest, Acc | K1> : never : Acc;
|
||||
/**
|
||||
* Union of the maps' keys' types
|
||||
*/
|
||||
export type UnionMapValues<Ts extends ReadonlyArray<unknown>> = UnionMapValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapValues.
|
||||
*/
|
||||
export type UnionMapValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Head extends Readonly<ReadonlyMap<unknown, infer V1>> ? Rest extends readonly [
|
||||
] ? Acc | V1 : UnionMapValuesHelper<Rest, Acc | V1> : never : Acc;
|
||||
/**
|
||||
* Use the more precise type if the types are compatible.
|
||||
* Otherwise, union them.
|
||||
*/
|
||||
export type PreciseOrUnion<A, B> = A extends B ? A : B extends A ? B : A | B;
|
||||
/**
|
||||
* Filter out U from a tuple.
|
||||
*/
|
||||
export type FilterOut<T extends ReadonlyArray<unknown>, U> = FilterOutHelper<T, U, [
|
||||
]>;
|
||||
/**
|
||||
* Tail-recursive helper type for FilterOut.
|
||||
*/
|
||||
export type FilterOutHelper<T extends ReadonlyArray<unknown>, U, Acc extends ReadonlyArray<unknown>> = T extends readonly [
|
||||
] ? Acc : T extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Is<Head, U> extends true ? FilterOutHelper<Rest, U, Acc> : FilterOutHelper<Rest, U, [
|
||||
...Acc,
|
||||
Head
|
||||
]> : T;
|
||||
/**
|
||||
* Filter out nevers from a tuple.
|
||||
*/
|
||||
export type FilterOutNever<T> = T extends ReadonlyArray<unknown> ? FilterOut<T, never> : never;
|
||||
/**
|
||||
* Is the type a tuple?
|
||||
*/
|
||||
export type IsTuple<T extends ReadonlyArray<unknown>> = T extends readonly [
|
||||
] ? true : T extends readonly [
|
||||
unknown,
|
||||
...ReadonlyArray<unknown>
|
||||
] ? true : false;
|
||||
/**
|
||||
* Perfrom a transpose operation on a 2D tuple.
|
||||
*/
|
||||
export type TransposeTuple<T> = T extends readonly [
|
||||
...(readonly [
|
||||
...unknown[]
|
||||
])
|
||||
] ? T extends readonly [
|
||||
] ? [
|
||||
] : T extends readonly [
|
||||
infer X extends ReadonlyArray<unknown>
|
||||
] ? TransposeTupleSimpleCase<X> : T extends readonly [
|
||||
infer X extends ReadonlyArray<unknown>,
|
||||
...infer XS extends ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? PrependCol<X, TransposeTuple<XS>> : T : never;
|
||||
export type PrependCol<T extends ReadonlyArray<unknown>, S extends ReadonlyArray<ReadonlyArray<unknown>>> = T extends readonly [
|
||||
] ? S extends readonly [
|
||||
] ? [
|
||||
] : never : T extends readonly [
|
||||
infer X,
|
||||
...infer XS
|
||||
] ? S extends readonly [
|
||||
readonly [
|
||||
...infer Y
|
||||
],
|
||||
...infer YS extends ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? [
|
||||
[
|
||||
X,
|
||||
...Y
|
||||
],
|
||||
...PrependCol<XS, YS>
|
||||
] : never : never;
|
||||
export type TransposeTupleSimpleCase<T extends readonly [
|
||||
...unknown[]
|
||||
]> = T extends readonly [
|
||||
] ? [
|
||||
] : T extends readonly [
|
||||
infer X,
|
||||
...infer XS
|
||||
] ? [
|
||||
[
|
||||
X
|
||||
],
|
||||
...TransposeTupleSimpleCase<XS>
|
||||
] : never;
|
||||
/**
|
||||
* Convert a tuple to an intersection of each of its types.
|
||||
*/
|
||||
export type TupleToIntersection<T extends ReadonlyArray<unknown>> = {
|
||||
[K in keyof T]: (x: T[K]) => void;
|
||||
} extends Record<number, (x: infer I) => void> ? I : never;
|
||||
/**
|
||||
* Convert a union to a tuple.
|
||||
*
|
||||
* Warning: The order of the elements is non-deterministic.
|
||||
* Warning 2: The union maybe me modified by the TypeScript engine before convertion.
|
||||
* Warning 3: This implementation relies on a hack/limitation in TypeScript.
|
||||
*/
|
||||
export type UnionToTuple<T, L = LastOf<T>> = IsNever<T> extends true ? [
|
||||
] : [
|
||||
...UnionToTuple<Exclude<T, L>>,
|
||||
L
|
||||
];
|
||||
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
||||
export type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
||||
/**
|
||||
* Convert a tuple of tuples to a tuple of unions.
|
||||
*/
|
||||
export type TupleTupleToTupleUnion<T extends ReadonlyArray<ReadonlyArray<unknown>>> = {
|
||||
[I in keyof T]: TupleToUnion<T[I]>;
|
||||
};
|
||||
/**
|
||||
* Convert a tuple to a union.
|
||||
*/
|
||||
export type TupleToUnion<T extends ReadonlyArray<unknown>> = T extends readonly [
|
||||
] ? never : T extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Head | TupleToUnion<Rest> : never;
|
||||
/**
|
||||
* Assert that a type is of a given type.
|
||||
*/
|
||||
export type AssertType<Expected, T> = T extends Expected ? T : never;
|
||||
/**
|
||||
* Mapping of merge function URIs to the merge function type.
|
||||
*/
|
||||
export interface DeepMergeFunctionURItoKind<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, in out M> {
|
||||
readonly DeepMergeLeafURI: DeepMergeLeaf<Ts, Fs, M>;
|
||||
readonly DeepMergeRecordsDefaultURI: DeepMergeRecordsDefaultHKT<Ts, Fs, M>;
|
||||
readonly DeepMergeArraysDefaultURI: DeepMergeArraysDefaultHKT<Ts, Fs, M>;
|
||||
readonly DeepMergeSetsDefaultURI: DeepMergeSetsDefaultHKT<Ts>;
|
||||
readonly DeepMergeMapsDefaultURI: DeepMergeMapsDefaultHKT<Ts>;
|
||||
readonly DeepMergeFilterValuesDefaultURI: DeepMergeFilterValuesDefaultHKT<Ts>;
|
||||
readonly DeepMergeNoFilteringURI: Ts;
|
||||
}
|
||||
/**
|
||||
* Get the type of the given merge function via its URI.
|
||||
*/
|
||||
export type DeepMergeFunctionKind<URI extends DeepMergeFunctionURIs, Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionURItoKind<Ts, Fs, M>[URI];
|
||||
/**
|
||||
* A union of all valid merge function URIs.
|
||||
*/
|
||||
export type DeepMergeFunctionURIs = keyof DeepMergeFunctionURItoKind<ReadonlyArray<unknown>, DeepMergeFunctionsURIs, unknown>;
|
||||
/**
|
||||
* The merge functions to use when deep merging.
|
||||
*/
|
||||
export type DeepMergeFunctionsURIs = Readonly<{
|
||||
/**
|
||||
* The merge function to merge records with.
|
||||
*/
|
||||
DeepMergeRecordsURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge arrays with.
|
||||
*/
|
||||
DeepMergeArraysURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge sets with.
|
||||
*/
|
||||
DeepMergeSetsURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge maps with.
|
||||
*/
|
||||
DeepMergeMapsURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge other things with.
|
||||
*/
|
||||
DeepMergeOthersURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The function to filter values.
|
||||
*/
|
||||
DeepMergeFilterValuesURI: DeepMergeFunctionURIs;
|
||||
}>;
|
||||
/**
|
||||
* Deep merge types.
|
||||
*/
|
||||
export type DeepMergeHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = IsTuple<Ts> extends true ? Ts extends readonly [
|
||||
] ? undefined : DeepMergeHKTHelper<FilterValuesHKT<Ts, Fs, M>, Fs, M> : unknown;
|
||||
export type DeepMergeHKTHelper<Ts, Fs extends DeepMergeFunctionsURIs, M> = Ts extends ReadonlyArray<unknown> ? IsTuple<Ts> extends true ? Ts extends readonly [
|
||||
] ? unknown : Ts extends readonly [
|
||||
infer T1
|
||||
] ? T1 : EveryIsArray<Ts> extends true ? DeepMergeArraysHKT<Ts, Fs, M> : EveryIsMap<Ts> extends true ? DeepMergeMapsHKT<Ts, Fs, M> : EveryIsSet<Ts> extends true ? DeepMergeSetsHKT<Ts, Fs, M> : EveryIsRecord<Ts> extends true ? DeepMergeRecordsHKT<Ts, Fs, M> : DeepMergeOthersHKT<Ts, Fs, M> : unknown : never;
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
export type DeepMergeRecordsHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeRecordsURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Deep merge arrays.
|
||||
*/
|
||||
export type DeepMergeArraysHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeArraysURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Deep merge sets.
|
||||
*/
|
||||
export type DeepMergeSetsHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeSetsURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Deep merge maps.
|
||||
*/
|
||||
export type DeepMergeMapsHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeMapsURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Deep merge other things.
|
||||
*/
|
||||
export type DeepMergeOthersHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeOthersURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Filter values.
|
||||
*/
|
||||
export type FilterValuesHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeFilterValuesURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* The merge function that returns a leaf.
|
||||
*/
|
||||
export type DeepMergeLeafURI = "DeepMergeLeafURI";
|
||||
/**
|
||||
* Don't filter values.
|
||||
*/
|
||||
export type DeepMergeNoFilteringURI = "DeepMergeNoFilteringURI";
|
||||
/**
|
||||
* Get the leaf type from many types that can't be merged.
|
||||
*/
|
||||
export type DeepMergeLeaf<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = Ts extends readonly [
|
||||
] ? never : Ts extends readonly [
|
||||
infer T
|
||||
] ? T : Ts extends readonly [
|
||||
...infer Rest,
|
||||
infer Tail
|
||||
] ? IsNever<Tail> extends true ? Rest extends ReadonlyArray<unknown> ? DeepMergeLeaf<Rest, Fs, M> : never : DeepMergeLeafApplyFilter<Ts, AssertType<ReadonlyArray<unknown>, TupleTupleToTupleUnion<AssertType<ReadonlyArray<ReadonlyArray<unknown>>, {
|
||||
[I in keyof Ts]: FilterValuesHKT<UnionToTuple<Ts[I]>, Fs, M>;
|
||||
}>>>> : never;
|
||||
export type DeepMergeLeafApplyFilter<Original extends ReadonlyArray<unknown>, Filtered extends ReadonlyArray<unknown>> = Original extends readonly [
|
||||
...infer OriginalRest,
|
||||
infer OriginalTail
|
||||
] ? Filtered extends readonly [
|
||||
...infer FilteredRest,
|
||||
infer FilteredTail
|
||||
] ? OriginalTail extends FilteredTail ? FilteredTail : FilteredTail | DeepMergeLeafApplyFilter<OriginalRest, FilteredRest> : never : never;
|
||||
/**
|
||||
* The meta data deepmerge is able to provide.
|
||||
*/
|
||||
export type DeepMergeBuiltInMetaData = Readonly<{
|
||||
key: PropertyKey;
|
||||
parents: ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>;
|
||||
}>;
|
||||
/**
|
||||
* The default merge function to merge records with.
|
||||
*/
|
||||
export type DeepMergeRecordsDefaultURI = "DeepMergeRecordsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge arrays with.
|
||||
*/
|
||||
export type DeepMergeArraysDefaultURI = "DeepMergeArraysDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge sets with.
|
||||
*/
|
||||
export type DeepMergeSetsDefaultURI = "DeepMergeSetsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge maps with.
|
||||
*/
|
||||
export type DeepMergeMapsDefaultURI = "DeepMergeMapsDefaultURI";
|
||||
/**
|
||||
* The default filter values function.
|
||||
*/
|
||||
export type DeepMergeFilterValuesDefaultURI = "DeepMergeFilterValuesDefaultURI";
|
||||
/**
|
||||
* The default merge functions to use when deep merging.
|
||||
*/
|
||||
export type DeepMergeFunctionsDefaultURIs = Readonly<{
|
||||
DeepMergeRecordsURI: DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: DeepMergeLeafURI;
|
||||
DeepMergeFilterValuesURI: DeepMergeFilterValuesDefaultURI;
|
||||
}>;
|
||||
export type RecordEntries<T extends Record<PropertyKey, unknown>> = FilterOut<UnionToTuple<{
|
||||
[K in keyof T]: [
|
||||
K,
|
||||
T[K]
|
||||
];
|
||||
}[keyof T]>, undefined>;
|
||||
export type RecordMeta = Record<PropertyKey, RecordPropertyMeta>;
|
||||
export type RecordPropertyMeta<Key extends PropertyKey = PropertyKey, Value = unknown, Optional extends boolean = boolean> = {
|
||||
key: Key;
|
||||
value: Value;
|
||||
optional: Optional;
|
||||
};
|
||||
export type RecordsToRecordMeta<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>> = FilterOutNever<{
|
||||
[I in keyof Ts]: RecordToRecordMeta<Ts[I]>;
|
||||
}>;
|
||||
export type RecordToRecordMeta<T extends Record<PropertyKey, unknown>> = {
|
||||
[K in keyof T]-?: {
|
||||
key: K;
|
||||
value: Required<T>[K];
|
||||
optional: KeyIsOptional<K, T>;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
export type DeepMergeRecordsDefaultHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = Ts extends ReadonlyArray<Record<PropertyKey, unknown>> ? SimplifyObject<DeepMergeRecordMetaDefaultHKTProps<RecordsToRecordMeta<Ts>, Fs, M>> : never;
|
||||
/**
|
||||
* Deep merge record props.
|
||||
*/
|
||||
export type DeepMergeRecordMetaDefaultHKTProps<RecordMetas, Fs extends DeepMergeFunctionsURIs, M> = RecordMetas extends ReadonlyArray<RecordMeta> ? CreateRecordFromMeta<MergeRecordMeta<RecordMetas>, Fs, M> : never;
|
||||
export type MergeRecordMeta<RecordMetas extends ReadonlyArray<RecordMeta>> = GroupValuesByKey<FlattenTuples<TransposeTuple<FilterOut<{
|
||||
[I in keyof RecordMetas]: TransposeTuple<RecordEntries<RecordMetas[I]>>;
|
||||
}, readonly [
|
||||
]>>>>;
|
||||
export type GroupValuesByKey<Ts> = Ts extends readonly [
|
||||
infer Keys extends ReadonlyArray<PropertyKey>,
|
||||
infer Values
|
||||
] ? {
|
||||
[I in keyof Keys]: DeepMergeRecordPropertyMetaDefaultHKTGetPossible<Keys[I], FilterOutNever<{
|
||||
[J in keyof Values]: Values[J] extends {
|
||||
key: Keys[I];
|
||||
} ? Values[J] : never;
|
||||
}>>;
|
||||
} : never;
|
||||
export type CreateRecordFromMeta<Ts, Fs extends DeepMergeFunctionsURIs, M> = Ts extends ReadonlyArray<unknown> ? TupleToIntersection<{
|
||||
[I in keyof Ts]: Ts[I] extends {
|
||||
key: infer Key extends PropertyKey;
|
||||
values: infer Values extends ReadonlyArray<unknown>;
|
||||
optional: infer O extends boolean;
|
||||
} ? CreateRecordForKeyFromMeta<Key, Values, O, Fs, M> : never;
|
||||
}> : never;
|
||||
export type CreateRecordForKeyFromMeta<Key extends PropertyKey, Values extends ReadonlyArray<unknown>, Optional extends boolean, Fs extends DeepMergeFunctionsURIs, M> = Optional extends true ? {
|
||||
[k in Key]+?: DeepMergeHKT<Values, Fs, M>;
|
||||
} : {
|
||||
[k in Key]-?: DeepMergeHKT<Values, Fs, M>;
|
||||
};
|
||||
/**
|
||||
* Get the possible types of a property.
|
||||
*/
|
||||
export type DeepMergeRecordPropertyMetaDefaultHKTGetPossible<Key extends PropertyKey, Ts> = Ts extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
] ? DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Ts, {
|
||||
key: Key;
|
||||
values: [
|
||||
];
|
||||
optional: never;
|
||||
}> : never;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeRecordPropertyMetaDefaultHKTGetPossible.
|
||||
*/
|
||||
export type DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Ts extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
], Acc extends {
|
||||
key: PropertyKey;
|
||||
values: ReadonlyArray<unknown>;
|
||||
optional: boolean;
|
||||
}> = Ts extends [
|
||||
...infer Rest,
|
||||
{
|
||||
key: infer K extends PropertyKey;
|
||||
value: infer V;
|
||||
optional: infer O extends boolean;
|
||||
}
|
||||
] ? Acc["optional"] extends true ? Acc extends {
|
||||
values: [
|
||||
infer Head,
|
||||
...infer AccRest
|
||||
];
|
||||
} ? Rest extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
] ? DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Rest, {
|
||||
key: K;
|
||||
values: [
|
||||
PreciseOrUnion<V, Head>,
|
||||
...AccRest
|
||||
];
|
||||
optional: O;
|
||||
}> : {
|
||||
key: K;
|
||||
values: [
|
||||
PreciseOrUnion<V, Head>,
|
||||
...AccRest
|
||||
];
|
||||
optional: O;
|
||||
} : Rest extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
] ? DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Rest, {
|
||||
key: K;
|
||||
values: [
|
||||
V,
|
||||
...Acc["values"]
|
||||
];
|
||||
optional: O;
|
||||
}> : {
|
||||
key: K;
|
||||
values: [
|
||||
V,
|
||||
...Acc["values"]
|
||||
];
|
||||
optional: O;
|
||||
} : Rest extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
] ? DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Rest, {
|
||||
key: K;
|
||||
values: [
|
||||
V,
|
||||
...Acc["values"]
|
||||
];
|
||||
optional: O;
|
||||
}> : {
|
||||
key: K;
|
||||
values: [
|
||||
V,
|
||||
...Acc["values"]
|
||||
];
|
||||
optional: O;
|
||||
} : never;
|
||||
/**
|
||||
* Deep merge arrays.
|
||||
*/
|
||||
export type DeepMergeArraysDefaultHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeArraysDefaultHKTHelper<Ts, Fs, M, [
|
||||
]>;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeArraysDefaultHKT.
|
||||
*/
|
||||
export type DeepMergeArraysDefaultHKTHelper<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M, Acc extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer Head extends ReadonlyArray<unknown>,
|
||||
...infer Rest
|
||||
] ? Rest extends readonly [
|
||||
ReadonlyArray<unknown>,
|
||||
...ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? DeepMergeArraysDefaultHKTHelper<Rest, Fs, M, [
|
||||
...Acc,
|
||||
...Head
|
||||
]> : [
|
||||
...Acc,
|
||||
...Head
|
||||
] : never;
|
||||
/**
|
||||
* Deep merge sets.
|
||||
*/
|
||||
export type DeepMergeSetsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Set<UnionSetValues<Ts>>;
|
||||
/**
|
||||
* Deep merge maps.
|
||||
*/
|
||||
export type DeepMergeMapsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Map<UnionMapKeys<Ts>, UnionMapValues<Ts>>;
|
||||
/**
|
||||
* Filter out undefined values.
|
||||
*/
|
||||
export type DeepMergeFilterValuesDefaultHKT<Ts extends ReadonlyArray<unknown>> = FilterOut<Ts, undefined>;
|
||||
/**
|
||||
* Get the merge functions with defaults apply from the given subset.
|
||||
*/
|
||||
export type GetDeepMergeFunctionsURIs<PMF extends Partial<DeepMergeFunctionsURIs>> = Readonly<{
|
||||
DeepMergeRecordsURI: PMF["DeepMergeRecordsURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeRecordsURI"] : DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: PMF["DeepMergeArraysURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeArraysURI"] : DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: PMF["DeepMergeSetsURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeSetsURI"] : DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: PMF["DeepMergeMapsURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeMapsURI"] : DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: PMF["DeepMergeOthersURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeOthersURI"] : DeepMergeLeafURI;
|
||||
DeepMergeFilterValuesURI: PMF["DeepMergeFilterValuesURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeFilterValuesURI"] : DeepMergeFilterValuesDefaultURI;
|
||||
}>;
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
type MergeFunctions = {
|
||||
mergeRecords: typeof mergeRecordsInto;
|
||||
mergeArrays: typeof mergeArraysInto;
|
||||
mergeSets: typeof mergeSetsInto;
|
||||
mergeMaps: typeof mergeMapsInto;
|
||||
mergeOthers: typeof mergeOthersInto;
|
||||
};
|
||||
declare function mergeRecordsInto<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeIntoFunctionUtils<M, MM>, M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(mut_target: Reference<Record<PropertyKey, unknown>>, values: Ts, utils: U, meta: M | undefined): void;
|
||||
declare function mergeArraysInto<Ts extends ReadonlyArray<ReadonlyArray<unknown>>>(mut_target: Reference<unknown[]>, values: Ts): void;
|
||||
declare function mergeSetsInto<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(mut_target: Reference<Set<unknown>>, values: Ts): void;
|
||||
declare function mergeMapsInto<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(mut_target: Reference<Map<unknown, unknown>>, values: Ts): void;
|
||||
declare function mergeOthersInto<Ts extends ReadonlyArray<unknown>>(mut_target: Reference<unknown>, values: Ts): void;
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
type MergeFunctions$1 = {
|
||||
mergeRecords: typeof mergeRecords;
|
||||
mergeArrays: typeof mergeArrays;
|
||||
mergeSets: typeof mergeSets;
|
||||
mergeMaps: typeof mergeMaps;
|
||||
mergeOthers: typeof mergeOthers;
|
||||
};
|
||||
declare function mergeRecords<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeUtils<M, MM>, Fs extends DeepMergeFunctionsURIs, M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(values: Ts, utils: U, meta: M | undefined): DeepMergeRecordsDefaultHKT<Ts, Fs, M>;
|
||||
declare function mergeArrays<Ts extends ReadonlyArray<ReadonlyArray<unknown>>, Fs extends DeepMergeFunctionsURIs, M>(values: Ts): DeepMergeArraysDefaultHKT<Ts, Fs, M>;
|
||||
declare function mergeSets<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(values: Ts): DeepMergeSetsDefaultHKT<Ts>;
|
||||
declare function mergeMaps<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(values: Ts): DeepMergeMapsDefaultHKT<Ts>;
|
||||
declare function mergeOthers<Ts extends ReadonlyArray<unknown>>(values: Ts): unknown;
|
||||
/**
|
||||
* The options the user can pass to customize deepmerge.
|
||||
*/
|
||||
export type DeepMergeOptions<in out M, MM extends Readonly<Record<PropertyKey, unknown>> = {}> = Partial<DeepMergeOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
/**
|
||||
* The options the user can pass to customize deepmergeInto.
|
||||
*/
|
||||
export type DeepMergeIntoOptions<in out M, MM extends Readonly<Record<PropertyKey, unknown>> = {}> = Partial<DeepMergeIntoOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
export type MetaDataUpdater<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = (previousMeta: M | undefined, metaMeta: Readonly<Partial<MM>>) => M;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmerge.
|
||||
*/
|
||||
export type DeepMergeOptionsFull<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
enableImplicitDefaultMerging: boolean;
|
||||
filterValues: DeepMergeUtilityFunctions<M>["filterValues"] | false;
|
||||
}>;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmergeInto.
|
||||
*/
|
||||
export type DeepMergeIntoOptionsFull<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeIntoFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeIntoFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeIntoFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeIntoFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeIntoFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
filterValues: DeepMergeUtilityFunctions<M>["filterValues"] | false;
|
||||
}>;
|
||||
/**
|
||||
* An object that has a reference to a value.
|
||||
*/
|
||||
type Reference<T> = {
|
||||
value: T;
|
||||
};
|
||||
/**
|
||||
* All the utility functions that can be overridden.
|
||||
*/
|
||||
export type DeepMergeUtilityFunctions<in M> = Readonly<{
|
||||
filterValues: <Ts extends ReadonlyArray<unknown>>(values: Ts, meta: M | undefined) => unknown[];
|
||||
}>;
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
export type DeepMergeFunctions<in M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
}>;
|
||||
export type DeepMergeIntoFunctionsReturnType = void | symbol;
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
export type DeepMergeIntoFunctions<in M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<Record<PropertyKey, unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<unknown[]>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<Map<unknown, unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<Set<unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<unknown>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
export type DeepMergeUtils<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeFunctions<M, MM>;
|
||||
defaultMergeFunctions: MergeFunctions$1;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmerge: <Ts extends ReadonlyArray<unknown>>(...values: Ts) => unknown;
|
||||
useImplicitDefaultMerging: boolean;
|
||||
filterValues: DeepMergeUtilityFunctions<M>["filterValues"] | undefined;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
skip: symbol;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
export type DeepMergeIntoFunctionUtils<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeIntoFunctions<M, MM>;
|
||||
defaultMergeFunctions: MergeFunctions;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmergeInto: <Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...values: Ts) => void;
|
||||
filterValues: DeepMergeUtilityFunctions<M>["filterValues"] | undefined;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
export declare function deepmerge<Ts extends Readonly<ReadonlyArray<unknown>>>(...objects: readonly [
|
||||
...Ts
|
||||
]): DeepMergeHKT<Ts, DeepMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
export declare function deepmergeCustom<BaseTs = unknown, PMF extends Partial<DeepMergeFunctionsURIs> = {}>(options: DeepMergeOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Ts extends ReadonlyArray<BaseTs>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeFunctionsURIs<PMF>, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
export declare function deepmergeCustom<BaseTs = unknown, PMF extends Partial<DeepMergeFunctionsURIs> = {}, MetaData = DeepMergeBuiltInMetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Ts extends ReadonlyArray<BaseTs>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeFunctionsURIs<PMF>, MetaData>;
|
||||
/**
|
||||
* Deeply merge objects into a target.
|
||||
*
|
||||
* @param target - This object will be mutated with the merge result.
|
||||
* @param objects - The objects to merge into the target.
|
||||
*/
|
||||
export declare function deepmergeInto<T extends object>(target: T, ...objects: ReadonlyArray<T>): void;
|
||||
/**
|
||||
* Deeply merge objects into a target.
|
||||
*
|
||||
* @param target - This object will be mutated with the merge result.
|
||||
* @param objects - The objects to merge into the target.
|
||||
*/
|
||||
export declare function deepmergeInto<Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...objects: Ts): asserts target is SimplifyObject<Target & DeepMergeHKT<[
|
||||
Target,
|
||||
...Ts
|
||||
], DeepMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
export declare function deepmergeIntoCustom<BaseTs = unknown>(options: DeepMergeIntoOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Target extends object, Ts extends ReadonlyArray<BaseTs>>(target: Target, ...objects: Ts) => void;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
export declare function deepmergeIntoCustom<BaseTs = unknown, MetaData = DeepMergeBuiltInMetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeIntoOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Target extends object, Ts extends ReadonlyArray<BaseTs>>(target: Target, ...objects: Ts) => void;
|
||||
/**
|
||||
* The different types of objects deepmerge-ts support.
|
||||
*/
|
||||
export declare const enum ObjectType {
|
||||
NOT = 0,
|
||||
RECORD = 1,
|
||||
ARRAY = 2,
|
||||
SET = 3,
|
||||
MAP = 4,
|
||||
OTHER = 5
|
||||
}
|
||||
/**
|
||||
* Get the type of the given object.
|
||||
*
|
||||
* @param object - The object to get the type of.
|
||||
* @returns The type of the given object.
|
||||
*/
|
||||
export declare function getObjectType(object: unknown): ObjectType;
|
||||
/**
|
||||
* Get the keys of the given objects including symbol keys.
|
||||
*
|
||||
* Note: Only keys to enumerable properties are returned.
|
||||
*
|
||||
* @param objects - An array of objects to get the keys of.
|
||||
* @returns A set containing all the keys of all the given objects.
|
||||
*/
|
||||
export declare function getKeys(objects: ReadonlyArray<object>): Set<PropertyKey>;
|
||||
/**
|
||||
* Does the given object have the given property.
|
||||
*
|
||||
* @param object - The object to test.
|
||||
* @param property - The property to test.
|
||||
* @returns Whether the object has the property.
|
||||
*/
|
||||
export declare function objectHasProperty(object: object, property: PropertyKey): boolean;
|
||||
|
||||
export {
|
||||
MergeFunctions as DeepMergeIntoFunctionsDefaults,
|
||||
MergeFunctions$1 as DeepMergeFunctionsDefaults,
|
||||
Reference as DeepMergeValueReference,
|
||||
};
|
||||
|
||||
export {};
|
832
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/dist/index.d.mts
generated
vendored
Normal file
832
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/dist/index.d.mts
generated
vendored
Normal file
|
@ -0,0 +1,832 @@
|
|||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
/**
|
||||
* Simplify a complex type such as a union or intersection of objects into a
|
||||
* single object.
|
||||
*/
|
||||
export type SimplifyObject<T extends {}> = {
|
||||
[K in keyof T]: T[K];
|
||||
} & {};
|
||||
/**
|
||||
* Flatten a collection of tuples of tuples into a collection of tuples.
|
||||
*/
|
||||
export type FlattenTuples<T> = {
|
||||
[I in keyof T]: FlattenTuple<T[I]>;
|
||||
};
|
||||
/**
|
||||
* Flatten a tuple of tuples into a single tuple.
|
||||
*/
|
||||
export type FlattenTuple<T> = T extends readonly [
|
||||
] ? [
|
||||
] : T extends readonly [
|
||||
infer T0
|
||||
] ? [
|
||||
...FlattenTuple<T0>
|
||||
] : T extends readonly [
|
||||
infer T0,
|
||||
...infer Ts
|
||||
] ? [
|
||||
...FlattenTuple<T0>,
|
||||
...FlattenTuple<Ts>
|
||||
] : [
|
||||
T
|
||||
];
|
||||
/**
|
||||
* Safely test whether or not the first given types extends the second.
|
||||
*
|
||||
* Needed in particular for testing if a type is "never".
|
||||
*/
|
||||
export type Is<T1, T2> = [
|
||||
T1
|
||||
] extends [
|
||||
T2
|
||||
] ? true : false;
|
||||
/**
|
||||
* Safely test whether or not the given type is "never".
|
||||
*/
|
||||
export type IsNever<T> = Is<T, never>;
|
||||
/**
|
||||
* And operator for types.
|
||||
*/
|
||||
export type And<T1 extends boolean, T2 extends boolean> = T1 extends false ? false : T2;
|
||||
/**
|
||||
* Not operator for types.
|
||||
*/
|
||||
export type Not<T extends boolean> = T extends true ? false : true;
|
||||
/**
|
||||
* Check if a key is optional in the given object.
|
||||
*/
|
||||
export type KeyIsOptional<K extends PropertyKey, O extends {
|
||||
[Key in K]?: unknown;
|
||||
}> = O extends {
|
||||
[Key in K]: unknown;
|
||||
} ? false : true;
|
||||
/**
|
||||
* Returns whether or not the given type a record.
|
||||
*
|
||||
* Note: Does not pass for interfaces.
|
||||
*/
|
||||
export type IsRecord<T> = And<Not<IsNever<T>>, T extends Readonly<Record<PropertyKey, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are records.
|
||||
*/
|
||||
export type EveryIsRecord<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? IsRecord<Head> extends true ? Rest extends ReadonlyArray<unknown> ? EveryIsRecord<Rest> : true : false : true;
|
||||
/**
|
||||
* Returns whether or not the given type is an array.
|
||||
*/
|
||||
export type IsArray<T> = And<Not<IsNever<T>>, T extends ReadonlyArray<unknown> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are arrays.
|
||||
*/
|
||||
export type EveryIsArray<Ts extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer T1
|
||||
] ? IsArray<T1> : Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? IsArray<Head> extends true ? Rest extends readonly [
|
||||
unknown,
|
||||
...ReadonlyArray<unknown>
|
||||
] ? EveryIsArray<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an set.
|
||||
*
|
||||
* Note: This may also return true for Maps.
|
||||
*/
|
||||
export type IsSet<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlySet<unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are sets.
|
||||
*
|
||||
* Note: This may also return true if all are maps.
|
||||
*/
|
||||
export type EveryIsSet<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [
|
||||
infer T1
|
||||
]> ? IsSet<T1> : Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? IsSet<Head> extends true ? Rest extends readonly [
|
||||
unknown,
|
||||
...ReadonlyArray<unknown>
|
||||
] ? EveryIsSet<Rest> : false : false : false;
|
||||
/**
|
||||
* Returns whether or not the given type is an map.
|
||||
*/
|
||||
export type IsMap<T> = And<Not<IsNever<T>>, T extends Readonly<ReadonlyMap<unknown, unknown>> ? true : false>;
|
||||
/**
|
||||
* Returns whether or not all the given types are maps.
|
||||
*/
|
||||
export type EveryIsMap<Ts extends ReadonlyArray<unknown>> = Ts extends Readonly<readonly [
|
||||
infer T1
|
||||
]> ? IsMap<T1> : Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? IsMap<Head> extends true ? Rest extends readonly [
|
||||
unknown,
|
||||
...ReadonlyArray<unknown>
|
||||
] ? EveryIsMap<Rest> : false : false : false;
|
||||
/**
|
||||
* Union of the sets' values' types
|
||||
*/
|
||||
export type UnionSetValues<Ts extends ReadonlyArray<unknown>> = UnionSetValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionSetValues.
|
||||
*/
|
||||
export type UnionSetValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Head extends Readonly<ReadonlySet<infer V1>> ? Rest extends ReadonlyArray<unknown> ? UnionSetValuesHelper<Rest, Acc | V1> : Acc | V1 : never : Acc;
|
||||
/**
|
||||
* Union of the maps' values' types
|
||||
*/
|
||||
export type UnionMapKeys<Ts extends ReadonlyArray<unknown>> = UnionMapKeysHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapKeys.
|
||||
*/
|
||||
export type UnionMapKeysHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Head extends Readonly<ReadonlyMap<infer K1, unknown>> ? Rest extends readonly [
|
||||
] ? Acc | K1 : UnionMapKeysHelper<Rest, Acc | K1> : never : Acc;
|
||||
/**
|
||||
* Union of the maps' keys' types
|
||||
*/
|
||||
export type UnionMapValues<Ts extends ReadonlyArray<unknown>> = UnionMapValuesHelper<Ts, never>;
|
||||
/**
|
||||
* Tail-recursive helper type for UnionMapValues.
|
||||
*/
|
||||
export type UnionMapValuesHelper<Ts extends ReadonlyArray<unknown>, Acc> = Ts extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Head extends Readonly<ReadonlyMap<unknown, infer V1>> ? Rest extends readonly [
|
||||
] ? Acc | V1 : UnionMapValuesHelper<Rest, Acc | V1> : never : Acc;
|
||||
/**
|
||||
* Use the more precise type if the types are compatible.
|
||||
* Otherwise, union them.
|
||||
*/
|
||||
export type PreciseOrUnion<A, B> = A extends B ? A : B extends A ? B : A | B;
|
||||
/**
|
||||
* Filter out U from a tuple.
|
||||
*/
|
||||
export type FilterOut<T extends ReadonlyArray<unknown>, U> = FilterOutHelper<T, U, [
|
||||
]>;
|
||||
/**
|
||||
* Tail-recursive helper type for FilterOut.
|
||||
*/
|
||||
export type FilterOutHelper<T extends ReadonlyArray<unknown>, U, Acc extends ReadonlyArray<unknown>> = T extends readonly [
|
||||
] ? Acc : T extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Is<Head, U> extends true ? FilterOutHelper<Rest, U, Acc> : FilterOutHelper<Rest, U, [
|
||||
...Acc,
|
||||
Head
|
||||
]> : T;
|
||||
/**
|
||||
* Filter out nevers from a tuple.
|
||||
*/
|
||||
export type FilterOutNever<T> = T extends ReadonlyArray<unknown> ? FilterOut<T, never> : never;
|
||||
/**
|
||||
* Is the type a tuple?
|
||||
*/
|
||||
export type IsTuple<T extends ReadonlyArray<unknown>> = T extends readonly [
|
||||
] ? true : T extends readonly [
|
||||
unknown,
|
||||
...ReadonlyArray<unknown>
|
||||
] ? true : false;
|
||||
/**
|
||||
* Perfrom a transpose operation on a 2D tuple.
|
||||
*/
|
||||
export type TransposeTuple<T> = T extends readonly [
|
||||
...(readonly [
|
||||
...unknown[]
|
||||
])
|
||||
] ? T extends readonly [
|
||||
] ? [
|
||||
] : T extends readonly [
|
||||
infer X extends ReadonlyArray<unknown>
|
||||
] ? TransposeTupleSimpleCase<X> : T extends readonly [
|
||||
infer X extends ReadonlyArray<unknown>,
|
||||
...infer XS extends ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? PrependCol<X, TransposeTuple<XS>> : T : never;
|
||||
export type PrependCol<T extends ReadonlyArray<unknown>, S extends ReadonlyArray<ReadonlyArray<unknown>>> = T extends readonly [
|
||||
] ? S extends readonly [
|
||||
] ? [
|
||||
] : never : T extends readonly [
|
||||
infer X,
|
||||
...infer XS
|
||||
] ? S extends readonly [
|
||||
readonly [
|
||||
...infer Y
|
||||
],
|
||||
...infer YS extends ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? [
|
||||
[
|
||||
X,
|
||||
...Y
|
||||
],
|
||||
...PrependCol<XS, YS>
|
||||
] : never : never;
|
||||
export type TransposeTupleSimpleCase<T extends readonly [
|
||||
...unknown[]
|
||||
]> = T extends readonly [
|
||||
] ? [
|
||||
] : T extends readonly [
|
||||
infer X,
|
||||
...infer XS
|
||||
] ? [
|
||||
[
|
||||
X
|
||||
],
|
||||
...TransposeTupleSimpleCase<XS>
|
||||
] : never;
|
||||
/**
|
||||
* Convert a tuple to an intersection of each of its types.
|
||||
*/
|
||||
export type TupleToIntersection<T extends ReadonlyArray<unknown>> = {
|
||||
[K in keyof T]: (x: T[K]) => void;
|
||||
} extends Record<number, (x: infer I) => void> ? I : never;
|
||||
/**
|
||||
* Convert a union to a tuple.
|
||||
*
|
||||
* Warning: The order of the elements is non-deterministic.
|
||||
* Warning 2: The union maybe me modified by the TypeScript engine before convertion.
|
||||
* Warning 3: This implementation relies on a hack/limitation in TypeScript.
|
||||
*/
|
||||
export type UnionToTuple<T, L = LastOf<T>> = IsNever<T> extends true ? [
|
||||
] : [
|
||||
...UnionToTuple<Exclude<T, L>>,
|
||||
L
|
||||
];
|
||||
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
||||
export type LastOf<T> = UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
||||
/**
|
||||
* Convert a tuple of tuples to a tuple of unions.
|
||||
*/
|
||||
export type TupleTupleToTupleUnion<T extends ReadonlyArray<ReadonlyArray<unknown>>> = {
|
||||
[I in keyof T]: TupleToUnion<T[I]>;
|
||||
};
|
||||
/**
|
||||
* Convert a tuple to a union.
|
||||
*/
|
||||
export type TupleToUnion<T extends ReadonlyArray<unknown>> = T extends readonly [
|
||||
] ? never : T extends readonly [
|
||||
infer Head,
|
||||
...infer Rest
|
||||
] ? Head | TupleToUnion<Rest> : never;
|
||||
/**
|
||||
* Assert that a type is of a given type.
|
||||
*/
|
||||
export type AssertType<Expected, T> = T extends Expected ? T : never;
|
||||
/**
|
||||
* Mapping of merge function URIs to the merge function type.
|
||||
*/
|
||||
export interface DeepMergeFunctionURItoKind<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, in out M> {
|
||||
readonly DeepMergeLeafURI: DeepMergeLeaf<Ts, Fs, M>;
|
||||
readonly DeepMergeRecordsDefaultURI: DeepMergeRecordsDefaultHKT<Ts, Fs, M>;
|
||||
readonly DeepMergeArraysDefaultURI: DeepMergeArraysDefaultHKT<Ts, Fs, M>;
|
||||
readonly DeepMergeSetsDefaultURI: DeepMergeSetsDefaultHKT<Ts>;
|
||||
readonly DeepMergeMapsDefaultURI: DeepMergeMapsDefaultHKT<Ts>;
|
||||
readonly DeepMergeFilterValuesDefaultURI: DeepMergeFilterValuesDefaultHKT<Ts>;
|
||||
readonly DeepMergeNoFilteringURI: Ts;
|
||||
}
|
||||
/**
|
||||
* Get the type of the given merge function via its URI.
|
||||
*/
|
||||
export type DeepMergeFunctionKind<URI extends DeepMergeFunctionURIs, Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionURItoKind<Ts, Fs, M>[URI];
|
||||
/**
|
||||
* A union of all valid merge function URIs.
|
||||
*/
|
||||
export type DeepMergeFunctionURIs = keyof DeepMergeFunctionURItoKind<ReadonlyArray<unknown>, DeepMergeFunctionsURIs, unknown>;
|
||||
/**
|
||||
* The merge functions to use when deep merging.
|
||||
*/
|
||||
export type DeepMergeFunctionsURIs = Readonly<{
|
||||
/**
|
||||
* The merge function to merge records with.
|
||||
*/
|
||||
DeepMergeRecordsURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge arrays with.
|
||||
*/
|
||||
DeepMergeArraysURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge sets with.
|
||||
*/
|
||||
DeepMergeSetsURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge maps with.
|
||||
*/
|
||||
DeepMergeMapsURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The merge function to merge other things with.
|
||||
*/
|
||||
DeepMergeOthersURI: DeepMergeFunctionURIs;
|
||||
/**
|
||||
* The function to filter values.
|
||||
*/
|
||||
DeepMergeFilterValuesURI: DeepMergeFunctionURIs;
|
||||
}>;
|
||||
/**
|
||||
* Deep merge types.
|
||||
*/
|
||||
export type DeepMergeHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = IsTuple<Ts> extends true ? Ts extends readonly [
|
||||
] ? undefined : DeepMergeHKTHelper<FilterValuesHKT<Ts, Fs, M>, Fs, M> : unknown;
|
||||
export type DeepMergeHKTHelper<Ts, Fs extends DeepMergeFunctionsURIs, M> = Ts extends ReadonlyArray<unknown> ? IsTuple<Ts> extends true ? Ts extends readonly [
|
||||
] ? unknown : Ts extends readonly [
|
||||
infer T1
|
||||
] ? T1 : EveryIsArray<Ts> extends true ? DeepMergeArraysHKT<Ts, Fs, M> : EveryIsMap<Ts> extends true ? DeepMergeMapsHKT<Ts, Fs, M> : EveryIsSet<Ts> extends true ? DeepMergeSetsHKT<Ts, Fs, M> : EveryIsRecord<Ts> extends true ? DeepMergeRecordsHKT<Ts, Fs, M> : DeepMergeOthersHKT<Ts, Fs, M> : unknown : never;
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
export type DeepMergeRecordsHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeRecordsURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Deep merge arrays.
|
||||
*/
|
||||
export type DeepMergeArraysHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeArraysURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Deep merge sets.
|
||||
*/
|
||||
export type DeepMergeSetsHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeSetsURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Deep merge maps.
|
||||
*/
|
||||
export type DeepMergeMapsHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeMapsURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Deep merge other things.
|
||||
*/
|
||||
export type DeepMergeOthersHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeOthersURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* Filter values.
|
||||
*/
|
||||
export type FilterValuesHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeFunctionKind<Fs["DeepMergeFilterValuesURI"], Ts, Fs, M>;
|
||||
/**
|
||||
* The merge function that returns a leaf.
|
||||
*/
|
||||
export type DeepMergeLeafURI = "DeepMergeLeafURI";
|
||||
/**
|
||||
* Don't filter values.
|
||||
*/
|
||||
export type DeepMergeNoFilteringURI = "DeepMergeNoFilteringURI";
|
||||
/**
|
||||
* Get the leaf type from many types that can't be merged.
|
||||
*/
|
||||
export type DeepMergeLeaf<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = Ts extends readonly [
|
||||
] ? never : Ts extends readonly [
|
||||
infer T
|
||||
] ? T : Ts extends readonly [
|
||||
...infer Rest,
|
||||
infer Tail
|
||||
] ? IsNever<Tail> extends true ? Rest extends ReadonlyArray<unknown> ? DeepMergeLeaf<Rest, Fs, M> : never : DeepMergeLeafApplyFilter<Ts, AssertType<ReadonlyArray<unknown>, TupleTupleToTupleUnion<AssertType<ReadonlyArray<ReadonlyArray<unknown>>, {
|
||||
[I in keyof Ts]: FilterValuesHKT<UnionToTuple<Ts[I]>, Fs, M>;
|
||||
}>>>> : never;
|
||||
export type DeepMergeLeafApplyFilter<Original extends ReadonlyArray<unknown>, Filtered extends ReadonlyArray<unknown>> = Original extends readonly [
|
||||
...infer OriginalRest,
|
||||
infer OriginalTail
|
||||
] ? Filtered extends readonly [
|
||||
...infer FilteredRest,
|
||||
infer FilteredTail
|
||||
] ? OriginalTail extends FilteredTail ? FilteredTail : FilteredTail | DeepMergeLeafApplyFilter<OriginalRest, FilteredRest> : never : never;
|
||||
/**
|
||||
* The meta data deepmerge is able to provide.
|
||||
*/
|
||||
export type DeepMergeBuiltInMetaData = Readonly<{
|
||||
key: PropertyKey;
|
||||
parents: ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>;
|
||||
}>;
|
||||
/**
|
||||
* The default merge function to merge records with.
|
||||
*/
|
||||
export type DeepMergeRecordsDefaultURI = "DeepMergeRecordsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge arrays with.
|
||||
*/
|
||||
export type DeepMergeArraysDefaultURI = "DeepMergeArraysDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge sets with.
|
||||
*/
|
||||
export type DeepMergeSetsDefaultURI = "DeepMergeSetsDefaultURI";
|
||||
/**
|
||||
* The default merge function to merge maps with.
|
||||
*/
|
||||
export type DeepMergeMapsDefaultURI = "DeepMergeMapsDefaultURI";
|
||||
/**
|
||||
* The default filter values function.
|
||||
*/
|
||||
export type DeepMergeFilterValuesDefaultURI = "DeepMergeFilterValuesDefaultURI";
|
||||
/**
|
||||
* The default merge functions to use when deep merging.
|
||||
*/
|
||||
export type DeepMergeFunctionsDefaultURIs = Readonly<{
|
||||
DeepMergeRecordsURI: DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: DeepMergeLeafURI;
|
||||
DeepMergeFilterValuesURI: DeepMergeFilterValuesDefaultURI;
|
||||
}>;
|
||||
export type RecordEntries<T extends Record<PropertyKey, unknown>> = FilterOut<UnionToTuple<{
|
||||
[K in keyof T]: [
|
||||
K,
|
||||
T[K]
|
||||
];
|
||||
}[keyof T]>, undefined>;
|
||||
export type RecordMeta = Record<PropertyKey, RecordPropertyMeta>;
|
||||
export type RecordPropertyMeta<Key extends PropertyKey = PropertyKey, Value = unknown, Optional extends boolean = boolean> = {
|
||||
key: Key;
|
||||
value: Value;
|
||||
optional: Optional;
|
||||
};
|
||||
export type RecordsToRecordMeta<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>> = FilterOutNever<{
|
||||
[I in keyof Ts]: RecordToRecordMeta<Ts[I]>;
|
||||
}>;
|
||||
export type RecordToRecordMeta<T extends Record<PropertyKey, unknown>> = {
|
||||
[K in keyof T]-?: {
|
||||
key: K;
|
||||
value: Required<T>[K];
|
||||
optional: KeyIsOptional<K, T>;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Deep merge records.
|
||||
*/
|
||||
export type DeepMergeRecordsDefaultHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = Ts extends ReadonlyArray<Record<PropertyKey, unknown>> ? SimplifyObject<DeepMergeRecordMetaDefaultHKTProps<RecordsToRecordMeta<Ts>, Fs, M>> : never;
|
||||
/**
|
||||
* Deep merge record props.
|
||||
*/
|
||||
export type DeepMergeRecordMetaDefaultHKTProps<RecordMetas, Fs extends DeepMergeFunctionsURIs, M> = RecordMetas extends ReadonlyArray<RecordMeta> ? CreateRecordFromMeta<MergeRecordMeta<RecordMetas>, Fs, M> : never;
|
||||
export type MergeRecordMeta<RecordMetas extends ReadonlyArray<RecordMeta>> = GroupValuesByKey<FlattenTuples<TransposeTuple<FilterOut<{
|
||||
[I in keyof RecordMetas]: TransposeTuple<RecordEntries<RecordMetas[I]>>;
|
||||
}, readonly [
|
||||
]>>>>;
|
||||
export type GroupValuesByKey<Ts> = Ts extends readonly [
|
||||
infer Keys extends ReadonlyArray<PropertyKey>,
|
||||
infer Values
|
||||
] ? {
|
||||
[I in keyof Keys]: DeepMergeRecordPropertyMetaDefaultHKTGetPossible<Keys[I], FilterOutNever<{
|
||||
[J in keyof Values]: Values[J] extends {
|
||||
key: Keys[I];
|
||||
} ? Values[J] : never;
|
||||
}>>;
|
||||
} : never;
|
||||
export type CreateRecordFromMeta<Ts, Fs extends DeepMergeFunctionsURIs, M> = Ts extends ReadonlyArray<unknown> ? TupleToIntersection<{
|
||||
[I in keyof Ts]: Ts[I] extends {
|
||||
key: infer Key extends PropertyKey;
|
||||
values: infer Values extends ReadonlyArray<unknown>;
|
||||
optional: infer O extends boolean;
|
||||
} ? CreateRecordForKeyFromMeta<Key, Values, O, Fs, M> : never;
|
||||
}> : never;
|
||||
export type CreateRecordForKeyFromMeta<Key extends PropertyKey, Values extends ReadonlyArray<unknown>, Optional extends boolean, Fs extends DeepMergeFunctionsURIs, M> = Optional extends true ? {
|
||||
[k in Key]+?: DeepMergeHKT<Values, Fs, M>;
|
||||
} : {
|
||||
[k in Key]-?: DeepMergeHKT<Values, Fs, M>;
|
||||
};
|
||||
/**
|
||||
* Get the possible types of a property.
|
||||
*/
|
||||
export type DeepMergeRecordPropertyMetaDefaultHKTGetPossible<Key extends PropertyKey, Ts> = Ts extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
] ? DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Ts, {
|
||||
key: Key;
|
||||
values: [
|
||||
];
|
||||
optional: never;
|
||||
}> : never;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeRecordPropertyMetaDefaultHKTGetPossible.
|
||||
*/
|
||||
export type DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Ts extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
], Acc extends {
|
||||
key: PropertyKey;
|
||||
values: ReadonlyArray<unknown>;
|
||||
optional: boolean;
|
||||
}> = Ts extends [
|
||||
...infer Rest,
|
||||
{
|
||||
key: infer K extends PropertyKey;
|
||||
value: infer V;
|
||||
optional: infer O extends boolean;
|
||||
}
|
||||
] ? Acc["optional"] extends true ? Acc extends {
|
||||
values: [
|
||||
infer Head,
|
||||
...infer AccRest
|
||||
];
|
||||
} ? Rest extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
] ? DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Rest, {
|
||||
key: K;
|
||||
values: [
|
||||
PreciseOrUnion<V, Head>,
|
||||
...AccRest
|
||||
];
|
||||
optional: O;
|
||||
}> : {
|
||||
key: K;
|
||||
values: [
|
||||
PreciseOrUnion<V, Head>,
|
||||
...AccRest
|
||||
];
|
||||
optional: O;
|
||||
} : Rest extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
] ? DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Rest, {
|
||||
key: K;
|
||||
values: [
|
||||
V,
|
||||
...Acc["values"]
|
||||
];
|
||||
optional: O;
|
||||
}> : {
|
||||
key: K;
|
||||
values: [
|
||||
V,
|
||||
...Acc["values"]
|
||||
];
|
||||
optional: O;
|
||||
} : Rest extends readonly [
|
||||
RecordPropertyMeta,
|
||||
...ReadonlyArray<RecordPropertyMeta>
|
||||
] ? DeepMergeRecordPropertyMetaDefaultHKTGetPossibleHelper<Rest, {
|
||||
key: K;
|
||||
values: [
|
||||
V,
|
||||
...Acc["values"]
|
||||
];
|
||||
optional: O;
|
||||
}> : {
|
||||
key: K;
|
||||
values: [
|
||||
V,
|
||||
...Acc["values"]
|
||||
];
|
||||
optional: O;
|
||||
} : never;
|
||||
/**
|
||||
* Deep merge arrays.
|
||||
*/
|
||||
export type DeepMergeArraysDefaultHKT<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M> = DeepMergeArraysDefaultHKTHelper<Ts, Fs, M, [
|
||||
]>;
|
||||
/**
|
||||
* Tail-recursive helper type for DeepMergeArraysDefaultHKT.
|
||||
*/
|
||||
export type DeepMergeArraysDefaultHKTHelper<Ts extends ReadonlyArray<unknown>, Fs extends DeepMergeFunctionsURIs, M, Acc extends ReadonlyArray<unknown>> = Ts extends readonly [
|
||||
infer Head extends ReadonlyArray<unknown>,
|
||||
...infer Rest
|
||||
] ? Rest extends readonly [
|
||||
ReadonlyArray<unknown>,
|
||||
...ReadonlyArray<ReadonlyArray<unknown>>
|
||||
] ? DeepMergeArraysDefaultHKTHelper<Rest, Fs, M, [
|
||||
...Acc,
|
||||
...Head
|
||||
]> : [
|
||||
...Acc,
|
||||
...Head
|
||||
] : never;
|
||||
/**
|
||||
* Deep merge sets.
|
||||
*/
|
||||
export type DeepMergeSetsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Set<UnionSetValues<Ts>>;
|
||||
/**
|
||||
* Deep merge maps.
|
||||
*/
|
||||
export type DeepMergeMapsDefaultHKT<Ts extends ReadonlyArray<unknown>> = Map<UnionMapKeys<Ts>, UnionMapValues<Ts>>;
|
||||
/**
|
||||
* Filter out undefined values.
|
||||
*/
|
||||
export type DeepMergeFilterValuesDefaultHKT<Ts extends ReadonlyArray<unknown>> = FilterOut<Ts, undefined>;
|
||||
/**
|
||||
* Get the merge functions with defaults apply from the given subset.
|
||||
*/
|
||||
export type GetDeepMergeFunctionsURIs<PMF extends Partial<DeepMergeFunctionsURIs>> = Readonly<{
|
||||
DeepMergeRecordsURI: PMF["DeepMergeRecordsURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeRecordsURI"] : DeepMergeRecordsDefaultURI;
|
||||
DeepMergeArraysURI: PMF["DeepMergeArraysURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeArraysURI"] : DeepMergeArraysDefaultURI;
|
||||
DeepMergeSetsURI: PMF["DeepMergeSetsURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeSetsURI"] : DeepMergeSetsDefaultURI;
|
||||
DeepMergeMapsURI: PMF["DeepMergeMapsURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeMapsURI"] : DeepMergeMapsDefaultURI;
|
||||
DeepMergeOthersURI: PMF["DeepMergeOthersURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeOthersURI"] : DeepMergeLeafURI;
|
||||
DeepMergeFilterValuesURI: PMF["DeepMergeFilterValuesURI"] extends keyof DeepMergeFunctionURItoKind<any, any, any> ? PMF["DeepMergeFilterValuesURI"] : DeepMergeFilterValuesDefaultURI;
|
||||
}>;
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
type MergeFunctions = {
|
||||
mergeRecords: typeof mergeRecordsInto;
|
||||
mergeArrays: typeof mergeArraysInto;
|
||||
mergeSets: typeof mergeSetsInto;
|
||||
mergeMaps: typeof mergeMapsInto;
|
||||
mergeOthers: typeof mergeOthersInto;
|
||||
};
|
||||
declare function mergeRecordsInto<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeIntoFunctionUtils<M, MM>, M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(mut_target: Reference<Record<PropertyKey, unknown>>, values: Ts, utils: U, meta: M | undefined): void;
|
||||
declare function mergeArraysInto<Ts extends ReadonlyArray<ReadonlyArray<unknown>>>(mut_target: Reference<unknown[]>, values: Ts): void;
|
||||
declare function mergeSetsInto<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(mut_target: Reference<Set<unknown>>, values: Ts): void;
|
||||
declare function mergeMapsInto<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(mut_target: Reference<Map<unknown, unknown>>, values: Ts): void;
|
||||
declare function mergeOthersInto<Ts extends ReadonlyArray<unknown>>(mut_target: Reference<unknown>, values: Ts): void;
|
||||
/**
|
||||
* The default merge functions.
|
||||
*/
|
||||
type MergeFunctions$1 = {
|
||||
mergeRecords: typeof mergeRecords;
|
||||
mergeArrays: typeof mergeArrays;
|
||||
mergeSets: typeof mergeSets;
|
||||
mergeMaps: typeof mergeMaps;
|
||||
mergeOthers: typeof mergeOthers;
|
||||
};
|
||||
declare function mergeRecords<Ts extends ReadonlyArray<Record<PropertyKey, unknown>>, U extends DeepMergeUtils<M, MM>, Fs extends DeepMergeFunctionsURIs, M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(values: Ts, utils: U, meta: M | undefined): DeepMergeRecordsDefaultHKT<Ts, Fs, M>;
|
||||
declare function mergeArrays<Ts extends ReadonlyArray<ReadonlyArray<unknown>>, Fs extends DeepMergeFunctionsURIs, M>(values: Ts): DeepMergeArraysDefaultHKT<Ts, Fs, M>;
|
||||
declare function mergeSets<Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>>(values: Ts): DeepMergeSetsDefaultHKT<Ts>;
|
||||
declare function mergeMaps<Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>>(values: Ts): DeepMergeMapsDefaultHKT<Ts>;
|
||||
declare function mergeOthers<Ts extends ReadonlyArray<unknown>>(values: Ts): unknown;
|
||||
/**
|
||||
* The options the user can pass to customize deepmerge.
|
||||
*/
|
||||
export type DeepMergeOptions<in out M, MM extends Readonly<Record<PropertyKey, unknown>> = {}> = Partial<DeepMergeOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
/**
|
||||
* The options the user can pass to customize deepmergeInto.
|
||||
*/
|
||||
export type DeepMergeIntoOptions<in out M, MM extends Readonly<Record<PropertyKey, unknown>> = {}> = Partial<DeepMergeIntoOptionsFull<M, MM & DeepMergeBuiltInMetaData>>;
|
||||
export type MetaDataUpdater<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = (previousMeta: M | undefined, metaMeta: Readonly<Partial<MM>>) => M;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmerge.
|
||||
*/
|
||||
export type DeepMergeOptionsFull<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
enableImplicitDefaultMerging: boolean;
|
||||
filterValues: DeepMergeUtilityFunctions<M>["filterValues"] | false;
|
||||
}>;
|
||||
/**
|
||||
* All the options the user can pass to customize deepmergeInto.
|
||||
*/
|
||||
export type DeepMergeIntoOptionsFull<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: DeepMergeIntoFunctions<M, MM>["mergeRecords"] | false;
|
||||
mergeArrays: DeepMergeIntoFunctions<M, MM>["mergeArrays"] | false;
|
||||
mergeMaps: DeepMergeIntoFunctions<M, MM>["mergeMaps"] | false;
|
||||
mergeSets: DeepMergeIntoFunctions<M, MM>["mergeSets"] | false;
|
||||
mergeOthers: DeepMergeIntoFunctions<M, MM>["mergeOthers"];
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
filterValues: DeepMergeUtilityFunctions<M>["filterValues"] | false;
|
||||
}>;
|
||||
/**
|
||||
* An object that has a reference to a value.
|
||||
*/
|
||||
type Reference<T> = {
|
||||
value: T;
|
||||
};
|
||||
/**
|
||||
* All the utility functions that can be overridden.
|
||||
*/
|
||||
export type DeepMergeUtilityFunctions<in M> = Readonly<{
|
||||
filterValues: <Ts extends ReadonlyArray<unknown>>(values: Ts, meta: M | undefined) => unknown[];
|
||||
}>;
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
export type DeepMergeFunctions<in M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeUtils<M, MM>>(values: Ts, utils: U, meta: M | undefined) => unknown;
|
||||
}>;
|
||||
export type DeepMergeIntoFunctionsReturnType = void | symbol;
|
||||
/**
|
||||
* All the merge functions that deepmerge uses.
|
||||
*/
|
||||
export type DeepMergeIntoFunctions<in M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeRecords: <Ts extends ReadonlyArray<Readonly<Record<PropertyKey, unknown>>>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<Record<PropertyKey, unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
mergeArrays: <Ts extends ReadonlyArray<ReadonlyArray<unknown>>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<unknown[]>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
mergeMaps: <Ts extends ReadonlyArray<Readonly<ReadonlyMap<unknown, unknown>>>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<Map<unknown, unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
mergeSets: <Ts extends ReadonlyArray<Readonly<ReadonlySet<unknown>>>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<Set<unknown>>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
mergeOthers: <Ts extends ReadonlyArray<unknown>, U extends DeepMergeIntoFunctionUtils<M, MM>>(mut_target: Reference<unknown>, values: Ts, utils: U, meta: M | undefined) => DeepMergeIntoFunctionsReturnType;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
export type DeepMergeUtils<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeFunctions<M, MM>;
|
||||
defaultMergeFunctions: MergeFunctions$1;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmerge: <Ts extends ReadonlyArray<unknown>>(...values: Ts) => unknown;
|
||||
useImplicitDefaultMerging: boolean;
|
||||
filterValues: DeepMergeUtilityFunctions<M>["filterValues"] | undefined;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
skip: symbol;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* The utils provided to the merge functions.
|
||||
*/
|
||||
export type DeepMergeIntoFunctionUtils<in out M, MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData> = Readonly<{
|
||||
mergeFunctions: DeepMergeIntoFunctions<M, MM>;
|
||||
defaultMergeFunctions: MergeFunctions;
|
||||
metaDataUpdater: MetaDataUpdater<M, MM>;
|
||||
deepmergeInto: <Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...values: Ts) => void;
|
||||
filterValues: DeepMergeUtilityFunctions<M>["filterValues"] | undefined;
|
||||
actions: Readonly<{
|
||||
defaultMerge: symbol;
|
||||
}>;
|
||||
}>;
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
export declare function deepmerge<Ts extends Readonly<ReadonlyArray<unknown>>>(...objects: readonly [
|
||||
...Ts
|
||||
]): DeepMergeHKT<Ts, DeepMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
export declare function deepmergeCustom<BaseTs = unknown, PMF extends Partial<DeepMergeFunctionsURIs> = {}>(options: DeepMergeOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Ts extends ReadonlyArray<BaseTs>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeFunctionsURIs<PMF>, DeepMergeBuiltInMetaData>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
export declare function deepmergeCustom<BaseTs = unknown, PMF extends Partial<DeepMergeFunctionsURIs> = {}, MetaData = DeepMergeBuiltInMetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Ts extends ReadonlyArray<BaseTs>>(...objects: Ts) => DeepMergeHKT<Ts, GetDeepMergeFunctionsURIs<PMF>, MetaData>;
|
||||
/**
|
||||
* Deeply merge objects into a target.
|
||||
*
|
||||
* @param target - This object will be mutated with the merge result.
|
||||
* @param objects - The objects to merge into the target.
|
||||
*/
|
||||
export declare function deepmergeInto<T extends object>(target: T, ...objects: ReadonlyArray<T>): void;
|
||||
/**
|
||||
* Deeply merge objects into a target.
|
||||
*
|
||||
* @param target - This object will be mutated with the merge result.
|
||||
* @param objects - The objects to merge into the target.
|
||||
*/
|
||||
export declare function deepmergeInto<Target extends object, Ts extends ReadonlyArray<unknown>>(target: Target, ...objects: Ts): asserts target is SimplifyObject<Target & DeepMergeHKT<[
|
||||
Target,
|
||||
...Ts
|
||||
], DeepMergeFunctionsDefaultURIs, DeepMergeBuiltInMetaData>>;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
*/
|
||||
export declare function deepmergeIntoCustom<BaseTs = unknown>(options: DeepMergeIntoOptions<DeepMergeBuiltInMetaData, DeepMergeBuiltInMetaData>): <Target extends object, Ts extends ReadonlyArray<BaseTs>>(target: Target, ...objects: Ts) => void;
|
||||
/**
|
||||
* Deeply merge two or more objects using the given options and meta data.
|
||||
*
|
||||
* @param options - The options on how to customize the merge function.
|
||||
* @param rootMetaData - The meta data passed to the root items' being merged.
|
||||
*/
|
||||
export declare function deepmergeIntoCustom<BaseTs = unknown, MetaData = DeepMergeBuiltInMetaData, MetaMetaData extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData>(options: DeepMergeIntoOptions<MetaData, MetaMetaData>, rootMetaData?: MetaData): <Target extends object, Ts extends ReadonlyArray<BaseTs>>(target: Target, ...objects: Ts) => void;
|
||||
/**
|
||||
* The different types of objects deepmerge-ts support.
|
||||
*/
|
||||
export declare const enum ObjectType {
|
||||
NOT = 0,
|
||||
RECORD = 1,
|
||||
ARRAY = 2,
|
||||
SET = 3,
|
||||
MAP = 4,
|
||||
OTHER = 5
|
||||
}
|
||||
/**
|
||||
* Get the type of the given object.
|
||||
*
|
||||
* @param object - The object to get the type of.
|
||||
* @returns The type of the given object.
|
||||
*/
|
||||
export declare function getObjectType(object: unknown): ObjectType;
|
||||
/**
|
||||
* Get the keys of the given objects including symbol keys.
|
||||
*
|
||||
* Note: Only keys to enumerable properties are returned.
|
||||
*
|
||||
* @param objects - An array of objects to get the keys of.
|
||||
* @returns A set containing all the keys of all the given objects.
|
||||
*/
|
||||
export declare function getKeys(objects: ReadonlyArray<object>): Set<PropertyKey>;
|
||||
/**
|
||||
* Does the given object have the given property.
|
||||
*
|
||||
* @param object - The object to test.
|
||||
* @param property - The property to test.
|
||||
* @returns Whether the object has the property.
|
||||
*/
|
||||
export declare function objectHasProperty(object: object, property: PropertyKey): boolean;
|
||||
|
||||
export {
|
||||
MergeFunctions as DeepMergeIntoFunctionsDefaults,
|
||||
MergeFunctions$1 as DeepMergeFunctionsDefaults,
|
||||
Reference as DeepMergeValueReference,
|
||||
};
|
||||
|
||||
export {};
|
611
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/dist/index.mjs
generated
vendored
Normal file
611
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/dist/index.mjs
generated
vendored
Normal file
|
@ -0,0 +1,611 @@
|
|||
/**
|
||||
* Special values that tell deepmerge to perform a certain action.
|
||||
*/
|
||||
const actions = {
|
||||
defaultMerge: Symbol("deepmerge-ts: default merge"),
|
||||
skip: Symbol("deepmerge-ts: skip"),
|
||||
};
|
||||
/**
|
||||
* Special values that tell deepmergeInto to perform a certain action.
|
||||
*/
|
||||
const actionsInto = {
|
||||
defaultMerge: actions.defaultMerge,
|
||||
};
|
||||
|
||||
/**
|
||||
* The default function to update meta data.
|
||||
*
|
||||
* It doesn't update the meta data.
|
||||
*/
|
||||
function defaultMetaDataUpdater(previousMeta, metaMeta) {
|
||||
return metaMeta;
|
||||
}
|
||||
/**
|
||||
* The default function to filter values.
|
||||
*
|
||||
* It filters out undefined values.
|
||||
*/
|
||||
function defaultFilterValues(values, meta) {
|
||||
return values.filter((value) => value !== undefined);
|
||||
}
|
||||
|
||||
/**
|
||||
* The different types of objects deepmerge-ts support.
|
||||
*/
|
||||
var ObjectType;
|
||||
(function (ObjectType) {
|
||||
ObjectType[ObjectType["NOT"] = 0] = "NOT";
|
||||
ObjectType[ObjectType["RECORD"] = 1] = "RECORD";
|
||||
ObjectType[ObjectType["ARRAY"] = 2] = "ARRAY";
|
||||
ObjectType[ObjectType["SET"] = 3] = "SET";
|
||||
ObjectType[ObjectType["MAP"] = 4] = "MAP";
|
||||
ObjectType[ObjectType["OTHER"] = 5] = "OTHER";
|
||||
})(ObjectType || (ObjectType = {}));
|
||||
/**
|
||||
* Get the type of the given object.
|
||||
*
|
||||
* @param object - The object to get the type of.
|
||||
* @returns The type of the given object.
|
||||
*/
|
||||
function getObjectType(object) {
|
||||
if (typeof object !== "object" || object === null) {
|
||||
return 0 /* ObjectType.NOT */;
|
||||
}
|
||||
if (Array.isArray(object)) {
|
||||
return 2 /* ObjectType.ARRAY */;
|
||||
}
|
||||
if (isRecord(object)) {
|
||||
return 1 /* ObjectType.RECORD */;
|
||||
}
|
||||
if (object instanceof Set) {
|
||||
return 3 /* ObjectType.SET */;
|
||||
}
|
||||
if (object instanceof Map) {
|
||||
return 4 /* ObjectType.MAP */;
|
||||
}
|
||||
return 5 /* ObjectType.OTHER */;
|
||||
}
|
||||
/**
|
||||
* Get the keys of the given objects including symbol keys.
|
||||
*
|
||||
* Note: Only keys to enumerable properties are returned.
|
||||
*
|
||||
* @param objects - An array of objects to get the keys of.
|
||||
* @returns A set containing all the keys of all the given objects.
|
||||
*/
|
||||
function getKeys(objects) {
|
||||
const keys = new Set();
|
||||
for (const object of objects) {
|
||||
for (const key of [...Object.keys(object), ...Object.getOwnPropertySymbols(object)]) {
|
||||
keys.add(key);
|
||||
}
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
/**
|
||||
* Does the given object have the given property.
|
||||
*
|
||||
* @param object - The object to test.
|
||||
* @param property - The property to test.
|
||||
* @returns Whether the object has the property.
|
||||
*/
|
||||
function objectHasProperty(object, property) {
|
||||
return typeof object === "object" && Object.prototype.propertyIsEnumerable.call(object, property);
|
||||
}
|
||||
/**
|
||||
* Get an iterable object that iterates over the given iterables.
|
||||
*/
|
||||
function getIterableOfIterables(iterables) {
|
||||
let mut_iterablesIndex = 0;
|
||||
let mut_iterator = iterables[0]?.[Symbol.iterator]();
|
||||
return {
|
||||
[Symbol.iterator]() {
|
||||
return {
|
||||
next() {
|
||||
do {
|
||||
if (mut_iterator === undefined) {
|
||||
return { done: true, value: undefined };
|
||||
}
|
||||
const result = mut_iterator.next();
|
||||
if (result.done === true) {
|
||||
mut_iterablesIndex += 1;
|
||||
mut_iterator = iterables[mut_iterablesIndex]?.[Symbol.iterator]();
|
||||
continue;
|
||||
}
|
||||
return {
|
||||
done: false,
|
||||
value: result.value,
|
||||
};
|
||||
} while (true);
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
// eslint-disable-next-line unicorn/prefer-set-has -- Array is more performant for a low number of elements.
|
||||
const validRecordToStringValues = ["[object Object]", "[object Module]"];
|
||||
/**
|
||||
* Does the given object appear to be a record.
|
||||
*/
|
||||
function isRecord(value) {
|
||||
// All records are objects.
|
||||
if (!validRecordToStringValues.includes(Object.prototype.toString.call(value))) {
|
||||
return false;
|
||||
}
|
||||
const { constructor } = value;
|
||||
// If has modified constructor.
|
||||
// eslint-disable-next-line ts/no-unnecessary-condition
|
||||
if (constructor === undefined) {
|
||||
return true;
|
||||
}
|
||||
const prototype = constructor.prototype;
|
||||
// If has modified prototype.
|
||||
if (prototype === null ||
|
||||
typeof prototype !== "object" ||
|
||||
!validRecordToStringValues.includes(Object.prototype.toString.call(prototype))) {
|
||||
return false;
|
||||
}
|
||||
// If constructor does not have an Object-specific method.
|
||||
// eslint-disable-next-line sonar/prefer-single-boolean-return, no-prototype-builtins
|
||||
if (!prototype.hasOwnProperty("isPrototypeOf")) {
|
||||
return false;
|
||||
}
|
||||
// Most likely a record.
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default strategy to merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecords$1(values, utils, meta) {
|
||||
const result = {};
|
||||
for (const key of getKeys(values)) {
|
||||
const propValues = [];
|
||||
for (const value of values) {
|
||||
if (objectHasProperty(value, key)) {
|
||||
propValues.push(value[key]);
|
||||
}
|
||||
}
|
||||
if (propValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updatedMeta = utils.metaDataUpdater(meta, {
|
||||
key,
|
||||
parents: values,
|
||||
});
|
||||
const propertyResult = mergeUnknowns(propValues, utils, updatedMeta);
|
||||
if (propertyResult === actions.skip) {
|
||||
continue;
|
||||
}
|
||||
if (key === "__proto__") {
|
||||
Object.defineProperty(result, key, {
|
||||
value: propertyResult,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
result[key] = propertyResult;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArrays$1(values) {
|
||||
return values.flat();
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSets$1(values) {
|
||||
return new Set(getIterableOfIterables(values));
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMaps$1(values) {
|
||||
return new Map(getIterableOfIterables(values));
|
||||
}
|
||||
/**
|
||||
* Get the last value in the given array.
|
||||
*/
|
||||
function mergeOthers$1(values) {
|
||||
return values.at(-1);
|
||||
}
|
||||
/**
|
||||
* The merge functions.
|
||||
*/
|
||||
const mergeFunctions = {
|
||||
mergeRecords: mergeRecords$1,
|
||||
mergeArrays: mergeArrays$1,
|
||||
mergeSets: mergeSets$1,
|
||||
mergeMaps: mergeMaps$1,
|
||||
mergeOthers: mergeOthers$1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Deeply merge objects.
|
||||
*
|
||||
* @param objects - The objects to merge.
|
||||
*/
|
||||
function deepmerge(...objects) {
|
||||
return deepmergeCustom({})(...objects);
|
||||
}
|
||||
function deepmergeCustom(options, rootMetaData) {
|
||||
const utils = getUtils(options, customizedDeepmerge);
|
||||
/**
|
||||
* The customized deepmerge function.
|
||||
*/
|
||||
function customizedDeepmerge(...objects) {
|
||||
return mergeUnknowns(objects, utils, rootMetaData);
|
||||
}
|
||||
return customizedDeepmerge;
|
||||
}
|
||||
/**
|
||||
* The the utils that are available to the merge functions.
|
||||
*
|
||||
* @param options - The options the user specified
|
||||
*/
|
||||
function getUtils(options, customizedDeepmerge) {
|
||||
return {
|
||||
defaultMergeFunctions: mergeFunctions,
|
||||
mergeFunctions: {
|
||||
...mergeFunctions,
|
||||
...Object.fromEntries(Object.entries(options)
|
||||
.filter(([key, option]) => Object.hasOwn(mergeFunctions, key))
|
||||
.map(([key, option]) => (option === false ? [key, mergeFunctions.mergeOthers] : [key, option]))),
|
||||
},
|
||||
metaDataUpdater: (options.metaDataUpdater ?? defaultMetaDataUpdater),
|
||||
deepmerge: customizedDeepmerge,
|
||||
useImplicitDefaultMerging: options.enableImplicitDefaultMerging ?? false,
|
||||
filterValues: options.filterValues === false ? undefined : (options.filterValues ?? defaultFilterValues),
|
||||
actions,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge unknown things.
|
||||
*
|
||||
* @param values - The values.
|
||||
*/
|
||||
function mergeUnknowns(values, utils, meta) {
|
||||
const filteredValues = utils.filterValues?.(values, meta) ?? values;
|
||||
if (filteredValues.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
if (filteredValues.length === 1) {
|
||||
return mergeOthers(filteredValues, utils, meta);
|
||||
}
|
||||
const type = getObjectType(filteredValues[0]);
|
||||
if (type !== 0 /* ObjectType.NOT */ && type !== 5 /* ObjectType.OTHER */) {
|
||||
for (let mut_index = 1; mut_index < filteredValues.length; mut_index++) {
|
||||
if (getObjectType(filteredValues[mut_index]) === type) {
|
||||
continue;
|
||||
}
|
||||
return mergeOthers(filteredValues, utils, meta);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case 1 /* ObjectType.RECORD */: {
|
||||
return mergeRecords(filteredValues, utils, meta);
|
||||
}
|
||||
case 2 /* ObjectType.ARRAY */: {
|
||||
return mergeArrays(filteredValues, utils, meta);
|
||||
}
|
||||
case 3 /* ObjectType.SET */: {
|
||||
return mergeSets(filteredValues, utils, meta);
|
||||
}
|
||||
case 4 /* ObjectType.MAP */: {
|
||||
return mergeMaps(filteredValues, utils, meta);
|
||||
}
|
||||
default: {
|
||||
return mergeOthers(filteredValues, utils, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge records.
|
||||
*
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecords(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeRecords(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeRecords !== utils.defaultMergeFunctions.mergeRecords)) {
|
||||
return utils.defaultMergeFunctions.mergeRecords(values, utils, meta);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge arrays.
|
||||
*
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArrays(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeArrays(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeArrays !== utils.defaultMergeFunctions.mergeArrays)) {
|
||||
return utils.defaultMergeFunctions.mergeArrays(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge sets.
|
||||
*
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSets(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeSets(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeSets !== utils.defaultMergeFunctions.mergeSets)) {
|
||||
return utils.defaultMergeFunctions.mergeSets(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge maps.
|
||||
*
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMaps(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeMaps(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeMaps !== utils.defaultMergeFunctions.mergeMaps)) {
|
||||
return utils.defaultMergeFunctions.mergeMaps(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Merge other things.
|
||||
*
|
||||
* @param values - The other things.
|
||||
*/
|
||||
function mergeOthers(values, utils, meta) {
|
||||
const result = utils.mergeFunctions.mergeOthers(values, utils, meta);
|
||||
if (result === actions.defaultMerge ||
|
||||
(utils.useImplicitDefaultMerging &&
|
||||
result === undefined &&
|
||||
utils.mergeFunctions.mergeOthers !== utils.defaultMergeFunctions.mergeOthers)) {
|
||||
return utils.defaultMergeFunctions.mergeOthers(values);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default strategy to merge records into a target record.
|
||||
*
|
||||
* @param mut_target - The result will be mutated into this record
|
||||
* @param values - The records (including the target's value if there is one).
|
||||
*/
|
||||
function mergeRecordsInto$1(mut_target, values, utils, meta) {
|
||||
for (const key of getKeys(values)) {
|
||||
const propValues = [];
|
||||
for (const value of values) {
|
||||
if (objectHasProperty(value, key)) {
|
||||
propValues.push(value[key]);
|
||||
}
|
||||
}
|
||||
if (propValues.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const updatedMeta = utils.metaDataUpdater(meta, {
|
||||
key,
|
||||
parents: values,
|
||||
});
|
||||
const propertyTarget = { value: propValues[0] };
|
||||
mergeUnknownsInto(propertyTarget, propValues, utils, updatedMeta);
|
||||
if (key === "__proto__") {
|
||||
Object.defineProperty(mut_target.value, key, {
|
||||
value: propertyTarget.value,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
mut_target.value[key] = propertyTarget.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge arrays into a target array.
|
||||
*
|
||||
* @param mut_target - The result will be mutated into this array
|
||||
* @param values - The arrays (including the target's value if there is one).
|
||||
*/
|
||||
function mergeArraysInto$1(mut_target, values) {
|
||||
mut_target.value.push(...values.slice(1).flat());
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge sets into a target set.
|
||||
*
|
||||
* @param mut_target - The result will be mutated into this set
|
||||
* @param values - The sets (including the target's value if there is one).
|
||||
*/
|
||||
function mergeSetsInto$1(mut_target, values) {
|
||||
for (const value of getIterableOfIterables(values.slice(1))) {
|
||||
mut_target.value.add(value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* The default strategy to merge maps into a target map.
|
||||
*
|
||||
* @param mut_target - The result will be mutated into this map
|
||||
* @param values - The maps (including the target's value if there is one).
|
||||
*/
|
||||
function mergeMapsInto$1(mut_target, values) {
|
||||
for (const [key, value] of getIterableOfIterables(values.slice(1))) {
|
||||
mut_target.value.set(key, value);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the target to the last value.
|
||||
*/
|
||||
function mergeOthersInto$1(mut_target, values) {
|
||||
mut_target.value = values.at(-1);
|
||||
}
|
||||
/**
|
||||
* The merge functions.
|
||||
*/
|
||||
const mergeIntoFunctions = {
|
||||
mergeRecords: mergeRecordsInto$1,
|
||||
mergeArrays: mergeArraysInto$1,
|
||||
mergeSets: mergeSetsInto$1,
|
||||
mergeMaps: mergeMapsInto$1,
|
||||
mergeOthers: mergeOthersInto$1,
|
||||
};
|
||||
|
||||
function deepmergeInto(target, ...objects) {
|
||||
return void deepmergeIntoCustom({})(target, ...objects);
|
||||
}
|
||||
function deepmergeIntoCustom(options, rootMetaData) {
|
||||
const utils = getIntoUtils(options, customizedDeepmergeInto);
|
||||
/**
|
||||
* The customized deepmerge function.
|
||||
*/
|
||||
function customizedDeepmergeInto(target, ...objects) {
|
||||
mergeUnknownsInto({ value: target }, [target, ...objects], utils, rootMetaData);
|
||||
}
|
||||
return customizedDeepmergeInto;
|
||||
}
|
||||
/**
|
||||
* The the utils that are available to the merge functions.
|
||||
*
|
||||
* @param options - The options the user specified
|
||||
*/
|
||||
function getIntoUtils(options, customizedDeepmergeInto) {
|
||||
return {
|
||||
defaultMergeFunctions: mergeIntoFunctions,
|
||||
mergeFunctions: {
|
||||
...mergeIntoFunctions,
|
||||
...Object.fromEntries(Object.entries(options)
|
||||
.filter(([key, option]) => Object.hasOwn(mergeIntoFunctions, key))
|
||||
.map(([key, option]) => (option === false ? [key, mergeIntoFunctions.mergeOthers] : [key, option]))),
|
||||
},
|
||||
metaDataUpdater: (options.metaDataUpdater ?? defaultMetaDataUpdater),
|
||||
deepmergeInto: customizedDeepmergeInto,
|
||||
filterValues: options.filterValues === false ? undefined : (options.filterValues ?? defaultFilterValues),
|
||||
actions: actionsInto,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Merge unknown things into a target.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The values.
|
||||
*/
|
||||
function mergeUnknownsInto(mut_target, values, utils, meta) {
|
||||
const filteredValues = utils.filterValues?.(values, meta) ?? values;
|
||||
if (filteredValues.length === 0) {
|
||||
return;
|
||||
}
|
||||
if (filteredValues.length === 1) {
|
||||
return void mergeOthersInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
const type = getObjectType(mut_target.value);
|
||||
if (type !== 0 /* ObjectType.NOT */ && type !== 5 /* ObjectType.OTHER */) {
|
||||
for (let mut_index = 1; mut_index < filteredValues.length; mut_index++) {
|
||||
if (getObjectType(filteredValues[mut_index]) === type) {
|
||||
continue;
|
||||
}
|
||||
return void mergeOthersInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
}
|
||||
switch (type) {
|
||||
case 1 /* ObjectType.RECORD */: {
|
||||
return void mergeRecordsInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
case 2 /* ObjectType.ARRAY */: {
|
||||
return void mergeArraysInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
case 3 /* ObjectType.SET */: {
|
||||
return void mergeSetsInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
case 4 /* ObjectType.MAP */: {
|
||||
return void mergeMapsInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
default: {
|
||||
return void mergeOthersInto(mut_target, filteredValues, utils, meta);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge records into a target record.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The records.
|
||||
*/
|
||||
function mergeRecordsInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeRecords(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeRecords(mut_target, values, utils, meta);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge arrays into a target array.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The arrays.
|
||||
*/
|
||||
function mergeArraysInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeArrays(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeArrays(mut_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge sets into a target set.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The sets.
|
||||
*/
|
||||
function mergeSetsInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeSets(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeSets(mut_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge maps into a target map.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The maps.
|
||||
*/
|
||||
function mergeMapsInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeMaps(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeMaps(mut_target, values);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Merge other things into a target.
|
||||
*
|
||||
* @param mut_target - The target to merge into.
|
||||
* @param values - The other things.
|
||||
*/
|
||||
function mergeOthersInto(mut_target, values, utils, meta) {
|
||||
const action = utils.mergeFunctions.mergeOthers(mut_target, values, utils, meta);
|
||||
if (action === actionsInto.defaultMerge || mut_target.value === actionsInto.defaultMerge) {
|
||||
utils.defaultMergeFunctions.mergeOthers(mut_target, values);
|
||||
}
|
||||
}
|
||||
|
||||
export { deepmerge, deepmergeCustom, deepmergeInto, deepmergeIntoCustom, getKeys, getObjectType, objectHasProperty };
|
154
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/package.json
generated
vendored
Normal file
154
my-workspace/projects/sae-lib/node_modules/deepmerge-ts/package.json
generated
vendored
Normal file
|
@ -0,0 +1,154 @@
|
|||
{
|
||||
"name": "deepmerge-ts",
|
||||
"version": "7.1.5",
|
||||
"description": "Deeply merge 2 or more objects respecting type information.",
|
||||
"keywords": [
|
||||
"merge",
|
||||
"deepmerge",
|
||||
"deep merge",
|
||||
"deep-merge",
|
||||
"inferred types",
|
||||
"inferred-types",
|
||||
"recursive merge",
|
||||
"recursive-merge",
|
||||
"ts",
|
||||
"ts merge",
|
||||
"ts-merge",
|
||||
"typescript",
|
||||
"typescript merge",
|
||||
"typescript-merge"
|
||||
],
|
||||
"homepage": "https://github.com/RebeccaStevens/deepmerge-ts#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/RebeccaStevens/deepmerge-ts/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/RebeccaStevens/deepmerge-ts.git"
|
||||
},
|
||||
"license": "BSD-3-Clause",
|
||||
"author": {
|
||||
"name": "Rebecca Stevens",
|
||||
"email": "rebecca.stevens@outlook.co.nz"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": {
|
||||
"import": "./dist/index.d.mts",
|
||||
"require": "./dist/index.d.cts"
|
||||
},
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"types": "./dist/index.d.cts",
|
||||
"files": [
|
||||
"dist/",
|
||||
"package.json",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
],
|
||||
"scripts": {
|
||||
"benchmark": "pnpm run build && cd benchmark && pnpm run benchmark; cd ..",
|
||||
"build": "rimraf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
||||
"cz": "git-cz",
|
||||
"lint": "eslint && pnpm run lint:md && pnpm run lint:spelling && pnpm run lint:knip && pnpm run lint:packages",
|
||||
"lint-fix": "eslint --fix && pnpm run lint:md-fix && pnpm run lint:packages-fix",
|
||||
"lint:js": "eslint \"**/*.?([cm])[jt]s?(x)\"",
|
||||
"lint:js-fix": "eslint \"**/*.?([cm])[jt]s?(x)\" --fix",
|
||||
"lint:knip": "pnpm run lint:knip:development && pnpm run lint:knip:production",
|
||||
"lint:knip:development": "knip --exclude exports,nsExports,types,nsTypes",
|
||||
"lint:knip:production": "knip --production --strict --exclude exports,nsExports,types,nsTypes",
|
||||
"lint:md": "markdownlint-cli2",
|
||||
"lint:md-fix": "markdownlint-cli2 --fix",
|
||||
"lint:md-full": "pnpm run lint:md && eslint \"**/*.md\"",
|
||||
"lint:md-full-fix": "pnpm run lint:md-fix && eslint \"**/*.md\" --fix",
|
||||
"lint:packages": "pnpm dedupe --check",
|
||||
"lint:packages-fix": "pnpm dedupe",
|
||||
"lint:spelling": "cspell \"**\" \".github/**/*\"",
|
||||
"lint:yaml": "eslint \"**/*.y?(a)ml\"",
|
||||
"lint:yaml-fix": "eslint \"**/*.y?(a)ml\" --fix",
|
||||
"prepare": "husky",
|
||||
"release": "semantic-release",
|
||||
"test": "pnpm run test:js-run && pnpm run test:types",
|
||||
"test:js": "vitest --coverage",
|
||||
"test:js-run": "vitest run --coverage",
|
||||
"test:types": "pnpm run build && tsd -f 'tests/**/*.test-d.ts' -t 'dist/index.d.mts'",
|
||||
"typecheck": "tsc -p tsconfig.build.json --noEmit"
|
||||
},
|
||||
"resolutions": {
|
||||
"dts-bundle-generator": "9.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "19.5.0",
|
||||
"@commitlint/config-conventional": "19.5.0",
|
||||
"@cspell/dict-cryptocurrencies": "5.0.3",
|
||||
"@eslint/compat": "1.2.2",
|
||||
"@rebeccastevens/eslint-config": "3.3.3",
|
||||
"@rollup/plugin-replace": "6.0.1",
|
||||
"@rollup/plugin-typescript": "12.1.1",
|
||||
"@sebbo2002/semantic-release-jsr": "2.0.1",
|
||||
"@semantic-release/changelog": "6.0.3",
|
||||
"@semantic-release/commit-analyzer": "13.0.0",
|
||||
"@semantic-release/git": "10.0.1",
|
||||
"@semantic-release/github": "11.0.0",
|
||||
"@semantic-release/npm": "12.0.1",
|
||||
"@semantic-release/release-notes-generator": "14.0.1",
|
||||
"@stylistic/eslint-plugin": "2.9.0",
|
||||
"@types/lodash": "4.17.13",
|
||||
"@types/node": "20.17.5",
|
||||
"@typescript-eslint/eslint-plugin": "8.8.1",
|
||||
"@typescript-eslint/parser": "8.8.1",
|
||||
"@vitest/coverage-v8": "2.1.2",
|
||||
"@vitest/eslint-plugin": "1.1.7",
|
||||
"commitizen": "4.3.1",
|
||||
"cspell": "8.15.0",
|
||||
"cz-conventional-changelog": "3.3.0",
|
||||
"eslint": "9.12.0",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-flat-config-utils": "0.4.0",
|
||||
"eslint-import-resolver-typescript": "3.6.3",
|
||||
"eslint-merge-processors": "0.1.0",
|
||||
"eslint-plugin-eslint-comments": "3.2.0",
|
||||
"eslint-plugin-format": "0.1.2",
|
||||
"eslint-plugin-functional": "7.1.0",
|
||||
"eslint-plugin-import-x": "4.4.0",
|
||||
"eslint-plugin-jsdoc": "50.4.3",
|
||||
"eslint-plugin-jsonc": "2.16.0",
|
||||
"eslint-plugin-markdown": "5.1.0",
|
||||
"eslint-plugin-n": "17.12.0",
|
||||
"eslint-plugin-no-only-tests": "3.3.0",
|
||||
"eslint-plugin-optimize-regex": "1.2.1",
|
||||
"eslint-plugin-prettier": "5.2.1",
|
||||
"eslint-plugin-promise": "7.1.0",
|
||||
"eslint-plugin-regexp": "2.6.0",
|
||||
"eslint-plugin-sonarjs": "2.0.4",
|
||||
"eslint-plugin-unicorn": "56.0.0",
|
||||
"eslint-plugin-yml": "1.15.0",
|
||||
"husky": "9.1.6",
|
||||
"jsonc-eslint-parser": "2.4.0",
|
||||
"knip": "5.36.1",
|
||||
"lint-staged": "15.2.10",
|
||||
"lodash": "4.17.21",
|
||||
"markdownlint-cli2": "0.14.0",
|
||||
"prettier": "3.3.3",
|
||||
"prettier-plugin-packagejson": "2.5.3",
|
||||
"rimraf": "6.0.1",
|
||||
"rollup": "4.24.3",
|
||||
"rollup-plugin-deassert": "1.3.0",
|
||||
"rollup-plugin-dts-bundle-generator": "1.4.0",
|
||||
"semantic-release": "24.1.2",
|
||||
"tsc-files": "1.1.4",
|
||||
"tsd": "0.31.2",
|
||||
"typescript": "5.6.3",
|
||||
"vite-tsconfig-paths": "5.0.1",
|
||||
"vitest": "2.1.2",
|
||||
"yaml-eslint-parser": "1.2.3"
|
||||
},
|
||||
"packageManager": "pnpm@9.12.3",
|
||||
"engines": {
|
||||
"node": ">=16.0.0"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue