![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
A library for immutably working with JavaScript objects.
$ npm install --save copy-with
var cw = require('copy-with');
var foo = { x: 1, y: 1 };
var bar = cw.copyWith(foo, { y: 2, z: 3 }); // { x: 1, y: 2, z: 3 }
This preserves referential equality and allows comparisons like this:
if (prevObj === newObj) { /* `newObj` has definitely changed */ }
This works very nicely with Redux, among other functionally-inspired libraries and patterns!
Returns a copy of input
with changes
applied. Similar to Object.assign({}, input, changes)
, but will return the original input
if applying changes
wouldn't actually change any values.
Examples:
copyWith({ x: 1 }, { y: 2 }) // { x: 1, y: 2 }
copyWith({ x: 1 }, { x: 2 }) // { x: 2 }
copyWith({ x: 1, y: 2 }, { x: 1 }) // Returns `input`, no changes necessary
Returns a copy of input
with keys
(and their associated values) removed, or returns the original input
if it does not have any of the keys
specified.
Examples:
copyWithout({ x: 1, y: 2 }, 'y') // { x: 1 }
copyWithout({ x: 1, y: 2, z: 3 }, 'x', 'y') // { z: 3 }
copyWithout({ x: 1 }, 'y') // Returns `input`, no changes necessary
Returns a copy of input
with a single change made: key
is set to value
. Returns the original input
if key
is already set to value
in input
.
Examples:
copyWithVal({ x: 1, y: 2 }, 'y', 3) // { x: 1, y: 3 }
copyWithVal({ x: 1, y: 2 }, 'x', 1) // Returns `input`, no changes necessary
Returns a copy of input
where changes
have been applied to the deeply nested object at path
, which is an array of string keys. Returns the original input
if there are no changes to be made.
Examples:
copyWithDeep({ x: { y: { z: 1 } } }, ['x', 'y'], { w: 2 }) // { x: { y: { z: 1, w: 2} } }
copyWithDeep({ x: { y: 1, z: 2 } }, ['x'], { y: 1 }) // Returns `input`, no changes necessary
Returns a copy of input
where the deeply nested property at path
(which is an array of string keys) has been set to value
. Returns the original input
if there is no change to be made.
Examples:
copyWithDeepVal({ x: { y: { z: 1 } } }, ['x', 'y', 'z'], 2) // { x: { y: { z: 2 } } }
copyWithDeepVal({ x: { y: 1 } }, ['x', 'y'], 1) // Returns `input`, no changes necessary
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:
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] } } }
Returns modified
, unless it is identical (given a shallow equality comparison) to original
, in which case it returns original
. This function supports arrays, unlike most functions in this library!
Examples:
var array = ['one', 'two', 'three']
firstIfSame(array, array.map(s => s.toUpperCase())) // Returns `modified`, which is ['ONE', 'TWO', 'THREE']
firstIfSame(array, array.map(s => s.toLowerCase())) // Returns `original`, which is `array` (['one', 'two', 'three'])
You'll need to be running at least Node v6 - this project is written in ES2015 (aka ES6) and doesn't use Babel for tests.
Clone this repo, and run npm install
. You can run npm test
to run unit tests. Run npm run build
to compile to ES5 in the lib
directory.
$ npm test
$ npm version [major|minor|patch]
$ npm run build
$ npm publish
$ git push --tags
We'd gladly accept PRs for the following:
copyWithDeep
and copyWithDeepVal
functionsFAQs
A library for immutably working with JavaScript objects.
The npm package copy-with receives a total of 5 weekly downloads. As such, copy-with popularity was classified as not popular.
We found that copy-with demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.