Skip to content

i3raby/Prototype

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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 file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request to contribute to this project.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Contributors