New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ebflat9/fp

Package Overview
Dependencies
Maintainers
1
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ebflat9/fp - npm Package Compare versions

Comparing version 1.1.22 to 1.1.23

2

package.json
{
"name": "@ebflat9/fp",
"version": "1.1.22",
"version": "1.1.23",
"description": "my fp utils",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -433,2 +433,23 @@ /**

/**
* Merge
* @param {object} a - Object to merge into
* @param {object} b - Object with diffs to merge
* @return {object} c - Result of merge
*/
export function merge(a, b) {
if (!a && b) return b
if (isArray(b)) {
return b.map((value, i) => merge(a[i], value))
}
if (isObject(b)) {
const result = deepCopy(a)
for (const key of Reflect.ownKeys(b)) {
result[key] = merge(a[key], b[key])
}
return result
}
return b
}
/**
* Stringifying functions

@@ -435,0 +456,0 @@ * Provides helper functions to stringify and parse JSON, along with numbers

@@ -702,2 +702,51 @@ import * as combinators from '../src/combinators.js'

})
describe('merge', function () {
it('should merge arrays', function () {
const a = [1, 2, 3]
const b = [1, 2, 4]
assert.deepEqual(combinators.merge(a, b), [1, 2, 4])
})
it('should merge objects', function () {
const a = {
name: 'jim',
age: 15,
address: {
city: 'Hellosville',
},
}
const b = {
name: 'john',
likes: ['cats', 'birds'],
address: {
street: '123 Fake st',
},
}
assert.deepEqual(combinators.merge(a, b), {
name: 'john',
age: 15,
likes: ['cats', 'birds'],
address: {
city: 'Hellosville',
street: '123 Fake st',
},
})
})
})
describe('merge and diff', function () {
it('should diff and merge resulting in deepEqual objects', function () {
const a = {
name: 'Jim',
catName: 'Steve Lu-cat-ther',
}
const b = {
name: 'Jim',
age: 16,
catName: 'Steve Lu-cat-ther',
}
assert.deepEqual(combinators.diff(a, b), { age: 16 })
assert.deepEqual(combinators.merge(b, combinators.diff(a, b)), b)
})
})
})
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