Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/i3raby/prototype
A utility function that allows you to dynamically extend objects with additional properties and methods at runtime. Use this function to easily add methods and properties to existing objects without modifying their original structure.
https://github.com/i3raby/prototype
javascript prototype prototypes typescript
Last synced: about 1 month ago
JSON representation
A utility function that allows you to dynamically extend objects with additional properties and methods at runtime. Use this function to easily add methods and properties to existing objects without modifying their original structure.
- Host: GitHub
- URL: https://github.com/i3raby/prototype
- Owner: i3raby
- License: mit
- Created: 2024-08-21T10:34:12.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-08-21T10:42:23.000Z (4 months ago)
- Last Synced: 2024-08-21T12:05:21.415Z (4 months ago)
- Topics: javascript, prototype, prototypes, typescript
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dynamic Object Extension Utility
A utility function for dynamically extending objects with additional properties and methods at runtime. This library allows you to enhance existing objects without altering their original structure.
## Features
- Dynamically add properties and methods to objects.
- Extend existing objects at runtime.
- Simple and flexible API.## Usage
Here's how you can use the `Prototype` function to extend an object```js
const user = {};const Prototype = require('./src');
Prototype(user, {
id: `${Math.floor(Math.random() * 99999999999) + 88888888}`,
username: function() {
return 'Username'
}
})
console.log(user.id);
console.log(user.username());
```## API
### **`Prototype(object, props)`**
Extends the `object` with properties and methods defined in `props`.
- `object`: The target object to be extended.
- `props`: An object containing the properties and methods to add. Each key represents the property or method name, and each value can be a function (method) or a string (property).## License
This project is licensed under the MIT License. See the [LICENSE](https://github.com/i3raby/Prototype/blob/main/LICENSE) file for details.## Contributing
Contributions are welcome! Please open an issue or submit a pull request to contribute to this project.