2.0.0 • Published 6 months ago

@ulisesgascon/soft-assign-deep-property v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

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

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

2.0.0

6 months ago

1.0.0

1 year ago