propaccess
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

✓ PropAccess

Deep property access written in TS.

📦 Installation

npm install propaccess

Benefits

  • [x] Type safe string with dot notation for query nested object.
  • [x] Property autocomplete

Enjoy :) ;) ...

📚 Documentation

deepPropAccess<T, P extends Path<T>>(obj: T, key: P):

const obj = {
  data: {
    numberProp: 2,
    stringProp: 'code',
    nullProp: null,
    undefinedProp: undefined,
    arrayProp: [1, 2, 3, 4, 5],
    deep: {
      key: 1,
      deep: {
        key: 2,
        deep: {
          key: 3,
        },
      },
    },
  },
}

const props = deepPropAccess(obj, 'data.arrayProp')

🤝 Contributing

  • Fork it!
  • Create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am 'Add some feature'
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

👥 Credits


💢 Troubleshootings

This is just a personal project created for study / demonstration purpose and to simplify my working life, it may or may not be a good fit for your project(s).


❤️ Show your support

Please this repository if you like it or this project helped you!
Feel free to open issues or submit pull-requests to help me improving my work.


🤖 Author

Chris M. Perez

You can follow me on github · twitter


Copyright ©2022 propaccess.

Package Sidebar

Install

npm i propaccess

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

4.55 kB

Total Files

5

Last publish

Collaborators

  • chris5855