New: Introducing PHP and Composer Support.Read the Announcement
Socket
Book a DemoInstallSign in
Socket

wetbox

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wetbox

A collection of prototype tools

Source
npmnpm
Version
0.3.2
Version published
Maintainers
1
Created
Source

alt text

Setup

npm install wetbox
let WET = require( 'wetbox' )

Functions

getVersion()
Returns the current in-use version of the library

getUrl( url, callback )
Fetches an external API url (typically json) and performs callback( status, response ) when loaded.
Status being a nubmer (ie 400), and response being the data.

zeros( n )
Returns an array of zeros of lenth n

sequence( n )
Returns an array of numbers from 0 .. n-1

randInt( n )
Returns a random int from 0 .. n-1

compress( array )
Remove all zero and falsy values from an array

randomizeArray( array )
Returns array with random-ordered elements using the Fisher-Yates-Knuth shuffle.

leftPad( str, len, fillerChar )
Pads a string up to length len, with single-char: fillerChar (defaults to space character)

toRadians( x )
Convert x degrees to radians

toDegrees( x )
Convert x radians to degrees

Classes

new WET.game( THREE )
Given a three.js library let THREE = require( 'three' ), initialize a basic game environment

Window lickers listeners

keyListen( isEnable, up, left, down, right, crouch, space, esc, tab, enter )
Adds some keyboard listeners to the page for typical game commands. All input params are callback functions, first 5 are mandatory.

WET.keyListen( 
  () => { return true },
  () => { console.log( 'up' ) },
  () => { console.log( 'left' ) },
  () => { console.log( 'down' ) },
  () => { console.log( 'right' ) },
  () => { console.log( 'crouch' ) },
  () => { console.log( 'space' ) },
  () => { console.log( 'esc' ) },
  () => { console.log( 'tab' ) },
  () => { console.log( 'enter' ) },
)

keyUpListen( up, left, down, right, crouch )
Adds key-release listeners for switch-keys, all args are callbacks and always enabled.

WET.keyUpListen(
  () => { console.log( 'release up' ) },
  () => { console.log( 'release left' ) },
  () => { console.log( 'release down' ) },
  () => { console.log( 'release right' ) },
  () => { console.log( 'release crouch' ) },
)

Keywords

prototype

FAQs

Package last updated on 06 Aug 2018

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