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

pot.js

v1.2.3

Published

Pot.js is an implemental utility library that can execute JavaScript without burdening the CPU.

Downloads

3

Readme

Pot.js

Build Status

Pot.js Logo

Pot.js / PotLite.js :
Pot.js is an implemental utility library that can execute JavaScript without burdening the CPU.

See Pot.js Document and Reference

Example Pot.js - CPU usage tester


Pot.js / PotLite.js :

Pot.js / PotLite.js implements practical tendency as a substitution utility library.
That includes asynchronous methods as "Deferred" for solution to heavy process.
That is fully ECMAScript compliant.

Pot.js is a JavaScript library that can be performed without causing stress to the UI and the CPU load by using easy loop iteration functions.

With respect to load, you can implement a particular application without requiring the programmer to be aware of.

Pot.js is built around the asynchronous processing and iterator with Deferred. Pot.Deferred is a Deferred object like MochiKit (or JSDeferred like).
That makes it possible to various iterations (forEach, filter, map, reduce, zip, repeat, some etc.).

Moreover, Pot.js is an utility library that handles string processes with various algorithms, and it has the Signal object that can write like aspect-oriented (AOP),
and it has the Event object for DOM listener, and treats it the File API for HTML5. etc.

And, Pot.js never pollute the prototype of the global objects.

We only define the 'Pot' object in the global scope basically.
You can use Pot.js with other available libraries without fear of conflict.

Pot.js is a cross-browser library that works on a Web browser, Node.js, userscript (Greasemonkey, Scriptish) XUL, or (Firefox Add-ons) etc.

PotLite.js is a light version that extracts only the part of asynchronous processing (Deferred etc.) has been implemented in Pot.js.

Install

Will work with common ways.

<script type="text/javascript" src="pot.min.js"></script>
<!-- or -->
<script type="text/javascript" src="potlite.min.js"></script>

For Node.js

npm install pot.js

var pot = require('pot.js');

As for jQuery plugin.

// Run after loading with jQuery.
Pot.deferrizejQueryAjax();

// Ajax-based functions will return with Pot.Deferred object instance.
$.getJSON('/hoge.json').then(function(data) {
    alert(data.results[0].text);
}).rescue(function(err) {
    alert('Error! ' + err);
}).ensure(function() {
    return someNextProcess();
});

// Will added 'deferred' method for effects etc
//  that convert to Deferred functions.
$('div#hoge').deferred('hide', 'slow').then(function() {
    // (...Do something after hide() method completed.)
});

Compatibility

Pot.js / PotLite.js works with the following web browsers.

  • Mozilla Firefox *
  • Internet Explorer 6+
  • Safari *
  • Opera *
  • Google Chrome *

And, it also designed for operate in following environments.

  • Greasemonkey (userscript)
  • Mozilla Firefox Add-On (on XUL)
  • Node.js
  • Other non-browser environment

Test Run

License

Dual licensed under the MIT and GPL v2 licenses.
Copyright © 2012-2014 polygon planet

Documentation And Reference

Blog

Example

Pot.begin(function() {
    Pot.debug('BEGIN example');
}).then(function() {
    // A simple HTTP request
    //  that even works on Node.js (non-browser).
    return Pot.request('pot.js.example.json', {
        mimeType : 'application/json'
    }).ensure(function(res) {
        if (Pot.isError(res)) {
            return {
                foo : 'fooError',
                bar : 'barError',
                baz : 'bazError'
            };
        } else {
            Pot.debug(res.responseText);
            // e.g., responseText = {
            //         foo: 'fooValue',
            //         bar: 'barValue',
            //         baz: 'bazValue'
            //       }
            return Pot.parseFromJSON(res.responseText);
        }
        // Iterate on chain by "forEach" method.
    }).forEach(function(val, key) {
        Pot.debug(key + ' : ' + val); // foo : fooValue ... etc.
        
        // Executed in one second intervals.
        return Pot.wait(1);
        
        // Wait 0.5 seconds
        //  and set the speed to slow between each chains.
    }).wait(0.5).speed('slow').then(function(res) {
        var s = '', keys = [];
        
        // Iterate by "forEach" method on synchronous.
        Pot.forEach(res, function(val, key) {
            s += key;
            keys.push(key);
        });
        keys.push(s);
        return keys;
        
        // Like (Destructuring-Assignment)
    }).then(function(foo, bar, baz, all) {
        Pot.debug('foo = ' + foo); // foo = 'foo'
        Pot.debug('bar = ' + bar); // bar = 'bar'
        Pot.debug('baz = ' + baz); // baz = 'baz'
        Pot.debug('all = ' + all); // all = 'foobarbaz'
        
        return [foo, bar, baz];
        
        // Iterate by "map" method at a slower speed.
    }).map.doze(function(val) {
        Pot.debug('in map.doze(val) : ' + val);
        
        return val + '!';
        
    }).then(function(res) {
        Pot.debug(res); // ['foo!', 'bar!', 'baz!']
        
        var d = new Pot.Deferred();
        return d.then(function() {
            // Generate an error for testing.
            throw new Error('TestError');
            
        }).then(function() {
            // This callback chain never executed
            //  because occured the error.
            Pot.debug('Help me!!');
            
        }).rescue(function(err) {
            // Catch the error.
            Pot.debug(err); // (Error: TestError)
            
        }).then(function() {
            // And, continue the callback chain.
            
            // Iterate by "reduce" method on asynchronous.
            return Pot.Deferred.reduce(res, function(a, b) {
                return a + b;
            }).then(function(result) {
                return result;
            });
        }).begin(); // Begin the callback chain.
        
    }).wait(2).then(function(res) {
        
        Pot.debug(res); // 'foo!bar!baz!'
        
        // Iterate by "filter" method on synchronous.
        return Pot.filter(res.split('!'), function(val) {
            return val && val.length;
        });
    });
    
}).then(function(result) {
    Pot.debug(result); // ['foo', 'bar', 'baz']
    Pot.debug('END example');
    
}).end(); // Chain can be closed by the "end" method on any.

Refer document if you want to need more example and usage.

Pot.js + PotLite.js - Document and Reference