@ulisesgascon/soft-assign-deep-property
v2.0.0
Published
A simple way to assign a deep property to an object without overwriting any existing properties within it
Downloads
2
Readme
About
A simple way to assign a deep property to an object without overwriting any existing properties within it
❤️ Awesome Features:
- Simple and easy to use 🔥
- Typescript support 💪
- Zero dependencies 🚀
- Easy to use and great test coverage ✅
Installation
npm install @ulisesgascon/soft-assign-deep-property
Usage
Simple example
Importation
const { softAssign } = require("@ulisesgascon/soft-assign-deep-property");
import { softAssign } from "@ulisesgascon/soft-assign-deep-property";
Usage
const data = {
I: {
will: {
say: "Hello World!",
},
},
};
// ✅ Just add deep properties
softAssign(data, ["you", "will", "say"], "This is cool!");
console.log(data.you.will.say); // This is cool!
// ❌ Avoid to modify existing properties
softAssign(data[("I", "will", "say")], "New Value!");
console.log(data.I.will.say); // Hello World!
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Ulises Gascón - Initial work- - @ulisesGascon
See also the list of contributors who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- Based on a Stack Overflow snippet made by Kennytm
- This project is under development, but you can help us to improve it! We :heart: FOSS!