Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ts-deepmerge

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-deepmerge - npm Package Compare versions

Comparing version 1.0.8 to 1.1.0

9

dist/index.d.ts

@@ -5,3 +5,10 @@ interface IObject {

declare type TUnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
declare const merge: <T extends IObject[]>(...objects: T) => TUnionToIntersection<T[number]>;
declare const merge: {
<T extends IObject[]>(...objects: T): TUnionToIntersection<T[number]>;
options: IOptions;
withOptions<T_1 extends IObject[]>(options: Partial<IOptions>, ...objects: T_1): TUnionToIntersection<T_1[number]>;
};
interface IOptions {
mergeArrays: boolean;
}
export default merge;
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -22,3 +58,5 @@ // istanbul ignore next

if (Array.isArray(result[key]) && Array.isArray(current[key])) {
result[key] = Array.from(new Set(result[key].concat(current[key])));
result[key] = merge.options.mergeArrays
? Array.from(new Set(result[key].concat(current[key])))
: current[key];
}

@@ -35,3 +73,17 @@ else if (isObject(result[key]) && isObject(current[key])) {

};
var defaultOptions = {
mergeArrays: true,
};
merge.options = defaultOptions;
merge.withOptions = function (options) {
var objects = [];
for (var _i = 1; _i < arguments.length; _i++) {
objects[_i - 1] = arguments[_i];
}
merge.options = __assign({ mergeArrays: true }, options);
var result = merge.apply(void 0, __spreadArray([], __read(objects), false));
merge.options = defaultOptions;
return result;
};
exports.default = merge;
//# sourceMappingURL=index.js.map

20

package.json

@@ -6,3 +6,3 @@ {

"license": "ISC",
"version": "1.0.8",
"version": "1.1.0",
"keywords": [

@@ -40,16 +40,16 @@ "typescript",

"devDependencies": {
"@types/jest": "^26.0.23",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@types/jest": "^27.0.2",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"cross-env": "^7.0.3",
"eslint": "^7.26.0",
"eslint": "^8.0.0",
"eslint-config-voodoocreation": "^2.0.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-import": "^2.25.1",
"eslint-plugin-jest": "^25.0.5",
"eslint-plugin-prefer-arrow": "^1.2.3",
"jest": "^26.6.3",
"jest": "^27.2.5",
"npm-run-all": "^4.1.5",
"prettier": "^2.3.0",
"ts-jest": "^26.5.6",
"typescript": "^4.2.4"
"prettier": "^2.4.1",
"ts-jest": "^27.0.5",
"typescript": "^4.4.4"
}
}

@@ -0,1 +1,3 @@

[![npm](https://img.shields.io/npm/v/ts-deepmerge)](https://www.npmjs.com/package/ts-deepmerge)
TypeScript Deep Merge

@@ -59,1 +61,27 @@ =====================

```
### With options
If you would like to provide options to change the merge behaviour, you can use the `.withOptions` method:
```typescript
const obj1 = {
array: ["A"],
};
const obj2 = {
array: ["B"],
}
const result = merge.withOptions(
{ mergeArrays: false },
obj1,
obj2
);
```
The value of the above `result` is:
```json
{
"array": ["B"]
}
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc