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

ludwig

v1.0.2

Published

A class definition module with some syntactic sugar

Downloads

2

Readme

ludwig

A module that adds a classy syntax to javascript

Install:

npm i -S ludwig

Example:

var ludwig = require('ludwig');

var Adder = ludwig.define(function(){
  this.constructor = function Adder(a, b)
  {
    this._a = a;
    this._b = b;
  }

  this.method.add = function() { return this._a + this._b; }

  this.get.a = function() { return this._a; }

  this.get.b = function() { return this._b; }

  this.set.a = function(val) { this._a = val; }

  this.set.b = function(val) { this._b = val; }
});

var SubAdder = ludwig.define(function(){
  this.extends = Adder;

  this.constructor = function(a, b, c)
  {
    this.super.call(this, a, b);
    this._c = c;
  }

  this.method.add = function() { return this.super() + this._c; }

  this.get.c = function() { return this._c; }

  this.set.c = function(val) { this._c = val; }
});

var subAdderInstance = new SubAdder(1, 2, 3);
subAdderInstance instanceof Adder; //true
subAdderInstance.a;// 1
subAdderInstance.b;// 2
subAdderInstance.c;// 3
subAdderInstance.add();// 6

ludwig.define

Generates a class based on input function

Parameters

fn: function, The class definition

Returns: function, The class constructor

define.__extend(con, ext)

Extends a class with another

Parameters

con: function, The class that is extending

ext: function, The class to be extended

Returns: function, A subclass of the extended class

define._addSuper(con)

Creates a definition to super on the class

Parameters

con: function, The class to add the reference to super to

define._addSuperStatic(con)

Same as __addSuper, but alters the static class instead

Parameters

con: function, The class to add the reference to super to

define._addGetter(obj, name, fn)

Adds a property getter to an object

Parameters

obj: Object, The object to add the getter to

name: string, The name of the getter

fn: function, The getter function

define._addSetter(obj, name, fn)

Adds a property setter to an object

Parameters

obj: Object, The object to add the setter to

name: string, The name of the setter

fn: function, The setter function

define._addProperties(con, definition)

Adds a list of properties to a class

Parameters

con: function, The class to add the properties to

definition: Object, The class definition object

define._addMethod(obj, name, fn)

Adds a method to an object

Parameters

obj: Object, The object to add the method to

name: string, The name of the method

fn: function, The method itself

define._addMethods(con, definition)

Adds a list of methods to a class

Parameters

con: function, The class to add the methods to

definition: Object, The class definition object

define._addStatic(con, defStatic)

Adds static members to the class

Parameters

con: function, The class to add the static members to

defStatic: Object, The static definition object isolated from the class definition object


ludwig.utils

A module of common utilities

utils.unwrap(input, defaults)

Copies an properties from one object to another overriding defaults

Parameters

input: Object | function, The optional properties

defaults: Object, The default properties

Returns: Object, An object with the optional properties overriding the default