1.0.0 • Published 6 months ago
key-picker v1.0.0
key-picker
A utility to pick specific keys from an object, useful for filtering valid query strings.
Installation
You can install key-picker
using npm:
npm install key-picker
Usage
Here's how you can use the pick
function from key-picker
:
import pick from "key-picker";
const obj = {
name: "John Doe",
age: 30,
email: "john@example.com",
address: "123 Main St",
};
const selectedKeys = ["name", "email"];
const result = pick(obj, selectedKeys);
console.log(result);
// Output: { name: 'John Doe', email: 'john@example.com' }
API
pick<T extends Record<string, unknown>, K extends keyof T>(obj: T, keys: K[]): Partial<T>
TypeScript Support
key-picker
is written in TypeScript and includes type definitions. It provides full type inference for better development experience.
Use Cases
- Filtering query parameters for API requests
- Extracting specific properties from large objects
- Creating subsets of configuration objects
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Author
Sheikh Mohammad Nazmul H. - GitHub
Issues
If you encounter any issues or have feature requests, please file them in the issues section.
1.0.0
6 months ago