Git Product home page Git Product logo

pick-one-by-weight's Introduction

pick-one-by-weight

pick-one-by-weight chooses a key string from an Object based on the weight of its value against all other values in the Object

Object is what the type is called in javascript, but most commonly the structure we are looking into is called a HashMap or HashTable.

Build Status

install

npm install pick-one-by-weight

examples

var pickOneByWeight = require('pick-one-by-weight')
var p = { a: 2, b: 3, c: 5 }
console.log(pickOneByWeight(p))
// output is a 20% of the time, b 30% of the time, and c 50% of the time.

development

First clone by doing: git clone git clone https://github.com/swang/pick-one-by-weight.git

Then npm install with devDependencies. npm install --dev

Then run babel-watch npm run babel-watch

Note: If you want to use GitHub, you must fork this repo over to your account, then change the git url from my repo to yours. You can then make commits to your version, push the changes, and then make a Pull Request.

license

ISC

author

Shuan Wang ([email protected])

pick-one-by-weight's People

Contributors

swang avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

revln9

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.