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

@appolo/utils

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appolo/utils - npm Package Compare versions

Comparing version 8.0.54 to 8.0.55

12

lib/arrays.js

@@ -5,2 +5,3 @@ "use strict";

const classes_1 = require("./classes");
const objects_1 = require("./objects");
class Arrays {

@@ -305,4 +306,15 @@ static clone(arr) {

}
static merge(target, source) {
for (let i = 0; i < source.length; i++) {
let item = source[i];
if (objects_1.Objects.isObject(item)) {
objects_1.Objects.merge(target[i] || (target[i] = {}), item);
}
else {
target[i] = item;
}
}
}
}
exports.Arrays = Arrays;
//# sourceMappingURL=arrays.js.map
import {Classes} from "./classes";
import {Objects} from "./objects";

@@ -420,2 +421,14 @@ export class Arrays {

}
public static merge<T>(target: T[], source: T[]) {
for (let i = 0; i < source.length; i++) {
let item = source[i];
if (Objects.isObject(item)) {
Objects.merge(target[i] || (target[i] = {} as any), item);
} else {
target[i] = item;
}
}
}
}

35

lib/objects.js

@@ -211,24 +211,23 @@ "use strict";

static merge(target, ...sources) {
if (typeof target !== 'object' || target === null) {
throw new TypeError('Target must be an object');
if (!sources.length) {
return target;
}
for (const source of sources) {
if (typeof source !== 'object' || source === null) {
continue;
}
for (const key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
if (typeof source[key] === 'object' && source[key] !== null) {
if (!target.hasOwnProperty(key) || typeof target[key] !== 'object' || target[key] === null) {
target[key] = {};
}
Objects.merge(target[key], source[key]);
}
else {
target[key] = source[key];
}
const source = sources.shift();
if (Objects.isObject(target) && Objects.isObject(source)) {
let keys = Object.keys(source);
for (let i = 0, len = keys.length; i < len; i++) {
let key = keys[i], sourceItem = source[key];
if (Objects.isObject(sourceItem)) {
Objects.merge(target[key] || (target[key] = {}), sourceItem);
}
else if (Array.isArray(sourceItem)) {
arrays_1.Arrays.merge(target[key] || (target[key] = []), sourceItem);
}
else {
target[key] = source[key];
}
}
}
return target;
//@ts-ignore
return Objects.merge(target, ...sources);
}

@@ -235,0 +234,0 @@ }

@@ -289,21 +289,22 @@ import {Arrays} from "./arrays";

public static merge(target: any, ...sources: any[]): any {
if (typeof target !== 'object' || target === null) {
throw new TypeError('Target must be an object');
if (!sources.length) {
return target;
}
for (const source of sources) {
if (typeof source !== 'object' || source === null) {
continue;
}
const source = sources.shift();
for (const key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
if (typeof source[key] === 'object' && source[key] !== null) {
if (!target.hasOwnProperty(key) || typeof target[key] !== 'object' || target[key] === null) {
target[key] = {} as any;
}
Objects.merge(target[key], source[key]);
} else {
target[key] = source[key];
}
if (Objects.isObject(target) && Objects.isObject(source)) {
let keys = Object.keys(source);
for (let i = 0, len = keys.length; i < len; i++) {
let key = keys[i],
sourceItem = source[key];
if (Objects.isObject(sourceItem)) {
Objects.merge(target[key] || (target[key] = {}), sourceItem);
} else if (Array.isArray(sourceItem)) {
Arrays.merge(target[key] || (target[key] = []), sourceItem);
} else {
target[key] = source[key];
}

@@ -313,5 +314,6 @@ }

return target as any;
//@ts-ignore
return Objects.merge(target, ...sources);
}
}

@@ -20,3 +20,3 @@ {

"main": "./index.js",
"version": "8.0.54",
"version": "8.0.55",
"license": "MIT",

@@ -23,0 +23,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

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