2.1.1 • Published 2 years ago

@sui.gn/mlearning v2.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

README.md

mLearning

mLearning is a machine learning tools module that provides an efficient way to invoke your tools. RECOMMENDED Install through npm install neurons.me.

Usage

The index.js file in your mLearning module is responsible for loading your src. Here's an explanation of how mLearning exports and treats the files inside the methods, lib, and utils directories:

methods directory:

The methods directory contains JavaScript files that define various methods or functions. When mLearning loads, it reads all the files in the methods directory using the fs.readdirSync function. For each file, it removes the file extension and checks if the method name already exists. If the method name already exists, it appends a number to the method name to ensure uniqueness. It then requires the method file using require and adds the method to the methods object, using the modified method name as the key.

lib directory:

The lib directory contains JavaScript files that provide additional functionality or libraries. The treatment of files in the lib directory is similar to the methods directory. mLearning reads all the files in the lib directory, removes the file extension, checks for uniqueness, and requires the file. The required module is then added to the utils object, using the modified file name as the key.

utils directory:

The utils directory contains JavaScript files that define utility functions or helper methods. The treatment of files in the utils directory is the same as the methods and lib directories. mLearning reads the files, modifies the file names for uniqueness, requires the files, and adds them to the utils object. By organizing the methods, libraries, and utility functions in separate directories, mLearning provides a modular approach to its functionality. It dynamically loads and exports these modules, allowing you to access them through the methods, libs, and utils objects within mLearning. This structure promotes code organization and reusability, making it easier to maintain and extend the mLearning application.

Adding Methods

Create a new JavaScript file in the src/methods directory. Define your method as a regular JavaScript function inside the file. Save the file with a .js extension. For example, let's say you want to add a method called multiply that multiplies two numbers. Create a file named multiply.js in the src/methods directory with the following code:

function multiply(x, y) {
  return x * y;
}
module.exports = multiply;

Now, you can access the multiply method as mLearning.method.multiply when you load the mLearning module.

Adding Utils

Create a new JavaScript file in the src/utils directory. Define your utility functions inside the file. Save the file with a .js extension. For example, let's say you want to add a utility function called lastUsed that returns the last used item in an array. Create a file named lastUsed.js in the src/utils directory with the following code:

function lastUsed(arr) {
  return arr[arr.length - 1];
}

module.exports = lastUsed;

Now, you can access the lastUsed utility function as mLearning.utils.lastUsed when you load the mLearning module.

Using Methods

To use the methods in the mLearning module, you can call them and pass any number of arguments separated by commas.

console.log(mLearning.method.multiply(3, 4)); // Output: 12
console.log(mLearning.method.multiply(2, 5, 7)); // Output: 10 (the additional argument 7 is ignored)

You can modify the implementation of your methods in the corresponding method files to handle the parameters as needed. The ...params syntax allows you to accept an indefinite number of arguments as an array within your method.

Using Utils

To use the utils in the mLearning module, you can call them and pass any necessary arguments.

console.log(mLearning.utils.lastUsed([1, 2, 3, 4])); // Output: 4

You can modify the implementation of your utils in the corresponding util files to handle the arguments as needed.

Adding Additional Modules

If you want to include additional modules, you can create a new directory in the src directory, such as src/lib, and place your module files inside it. For example, let's say you want to add a module called files. Create a new file named files.js inside the src/lib directory with your module's functionality. Then, you can access the files module as mLearning.lib.files when you load the mLearning module.

Feel free to add more methods, utils, or modules to the mLearning module and use them as needed in your project.

Package Details

Package Name: mLearning Description: Machine Learning Tools License: MIT License Dependencies: The mLearning module does not have any external dependencies. It is designed to work in conjunction with the neurons.me package.

Contributions Contributions are welcome! If you find any issues or have suggestions for improvement, please open an issue on the GitHub repository. Pull requests are also appreciated.

License

This project is licensed under the terms of the MIT License. See the LICENSE file for more information.

2.1.1

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.1.0

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

1.0.3

2 years ago

1.0.0

2 years ago