npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yy-debug

v1.1.3

Published

Javascript Debug Panels (useful for game development)

Downloads

10

Readme

debug.js

debug panels for javascript (designed for game development)

Code Example

const Debug = require('@yy/debug');

// initialize the library
Debug.init();

// send a message to the default panel created in the init()
Debug.log('This is a test message.');

// add an FPS panel and meter
var fps = Debug.add('FPS', {text: '0 FPS', side: 'rightBottom'});
var meter = Debug.addMeter('panel', {side: 'rightBottom'});

// update the FPS
setInterval(function () {
    var FPS = Math.random() * 60;

    // adds a meter line
    Debug.meter(Math.random() * 2 - 1, {panel: meter});

    // replaces all HTML in FPS panel
    Debug.one(Math.round(FPS) + ' FPS', {panel: fps, color: (FPS < 30 ? 'red' : null)});
}, 60);

Debug.add('testing', {text: 'this is another panel.'});

Live Example

https://davidfig.github.io/debug/

see also

  • https://davidfig.github.io/update/
  • https://davidfig.github.io/animate/
  • https://davidfig.github.io/renderer/
  • https://davidfig.github.io/viewport/

Installation

include debug.js in your project or add to your workflow

npm install yy-debug

API Reference

Debug

Kind: global constant

Debug.init([options]) ⇒ HTMLElement

initialize the debug panels (must be called before adding panels) options may also include options for the default debug panel (see Debug.add() for a list of these options)

Kind: static method of Debug
Returns: HTMLElement - div where panel was created

| Param | Type | Default | Description | | --- | --- | --- | --- | | [options] | object | | | | [options.padding] | number | 7 | between parent panels | | [options.color] | string | "'rgba(150,150,150,0.5)'" | default CSS background color for panels |

Debug.changeSide(div, side)

change side of an existing panel

Kind: static method of Debug

| Param | Type | Description | | --- | --- | --- | | div | HTMLElement | panel returned by Debug | | side | string | |

Debug.remove(div)

remove a debug panel

Kind: static method of Debug

| Param | Type | Description | | --- | --- | --- | | div | object | string | or name of panel |

Debug.add(name, [options], [style], [text], [parent]) ⇒ HTMLElement

add debug panel

Kind: static method of Debug
Returns: HTMLElement - div where panel was created

| Param | Type | Default | Description | | --- | --- | --- | --- | | name | string | | of panel | | [options] | object | | | | [options.side] | string | "'rightBottom'" | 'rightBottom' (default), 'leftBottom', 'leftTop', 'rightTop' | | [options.expandable] | number | 0 | or percent size to expand | | [options.default] | boolean | false | if true then this panel replaces default for calls to debug and debugOne | | [options.size] | number | 0 | if > 0 then this is the percent size of panel | | [style] | object | | CSS styles for the panel | | [text] | string | | starting text | | [parent] | string | | attach to another panel (to the left or right, depending on the side of the panel) |

Debug.addMeter(name, [options]) ⇒ HTMLElement

creates a meter (useful for FPS)

Kind: static method of Debug
Returns: HTMLElement - div where panel was created

| Param | Type | Default | Description | | --- | --- | --- | --- | | name | string | | of meter | | [options] | object | | | | [options.side] | string | "='leftBottom'" | 'leftBottom', 'leftTop', 'rightBottom', 'rightTop' | | [options.width] | number | 100 | in pixels | | [options.height] | number | 25 | in pixels |

Debug.meter(percent, [options])

adds a line to the end of the meter and scrolls the meter as necessary must provide either an options.name or options.panel

Kind: static method of Debug

| Param | Type | Description | | --- | --- | --- | | percent | number | between -1 and +1 | | [options] | object | | | [options.name] | string | of panel to add the line | | [options.panel] | object | div of panel as returned by Debug.add() |

Debug.addLink(name, link, [options]) ⇒ HTMLElement

adds a panel with a browser link note: this panel cannot be individually minimized

Kind: static method of Debug
Returns: HTMLElement - div where panel was created

| Param | Type | Default | Description | | --- | --- | --- | --- | | name | string | | | | link | string | | | | [options] | object | | | | [options.side] | string | "='leftBottom'" | 'leftBottom', 'leftTop', 'rightBottom', 'rightTop' | | [options.width] | number | 100 | in pixels | | [options.height] | number | 25 | in pixels | | [options.style] | object | | additional css styles to apply to link |

Debug.log(text, [options])

adds text to the end of in the panel and scrolls the panel

Kind: static method of Debug

| Param | Type | Default | Description | | --- | --- | --- | --- | | text | Array.<string> | string | | may be an array or you can include multiple strings: text1, text2, text3, [options] | | [options] | object | | | | [options.color] | string | | background color for text (in CSS) | | [options.name] | string | | of panel | | [options.debug] | boolean | | invoke debugger from javascript | | [options.panel] | HTMLElement | | returned from Debug.Add() | | [options.console] | boolean | false | print to console instead of panel (useful for fast updating messages) |

Debug.one(text)

replaces all text in the panel

Kind: static method of Debug

| Param | Type | Description | | --- | --- | --- | | text | Array.<string> | string | may be an array or you can include multiple strings: text1, text2, text3, [options] | | [options.name] | string | of panel, defaults to defaultDiv | | [options.debug] | boolean | invoke debugger from javascript | | [options.panel] | HTMLElement | returned from Debug.Add() |

Debug.caller([options])

adds a debug message showing who called the function

Kind: static method of Debug

| Param | Type | Description | | --- | --- | --- | | [options] | object | (see Debug.debug) |

Debug.get(name) ⇒ HTMLElement

returns a panel based on its name

Kind: static method of Debug
Returns: HTMLElement - panel or null if not found

| Param | Type | Description | | --- | --- | --- | | name | string | of panel |

Debug._checkResize(dir)

Kind: static method of Debug

| Param | Type | Description | | --- | --- | --- | | dir | string | to check |

Debug.resize()

resize all panels

Kind: static method of Debug

Debug._isLeft(side) ⇒ boolean

Kind: static method of Debug
Returns: boolean - whether on the left side

| Param | Type | Description | | --- | --- | --- | | side | object | returned by Debug._getSide |

Debug._isBottom(side) ⇒ boolean

Kind: static method of Debug
Returns: boolean - whether on the bottom side

| Param | Type | Description | | --- | --- | --- | | side | object | returned by Debug._getSide |

Debug._keypress(e)

handler for: ` key used to expand default debug box c/C key to copy contents of default div to clipboard

Kind: static method of Debug

| Param | Type | | --- | --- | | e | Event |

Debug._error(e)

handler for errors

Kind: static method of Debug

| Param | Type | | --- | --- | | e | Event |

Debug.clipboard(text)

copies text to clipboard called after pressing c or C (if input is allowed to bubble down) from http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript

Kind: static method of Debug

| Param | Type | | --- | --- | | text | string |


Copyright (c) 2016 YOPEY YOPEY LLC - MIT License - Documented by jsdoc-to-markdown