Skip to content

tlojs/tlojs

Repository files navigation

TLO.js (The Last One)

TLO.js is the last npm package that you'll have to install. With little to no sub dependencies The goal of this repo is to jam pack it full of handy functions, functionality, etc to get the job done.

Sub Libraries

  • Array
  • Dependency Injection
  • JSON
  • Table
  • Events
  • Logger
  • String

Examples

Table Usage

const data = [
  { a: 1, b: 2},
  { a: -1, b: 3}
]

const table = new Table({ data })
table.sort(0, true)
const query = table.select('A:B')

const results = query.exec(Sum)

// Render the table
const renderer = new TableRenderer(table)
renderer.renderTo(document.getElementById('data'))

// Or load the table from a CSV
const csv = `
a,b,c
1,1,1
2,2,2
3,3,3
`;

const table = Table.load(CsvLoader, csv)

Dependency Injection Usage

@Injectable()
class A {
  getNumber() { return 1 }
}

@Injectable()
class B {
  constructor(public a: A) {

  }
}

const service = Injector.resolve<B>(B)

Event and Event Hub Usage

// Define the custom event
class TestEvent extends BaseEvent {
  name = 'Test'
}

// Create a new instance of the event
const ev = new TestEvent()

// Listen to the event
GlobalEventHub.register(TestEvent, (e) => console.log(e))

// Dispatch the event
ev.dispatch()

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published