Socket
Socket
Sign inDemoInstall

merge-anything

Package Overview
Dependencies
1
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.4 to 5.1.0

dist/types/typeUtils/Assign.d.ts

11

dist/index.es.js
import { isArray, isPlainObject, isSymbol } from 'is-what';
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
function concatArrays(originVal, newVal) {

@@ -66,4 +65,2 @@ if (isArray(originVal) && isArray(newVal)) {

* Basic types overwrite objects or other basic types.
* @param object
* @param otherObjects
*/

@@ -85,3 +82,11 @@ function merge(object, ...otherObjects) {

}
// import { Timestamp } from 'firebase/firestore'
// type T1 = { date: Timestamp }
// type T2 = [{ b: string[] }, { b: number[] }, { date: Timestamp }]
// type Test = Merge<T1, T2>
// type A1 = { arr: string[] }
// type A2 = { arr: number[] }
// type A3 = { arr: boolean[] }
// type Test = Merge<A1, [A2, A3]>
export { concatArrays, merge, mergeAndCompare, mergeAndConcat };

@@ -1,2 +0,2 @@

export { merge, mergeAndCompare, mergeAndConcat } from './merge';
export { concatArrays } from './extensions';
export * from './merge';
export * from './extensions';

@@ -1,15 +0,17 @@

import { O } from 'ts-toolbelt';
declare type ExpandDeep<T> = T extends Record<string | number | symbol, unknown> ? {
[K in keyof T]: ExpandDeep<T[K]>;
} : T extends Array<infer E> ? Array<ExpandDeep<E>> : T;
import type { Assign } from './typeUtils/Assign';
import type { List } from './typeUtils/List';
import type { PrettyPrint } from './typeUtils/PrettyPrint';
/**
* The return type of `merge()`. It reflects the type that is returned by JavaScript.
*
* This TS Utility can be used as standalone as well
*/
export declare type Merge<T extends object, Ts extends List<object>> = PrettyPrint<Assign<T, Ts>>;
/**
* Merge anything recursively.
* Objects get merged, special objects (classes etc.) are re-assigned "as is".
* Basic types overwrite objects or other basic types.
* @param object
* @param otherObjects
*/
export declare function merge<T extends Record<string, any>, Tn extends Record<string, any>[]>(object: T, ...otherObjects: Tn): ExpandDeep<O.Assign<T, Tn, 'deep'>>;
export declare function mergeAndCompare<T extends Record<string, any>, Tn extends Record<string, any>[]>(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): ExpandDeep<O.Assign<T, Tn, 'deep'>>;
export declare function mergeAndConcat<T extends Record<string, any>, Tn extends Record<string, any>[]>(object: T, ...otherObjects: Tn): ExpandDeep<O.Assign<T, Tn, 'deep'>>;
export {};
export declare function merge<T extends Record<string | number | symbol, unknown>, Tn extends Record<string | number | symbol, unknown>[]>(object: T, ...otherObjects: Tn): Merge<T, Tn>;
export declare function mergeAndCompare<T extends Record<string | number | symbol, unknown>, Tn extends Record<string | number | symbol, unknown>[]>(compareFn: (prop1: any, prop2: any, propName: string | symbol) => any, object: T, ...otherObjects: Tn): Merge<T, Tn>;
export declare function mergeAndConcat<T extends Record<string | number | symbol, unknown>, Tn extends Record<string | number | symbol, unknown>[]>(object: T, ...otherObjects: Tn): Merge<T, Tn>;
{
"name": "merge-anything",
"version": "5.0.4",
"version": "5.1.0",
"sideEffects": false,

@@ -26,3 +26,3 @@ "type": "module",

"test": "vitest run",
"build": "rollup -c ./scripts/build.js",
"build": "rollup --bundleConfigAsCjs -c ./scripts/build.js",
"release": "npm run lint && del dist && npm run build && np"

@@ -64,10 +64,9 @@ },

"dependencies": {
"is-what": "^4.1.7",
"ts-toolbelt": "^9.6.0"
"is-what": "^4.1.7"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.34.0",
"@typescript-eslint/parser": "^5.34.0",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"del-cli": "^5.0.0",
"eslint": "^8.22.0",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",

@@ -77,6 +76,6 @@ "eslint-plugin-tree-shaking": "^1.10.0",

"prettier": "^2.7.1",
"rollup": "^2.78.1",
"rollup-plugin-typescript2": "^0.33.0",
"typescript": "^4.7.4",
"vitest": "^0.22.1"
"rollup": "^3.3.0",
"rollup-plugin-typescript2": "^0.34.1",
"typescript": "^4.8.4",
"vitest": "^0.25.1"
},

@@ -83,0 +82,0 @@ "np": {

@@ -29,11 +29,16 @@ # Merge anything 🥡

## Meet the family
## Meet the family (more tiny utils with TS support)
- [is-what 🙉](https://github.com/mesqueeb/is-what)
- [is-where 🙈](https://github.com/mesqueeb/is-where)
- [merge-anything 🥡](https://github.com/mesqueeb/merge-anything)
- [check-anything 👁](https://github.com/mesqueeb/check-anything)
- [remove-anything ✂️](https://github.com/mesqueeb/remove-anything)
- [getorset-anything 🐊](https://github.com/mesqueeb/getorset-anything)
- [map-anything 🗺](https://github.com/mesqueeb/map-anything)
- [filter-anything ⚔️](https://github.com/mesqueeb/filter-anything)
- [find-and-replace-anything 🎣](https://github.com/mesqueeb/find-and-replace-anything)
- [compare-anything 🛰](https://github.com/mesqueeb/compare-anything)
- [copy-anything 🎭](https://github.com/mesqueeb/copy-anything)
- [case-anything 🐫](https://github.com/mesqueeb/case-anything)
- [flatten-anything 🏏](https://github.com/mesqueeb/flatten-anything)
- [is-what 🙉](https://github.com/mesqueeb/is-what)
- [nestify-anything 🧅](https://github.com/mesqueeb/nestify-anything)

@@ -67,2 +72,14 @@ ## Usage

The return type of the `merge()` function is usable as a TypeScript utility as well:
```ts
import type { Merge } from 'merge-anything'
type A1 = { name: string }
type A2 = { types: { water: boolean } }
type A3 = { types: { fighting: boolean } }
type Result = Merge<A1, [A2, A3]>
```
## Rules

@@ -129,3 +146,3 @@

function concatStrings (originVal, newVal, key) {
function concatStrings(originVal, newVal, key) {
if (typeof originVal === 'string' && typeof newVal === 'string') {

@@ -198,3 +215,3 @@ // concat logic

function mergeRecursively (origin, newComer) {
function mergeRecursively(origin, newComer) {
if (!isPlainObject(newComer)) return newComer

@@ -201,0 +218,0 @@ // define newObject to merge all values upon

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc