1.0.1 • Published 6 years ago

ffg-utils v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

input()

Gets input from the user

typenamedescription
stringquestionStatement in front of the cursor

Example

const {input} = require("ffg-utils");
input("How was your day? ").then(ans => { /* Stuff to do */ });

random()

Returns a random number between two values

typenamedescription
NumberminimumMinimum number of random (inclusive)
NumbermaximumMaximum number of random (exclusive)

Example

// Random number between 10 and 20
const {random} = require("ffg-utils");
var _num = random(10, 20);

choose()

Chooses a random value from arguments

typenamedescription
anythingargs...Minimum number of random (inclusive)

Example

// Chooses from arguments
const {choose} = require("ffg-utils");
var _foo = choose("Hello", "World", "!");

Grid

Grid object

Methods

nameargumentsdescription
constructorw, h, defaultvalWidth, height and default value of all grid cells
entryx, yReturns entry at grid (x, y) position
valuex, y, ?valReturns value at grid (x, y) position, value sets position
swapx1, y1, x2, y2Swaps two grid cells
movex, y, xinc, yincIncreases given cell position by xinc and yinc

Static methods

nameargumentsdescription
fetchindexReturns Grid from Grid.GRIDS at index
entryindex, x, yReturns entry at grid (x, y) position
valueindex, x, y, ?valReturns value at grid (x, y) position, value sets position
swapindex, x1, y1, x2, y2Swaps two grid cells
moveindex, x, y, xinc, yincIncreases given cell position by xinc and yinc
releaseindexSets the grid at index in Grid.GRIDS to null

Variables

typenamedescription
NumberwidthWidth of grid
NumberheightHeight of grid
ObjectentriesArray of all grid cells
NumberidIndex of the grid in Grid.GRIDS

Static variables

typenamedescription
NumberCOUNTNext index of Grid.GRIDS
ObjectGRIDSArray of all Grids
NumberSIZELength of Grid.GRIDS

Example

// Create a 3x3 grid with default value 'apple'
const {Grid} = require("ffg-utils");
var _grid = new Grid(3, 3, "apple");

Vector

Vector object

Methods

nameargumentsdescription
constructor?x, ?y, ?zCreates a vector of x, y, and z (all optional, 0 by default)
addaAdds a Number or Vector to this
subaSubtracts a Number or Vector from this
multaMultiplies a Number or Vector by this
divaDivides this by a Number or Vector

Static methods

nameargumentsdescription
fetchindexReturns Vector from Vector.VECTORS at index
releaseindexSets Vector.VECTORS at index to null
addindex, aAdds a Number or Vector to index at Vector.VECTORS
subindex, aSubtracts a Number or Vector from index at Vector.VECTORS
multindex, aMultiplies a Number or Vector by index at Vector.VECTORS
divindex, aDivides index at Vector.VECTORS by a Number or Vector

Variables

typenamedescription
NumberxValue of x
NumberyValue of y
NumberzValue of z

Static variables

typenamedescription
NumberCOUNTNext index of Vector.VECTORS
ObjectVECTORSArray of all Vectos
NumberSIZELength of Vector.VECTORS

Example

// Create a vector of (3, 5, 0)
const {Vector} = require("ffg-utils");
var _vec2 = new Vector(3, 5);

1.0.1

6 years ago

1.0.0

6 years ago