📜 ⬆️ ⬇️

TOM.js is a special library for special cases.

Greetings to all.
I do not know how correctly I described this library in the title, but I want to tell you about it.



What is it?


The library TOM.js makes it possible to facilitate such tasks as:

Why is it if there are analogues?


I am well aware of the fact that there are all sorts of RequireJS , klass.js, and so on, but this library is a development for several years for specific tasks in the project I'm working on.
')
For example, I never met the function call interception functionality, but we needed this functionality in the project for developing extensions for all occasions, and later for other tasks. And there already is the creation of classes with the necessary set of parameters and functions, and, of course, the file loader created taking into account the specifics of our project.

TOM.boot - loading modules and scripts with dependencies


Initially it was a small library, which in 4 years was rewritten several times already due to unpleasant dependency bugs. The last time was an attempt to implement a load using RequireJS , with a small "add-in", but in the end this "add-in" turned out to be so twisted (and also RequireJS had dependencies on its own concepts), which turned out to be easier to implement its bootloader, but without allowing any errors were in past implementations.

What can this part of the library?



TOM.processor - interception of functions performed within the application


In fact, the interception of functions will take place only where you need it, only in those objects that you “proxy”.
In our project, for example, there are 3 objects that are registered in the window and with which we work, these are our so-called “scopes”: api , core , interface and we work with them, therefore we only proxify them.

TOM.js by default creates the core and interface , but working with them or not is a private matter for everyone.

How to work with it?




TOM.classes - creating and inheriting classes


This part of the library beats the standard approach to creating and inheriting classes in standard JavaScript , but with a large number of nuances and developments.



Demo page: tredsnet.imtqy.com/TOM
GitHub repository: github.com/tredsnet/TOM

The library, of course, is not very prepared for publication, the code is not “cleaned out”, unnecessary comments and notes are not removed, non-standard behavior is possible somewhere (as it was tested only on our project) . But everything has its time, perhaps in this form the library will be useful to someone, and in the case of the interest of users, development is also possible in the right direction.

Thank you for reading to the end. I would welcome any comments, but please do not forget that the library was created for specific needs, a specific project.

Source: https://habr.com/ru/post/278033/


All Articles