npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aleatorer

v1.0.2

Published

An independent randomization algorithm with data leveling.

Downloads

4

Readme

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

| Argument | Type | Options | |----------|---------|-------------------| |variable |array | '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

| Argument | Type | Options | |----------|---------|-------------------| |query |string | '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