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

picket

v0.1.0

Published

Picket allows you to create large-scale object-orientated architectures in JavaScript

Downloads

21

Readme

Build Status

Picket

Picket allows you to create large-scale object-orientated architectures in JavaScript.

The current feature list includes the following; classes, abstract classes, interfaces, inheritance, class properties/fields, class methods, class constructors, class constants, class events, abstract class members, typing of properties, typing of method arguments, typing of method return values, method overloading, optional method arguments, autoloading classes and interfaces and a reflection API.

I am keen to hear from anyone who is interested in contributing, whether that be actual pull requests or simply using the code and/or filing issues.

Documentation

There is full documentation on each feature on the Picket website at (http://picketjs.com/documentation.html).

There is a tutorial series currently being and this will be available as soon as possible. This will be a considerably more friendly introduction to coding in Picket.

Example

The following shows some basics of inheritance, abstraction and type safety.

define(

'class Animal',
{
    
    'private weight (number)': null,
    
    'abstract protected getStartingWeight () -> number': undefined,
    
    'public construct ()': function()
    {
        this.weight(this.getStartingWeight());
    },
    
    'public eat (Food)': function(food)
    {
        this.weight(this.weight() + food.getCalories() / 10);
    },
    
    'public getWeight () -> number': function()
    {
        return this.weight();
    }
    
});
define(

'class Pig extends Animal',
{
    
    'protected getStartingWeight () -> number': function()
    {
        return 1000;
    }
    
});
define(

'class Food',
{
    
    'private calories (number)': null,
    
    'public construct (number)': function(calories)
    {
        this.calories(calories);
    },
    
    'public getCalories () -> number': function()
    {
        return this.calories();
    }
    
});

Given these classes, the following Jasmine test will pass:

describe('Pig', function(){
    
    it('gains weight when it eats', function(){
        
        var pete = new Pig();
        pete.eat(new Food(100));
        expect(pete.getWeight()).toBe(1010);
        
    });
    
});

Running the code

In order to run your own Picket, download one of the files from the build directory and include something like the following in your HTML. You could alternatively get the files from Bower or NPM via the alias picket.

<script type="text/javascript" src="path/to/picket.js"></script>
<script>
    start('MyNamespace.Start', { 'MyNamespace': '/public/scripts' });
</script>

This example expects that you have a class named MyNamespace.Start inside the file /public/scripts/Start.js. This file must have a constructor that expects no arguments. Further classes must be named to match the file system.

The following is an example of what MyNamespace.Start may look like and assumes there are classes at /public/scripts/Application.js and /public/scripts/Application/Controller.js.

define(

'require MyNamespace.Application',
'require MyNamespace.Application.Controller',

'class MyNamespace.Start',
{
    
    'public construct ()': function()
    {
        
        var application = new MyNamespace.Application(
            new MyNamespace.Application.Controller()
        );
        
        application.run();
        
    }
    
});

Contributing

All contributions are welcome. To do so, branch from develop and create a pull request.

Whilst all contributions are indeed welcome, I would ideally like to see supporting unit tests and integration tests for any changes or new features. Unit tests are based on one single class and reside along the class - they should consider all details of said class. Integration tests are like documentation - they should demonstrate how a user consumes a feature and will likely cover functionality within many classes.

To run the tests, use Node.js and NPM to install the dependencies. Then type gulp within the root directory of the project. If you are new to Node and would like assistance, feel free to contact me.

Roadmap

The following describes the likely features ahead for Picket.

  • Tutorials
  • Browser support - right now, Picket is only guaranteed to work in the latest versions of Chrome and Firefox. This is a work in progress and is likely to be resolved in the coming weeks all the way back to Internet Explorer 6, Android 2.3, iOS 4.3 and the like.
  • Node.js compatability
  • Integration with an established autoloading system such as AMD or Require.js.
  • New language features - currently being considered features include variadic methods, enums, generics and more.
  • Facility to write code without the limitations imposed by the nature of class declarations being valid JavaScript literals. This code would be identical but without quotes around signatures, commas after class members etc and would then be compilable to valid Picket.

Contact

You are encouraged to contact me at [email protected] if you want to be involved in the project or if you want any assistance in using it for yourself.