New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aleatorer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aleatorer

An independent randomization algorithm with data leveling.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Aleatorer

Build Status Coverage Status npm version

NPM

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.

Prerequisites

This library is a server application based on node.js, and use the FileSystem module (fs) to deal with data files.

Installing

$ npm install aleatorer --save

How to use

ES6

import { Aleatorer } from 'aleatorer';

const aleatorer = new Aleatorer({
  id: 'ID_OF_DATA',
  baseData: 'DATA_VARIABLE',
});

CommonJS

var Aleatorer = require('aleatorer').default;

var rand = new Aleatorer({
  id: 'ID_OF_DATA',
  baseData: 'DATA_VARIABLE',
});

After that the library will be available to the Global as Aleatorer.

Methods

Follow the methods that the library provides.

aleatorer.loader();

Loads the original data in the library. If its the first time, loader will 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, loader just load the file information. Must be used just after initial configuration.

Example

aleatorer.loader();

aleatorer.random();

Returns an object with original value and index position of value in the original array

Example

var random = aleatorer.random();

console.log(random.data); // random value from the original data
console.log(random.idx); // random index position in the original data array

aleatorer.adder();

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.

Arguments

ArgumentTypeOptions
variablearray'original data'

Example

aleatorer.adder(variable);

aleatorer.deleter();

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.

Arguments

ArgumentTypeOptions
querystring'value to be deleted'

Example

aleatorer.deleter('query');

aleatorer.logger();

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.

Example

var log = aleatorer.logger();

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

Leandro Fernandes
Leandro Fernandes

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Keywords

FAQs

Package last updated on 04 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc