0.9.0 • Published 10 years ago

troop v0.9.0

Weekly downloads
57
License
MIT
Repository
github
Last release
10 years ago

Troop

Full-featured, testable OOP

Wiki

Reference

Troop features

  • multiple inheritance with traits
  • makes use of ES5 property attributes
    • pseudo-privates are non-enumerable
    • constants are actually read-only
  • testing mode for applying mock methods
  • postponed, on-demand property definitions
  • delegation of instantiation with surrogates
  • support for instance memoization

Troop is distinguished from other OOP-related libs such as MooTools or Backbone by

  • not littering your classes and instances with its own meta-properties
  • non-declarative API leads to better IDE integration
  • offering simpler unit testing with built-in mocks to speed up TDD process

Example

var MyClass = troop.Base.extend()
    .addPrivate({
        _secret: "ufo" // static private property
    })
    .addPublic({
        hello: "world" // static public property
    })
    .addConstants({
        pi: 3.14 // static public constant
    })
    .addMethods({
        init: function (who) {
            this.addPublic({
                hello: who
            });
        }
    });

var myInstance = MyClass.create("all");

myInstance in console

Check out these jsFiddles for more examples:

0.9.0

10 years ago

0.8.1

10 years ago

0.8.0

11 years ago

0.7.2

11 years ago

0.7.1

12 years ago

0.7.0

12 years ago

0.6.1

12 years ago

0.6.0

12 years ago

0.5.1

12 years ago

0.5.0

12 years ago

0.4.0

12 years ago

0.3.9

12 years ago

0.3.8

12 years ago

0.3.7

12 years ago

0.3.6

12 years ago

0.3.5

12 years ago

0.3.4

12 years ago

0.3.3

12 years ago

0.3.2

12 years ago

0.3.1

12 years ago