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

copy-with

Package Overview
Dependencies
Maintainers
4
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

copy-with - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

lib/copyWithDeepFn.js

1

lib/index.js

@@ -8,2 +8,3 @@ 'use strict';

exports.copyWithDeepVal = require('./copyWithDeepVal');
exports.copyWithDeepFn = require('./copyWithDeepFn');
exports.firstIfSame = require('./firstIfSame');

2

package.json
{
"name": "copy-with",
"version": "1.0.1",
"version": "1.1.0",
"main": "lib/index",

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

@@ -91,2 +91,13 @@ # copy-with

### cw.copyWithDeepFn(input, path, fn)
Returns a copy of `input` where the deeply nested property at `path` (which is an array of string keys) has been set to the return value of calling `fn` with the current value. Useful for situations where you want to modify a value rather than replacing it, which would otherwise require listing the path twice.
Examples:
```js
copyWithDeepFn({ x: { y: { z: 1 } } }, ['x', 'y', 'z'], z => z + 1) // { x: { y: { z: 2 } } }
copyWithDeepFn({ x: { y: { z: [1, 2] } } }, ['x', 'y', 'z'], z => z.concat([3, 4])) // { x: { y: { z: [1, 2, 3, 4] } } }
```
### cw.firstIfSame(original, modified)

@@ -93,0 +104,0 @@

@@ -8,2 +8,3 @@ 'use strict';

exports.copyWithDeepVal = require('./copyWithDeepVal');
exports.copyWithDeepFn = require('./copyWithDeepFn');
exports.firstIfSame = require('./firstIfSame');
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