Socket
Book a DemoInstallSign in
Socket

abz

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

abz

Simple JavaScript random array element chooser with percentage weight|chance support

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
2
-60%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status npm version

abz

Simple JavaScript random array element chooser with percentage weight|chance support.

I was doing some ab thing and I needed it. So I write a simple piece of code and I thought it can|may be used by someone else.

Installation:

You can simply install it from npm:

npm install --save abz

Usage:

import abz from 'abz'; // or require it
const result = abz([
  {
    chance: 70,
    value: 'a',
  }, {
    chance: 20,
    value: 'b',
  }, {
    chance: 10,
    fn: () => {
      if (location.pathname === '/') { // or anything else maybe
        return 'z';
      }
    }
  }
]);

console.log(result); // a, b or z

Ideas || Issues

Just fill an issue and describe it. I'll check it ASAP!

Contribution

You can fork the repository, improve or fix some part of it and then send the pull requests back if you want to see them here. I really appreciate that. :heart:

Keywords

random

FAQs

Package last updated on 30 May 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.