Giter Site home page Giter Site logo

zufall's Introduction

Zufall

Generate random values and noise.

Installation

yarn add @tstelzer/zufall
# or
npm install @tstelzer/zufall

Usage

import makeRandom from '@tstelzer/zufall';

// Building with a static seed will
// always return predictable results ...
const random = makeRandom('SEED');

// Static seed value for reference.
random.seed; // 'SEED'

// Pseudo-random number (generic).
random.number(); // Always 0.8566100631751684
random.number(); // Always 0.09421503014329177

// Also exposes different implementations from the underlying RNG
// see https://github.com/davidbau/seedrandom for
// functionality beyond whats documented here.
random.number.alea();
random.number.xor128();
random.number.tychei();
random.number.xorwow();
random.number.xor4096();
random.number.xorshift7();
random.number.quick();

// Pseudo-random number with `n` digits.
random.digits(10) // Always 8709490569
random.digits(10) // Always 1847935272

// Pseudo-random number between min and max (both inclusive).
random.between(0, 100) // Always 86
random.between(0, 100) // Always 9
random.between(0, 100) // Always 99

// Open Simplex Noise.
// Note: Implementation is essentially copied from
// https://github.com/joshforisha/open-simplex-noise-js
// with two additions:
// 1. The internal RNG was replaced.
// 2. The public interface is functional instead of OO.
// 3. The `arrayND` methods have been omitted.
random.noise2D(0, 1) // Always -0.27409970004637957
random.noise3D(0, 1, 2) // Always -0.08090614886731362
random.noise4D(0, 1, 2, 4) // Always -0.3194015527038483

// Omitting a seed will generate practically
// unpredictable results every time.
const random = makeRandom();

Build locally

Clone repository.

git clone github.com/tstelzer/zufall

Install dependencies.

cd zufall
yarn
# or
npm install

Run test suite

Assuming you have cloned the repository and installed dependencies.

yarn test
# or
npm test

zufall's People

Contributors

tstelzer avatar

Watchers

James Cloos avatar  avatar

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.