1.1.3 • Published 2 years ago

pyrand v1.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

Python random module ported to JavaScript

NOTE: This module is not finished and many functions are still missing

Installation

With npm

npm install pyrand

Import directly from cdn

<script type="module">
  import pyrand from "https://cdn.jsdelivr.net/npm/pyrand/+esm";
</script>

Usage

import pyrand from "pyrand";
// or using CommonJS syntax
const pyrand = require("pyrand");

const float = pyrand.random(); // returns random float between 0 and 1
console.log(float);

const integer = pyrand.randint(1, 3); // returns a random integer between 1 and 3 (inclusive)
console.log(integer);

const array = [1, 2, 3, 4, 5];
pyrand.shuffle(array); // shuffles elements of the array in random order
console.log(array); // mutated array

const randomElement = pyrand.choice(["apple", "orange", "banana"]); // returns a random element from the array
console.log(randomElement);
1.1.3

2 years ago

1.1.2

2 years ago

1.1.0

2 years ago

1.0.16

2 years ago

1.0.13

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago