aleatorer1.0.2 • Public • Published
Aleatorer is an leveled randomization algorithm where all values are used and randomically choosen. This is done by dividing and monitoring data in 4 groups where only the last positions are avaliable for random selection. It works without changes in the original database (except the deleter method), creating a reference file to constantly monitor the randomization process.
This library is a server application based on node.js, and use the FileSystem module (fs) to deal with data files.
$ npm install aleatorer --save
How to use
;const aleatorer =id: 'ID_OF_DATA'baseData: 'DATA_VARIABLE';
var Aleatorer = default;var rand =id: 'ID_OF_DATA'baseData: 'DATA_VARIABLE';
After that the library will be available to the Global as
Follow the methods that the library provides.
Loads the original data in the library. If its the first time,
loaderwill create a file like
aldata_ID_OF_DATA.json. Make sure this file is saved anywhere else in case of using a non-persistent server as Heroku. If its not the first load of data,
loaderjust load the file information. Must be used just after initial configuration.
Returns an object with original value and index position of value in the original array
var random = aleatorer;console; // random value from the original dataconsole; // random index position in the original data array
Detects when new data is added to the basedata and adds it to aleatorer references. You dont pass the new value, it detects de difference in the length of the original array and add the last values to aleatorer data.
Receive the value passed as argument and delete its references on aleatorer data. Actually this is the only method that changes the original data. It deletes the reference and the value from original data.
||string||'value to be deleted'|
This method return all data random information logged in aleatorer in template literals format. It presents every data value followed by how many times it was used. If you have 3000 data, this will log 3000 lines. But to be true, as a leveled randomization the the differences between each value uses hardly is more that 2 or 3.
var log = aleatorer;
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
This project is licensed under the MIT License - see the LICENSE.md file for details