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

merge-options

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge-options - npm Package Compare versions

Comparing version 0.0.64 to 1.0.0

68

index.js
'use strict';
var isOptionObject = require('is-plain-obj');
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.propertyIsEnumerable;
var globalThis = this;
var defaultMergeOpts = {
const isOptionObject = require('is-plain-obj');
const hasOwnProperty = Object.prototype.hasOwnProperty;
const propIsEnumerable = Object.propertyIsEnumerable;
const globalThis = this;
const defaultMergeOpts = {
concatArrays: false
};
function getEnumerableOwnPropertyKeys(value) {
var keys = [];
const getEnumerableOwnPropertyKeys = value => {
const keys = [];
for (var key in value) {
for (const key in value) {
if (hasOwnProperty.call(value, key)) {

@@ -19,6 +20,7 @@ keys.push(key);

/* istanbul ignore else */
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(value);
const symbols = Object.getOwnPropertySymbols(value);
for (var i = 0; i < symbols.length; i++) {
for (let i = 0; i < symbols.length; i++) {
if (propIsEnumerable.call(value, symbols[i])) {

@@ -31,3 +33,3 @@ keys.push(symbols[i]);

return keys;
}
};

@@ -47,5 +49,5 @@ function clone(value) {

function cloneArray(array) {
var result = array.slice(0, 0);
const result = array.slice(0, 0);
getEnumerableOwnPropertyKeys(array).forEach(function (key) {
getEnumerableOwnPropertyKeys(array).forEach(key => {
result[key] = clone(array[key]);

@@ -58,5 +60,5 @@ });

function cloneOptionObject(obj) {
var result = Object.getPrototypeOf(obj) === null ? Object.create(null) : {};
const result = Object.getPrototypeOf(obj) === null ? Object.create(null) : {};
getEnumerableOwnPropertyKeys(obj).forEach(function (key) {
getEnumerableOwnPropertyKeys(obj).forEach(key => {
result[key] = clone(obj[key]);

@@ -72,4 +74,4 @@ });

*/
function mergeKeys(merged, source, keys, mergeOpts) {
keys.forEach(function (key) {
const mergeKeys = (merged, source, keys, mergeOpts) => {
keys.forEach(key => {
if (key in merged) {

@@ -83,3 +85,3 @@ merged[key] = merge(merged[key], source[key], mergeOpts);

return merged;
}
};

@@ -92,11 +94,11 @@ /**

*/
function concatArrays(merged, source, mergeOpts) {
var result = merged.slice(0, 0);
var resultIndex = 0;
const concatArrays = (merged, source, mergeOpts) => {
let result = merged.slice(0, 0);
let resultIndex = 0;
[merged, source].forEach(function (array) {
var indices = [];
[merged, source].forEach(array => {
const indices = [];
// result.concat(array) with cloning
for (var k = 0; k < array.length; k++) {
// `result.concat(array)` with cloning
for (let k = 0; k < array.length; k++) {
if (!hasOwnProperty.call(array, k)) {

@@ -109,3 +111,3 @@ continue;

if (array === merged) {
// already cloned
// Already cloned
result[resultIndex++] = array[k];

@@ -117,4 +119,4 @@ } else {

// merge non-index keys
result = mergeKeys(result, array, getEnumerableOwnPropertyKeys(array).filter(function (key) {
// Merge non-index keys
result = mergeKeys(result, array, getEnumerableOwnPropertyKeys(array).filter(key => {
return indices.indexOf(key) === -1;

@@ -125,3 +127,3 @@ }), mergeOpts);

return result;
}
};

@@ -145,7 +147,7 @@ /**

module.exports = function () {
var mergeOpts = merge(clone(defaultMergeOpts), (this !== globalThis && this) || {}, defaultMergeOpts);
var merged = {};
const mergeOpts = merge(clone(defaultMergeOpts), (this !== globalThis && this) || {}, defaultMergeOpts);
let merged = {};
for (var i = 0; i < arguments.length; i++) {
var option = arguments[i];
for (let i = 0; i < arguments.length; i++) {
const option = arguments[i];

@@ -152,0 +154,0 @@ if (option === undefined) {

{
"name": "merge-options",
"version": "0.0.64",
"version": "1.0.0",
"description": "Merge Option Objects",

@@ -13,3 +13,3 @@ "license": "MIT",

"engines": {
"node": ">=0.10.0"
"node": ">=4"
},

@@ -34,11 +34,11 @@ "scripts": {

"devDependencies": {
"ava": "^0.12.0",
"coveralls": "^2.11.6",
"nyc": "^6.0.0",
"rimraf": "^2.5.2",
"xo": "^0.12.1"
"ava": "^0.19",
"coveralls": "^2.13",
"nyc": "^10.3",
"rimraf": "^2.5",
"xo": "^0.18"
},
"dependencies": {
"is-plain-obj": "^1.1.0"
"is-plain-obj": "^1.1"
}
}

@@ -31,3 +31,3 @@ # merge-options [![Build Status](https://travis-ci.org/schnittstabil/merge-options.svg?branch=master)](https://travis-ci.org/schnittstabil/merge-options) [![Coverage Status](https://coveralls.io/repos/schnittstabil/merge-options/badge.svg?branch=master&service=github)](https://coveralls.io/github/schnittstabil/merge-options?branch=master) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)

### mergeOptions(option1, ...options)<br/>mergeOptions.call(config, option1, ...options)
### mergeOptions(option1, ...options)<br/>mergeOptions.call(config, option1, ...options)<br/>mergeOptions.apply(config, [option1, ...options])

@@ -80,4 +80,9 @@ `mergeOptions` recursively merges one or more *Option Objects* into a new one and returns that. The `options` are merged in order, thus *Option Values* of additional `options` take precedence over previous ones.

// Via call
mergeOptions.call({concatArrays: true}, {src: ['src/**']}, {src: ['test/**']})
//=> {src: ['src/**', 'test/**']}
// Via apply
mergeOptions.apply({concatArrays: true}, [{src: ['src/**']}, {src: ['test/**']}])
//=> {src: ['src/**', 'test/**']}
```

@@ -84,0 +89,0 @@

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