Socket
Socket
Sign inDemoInstall

wetbox

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wetbox

A collection of prototype tools


Version published
Weekly downloads
2
Maintainers
1
Install size
64.2 kB
Created
Weekly downloads
 

Readme

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

clearEmptyElements( 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

hasDuplicates( n ) Returns true if array contains duplicates

choose( n, k ) The mathematical choose function. One-indexed

ithIteration( n, k, i ) Alias for ithCombination( n, k, i )

inverseIthIteration( n, combinationArray ) Alias for inverseIthCombination( n, combinationArray )

ithCombination( n, k, i ) Given a set of n items, k choices, and an index i, give me a k-sized array of the ith combination. 0 <= i < n.

inverseIthCombination( n, combinationArray ) Given a number n and combinationArray, convert the array into an ith ordering. k is infered from combinationArrays length.

Classes

new WET.game( THREE, gameTitle )
Given a three.js library let THREE = require( 'three' ), initialize a basic game environment using threejs. ie in index.js

WET = require( 'wetbox' )
THREE = require( 'three' )
game = new WET.Game( THREE, 'Wizzy boi' )

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( 
  enabled => { return true },
  up      => { console.log( 'up' ) },
  left    => { console.log( 'left' ) },
  down    => { console.log( 'down' ) },
  right   => { console.log( 'right' ) },
  crouch  => { console.log( 'crouch' ) },
  space   => { console.log( 'space' ) },
  esc     => { console.log( 'esc' ) },
  tab     => { console.log( 'tab' ) },
  enter   => { 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(
  releaseUp     => { console.log( 'release up' ) },
  releaseLeft   => { console.log( 'release left' ) },
  releaseDown   => { console.log( 'release down' ) },
  releaseRight  => { console.log( 'release right' ) },
  releaseCrouch => { console.log( 'release crouch' ) },
)

Administration

Updating npm publish --dry-run npm publish

Keywords

FAQs

Last updated on 17 Jan 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc