Giter Club home page Giter Club logo

console-extras.js's Introduction

Console Extras

This package contains chainable enhancements to the JavaScript console object.

Builds: dist/console-extras.js and dist/console-extras.min.js.

Methods

console.times(n)
Limits the next call to n invocations.
e.g.

console.times(5).log("This message will only show up 5 times.")

console.throttle(n)
Throttles the next call to at most once every n milliseconds.
e.g.

console.throttle(1000).log("This message will only show up once per second.")

console.collate(...)
Collects arbitrary data for summarization. Accepts numbers, strings, arrays, objects.

console.summary()
Displays a summary of collated data: Average/stddev for numbers, unique string counts, objects by type, arrays by elements. Must be called in the same chain as .collate().

Examples

Chaining

console.times(5).throttle(1000).log("This message will be printed once per second, up to 5 times.")

Collecting data in a live app e.g.

console
  .collate(1, "foo", { x: 1, y: 2 }, [ 1, 2 ])
  .collate(2, "bar", { x: 2, y: 4 }, [ 5, 4 ])
  .collate(3, "bar", { x: 3, y: 4 }, [ 2, 3 ])
  .throttle(1000)
  .summary()

results in:

0: 2 ± 0.82 (×3)
1: 
  "foo" (×1)
  "bar" (×2)
2: 
  Object (×3)
    x: 2 ± 0.82 (×3)
    y: 3.33 ± 0.94 (×3)
3: 
  Array
    0: 2.67 ± 1.7 (×3)
    1: 3 ± 0.82 (×3)

If you do this in a loop with dynamic data, you will get a summary printed out every second of all collected data. The data is reset every time the summary is output.

console-extras.js's People

Contributors

unconed avatar phlipper avatar

Watchers

JT5D avatar 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.