gt

good-typescript

Some good and useful implementations for TypeScript or JavaScript projects.

Showing:

Popularity

Downloads/wk

4

GitHub Stars

4

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

0

License

Type Definitions

Tree-Shakeable

No?

Categories

Deprecated!
this package has been deprecated

Readme

Build Status

Good

Some good and useful implementations for TypeScript or JavaScript projects.

Download

Directly from the master branch dist folder: https://github.com/SergioMorchon/Good-Typescript/tree/master/dist

Patterns

Here are some examples of the main patterns here.

Future

var async = new Good.Patterns.Future.Async<number, string, string>();

async.await().done((result: number) => {
    console.log(`done: ${result}`);
}).progress((value: string) => {
    console.log(`progress: ${value}`);
}).fail((error: string) => {
    console.log(`error: ${error}`);
}).always(() => {
    console.log("always");
});

async.notify("1");// "progress: 1"
async.notify("3");// "progress: 3"
async.notify("duck!");// "progress: duck!"

async.resolve(4);// "done: 4"
                 // "always"

Parallel Tasks

var task: Good.Patterns.Parallel.Task<string, void, string>,
    p1 = "task", p2 = "must", p3 = ["w", "o", "r", "k"];

task = new Good.Patterns.Parallel.Task<string, void, string>((async: Good.Patterns.Future.Async<string, void, string>, r1: string, r2: string, r3: string[]) => {
    async.resolve([r1, r2, r3.join("")].join(" "));
});

task.run(p1, p2, p3).done((result: string) => {
    console.log(result);// "task must work"
});

Contract

Good.Patterns.Contract.requires(true);// ok
Good.Patterns.Contract.requires(false, "contract violation");// throws a PreConditionError
Good.Patterns.Contract.ensures(true);// ok
Good.Patterns.Contract.ensures(false, "contract violation");// throws a PostConditionError

Namespace

var myModule: any = {},
    path: Object;

path = Good.Patterns.Namespace.extend(myModule, "with.a.namespace");
typeof myModule.with.a.namespace !== "undefined";// true

Command

var data = {
    add: function (s1: number, s2: number) {
        return s1 + s2;
    }
}, command = new Good.Patterns.Command.Invoker(data);

console.log(command.execute("add", 4, 6));// 10
command.execute("notExists");// throws an InvocationError

Mediator

 var group = new Good.Patterns.Mediator.Group(),
    error = "Some core error";

group.subscribe("core-error",(value: any) => {
    console.log(value);
});

group.publish("core-error", error);// "error"

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial