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

tlo

v1.0.0

Published

Reader of binary serialized Type Language Schema

Downloads

8

Readme

Type Language Object

Reader of binary serialized Type Language Schema

Example of result in the end of reading TLO

Python

JavaScript/TypeScript

Declaimer

This code has not been tested sufficiently. It's a rewritten version of original reader in C++. If you are going to use this for code generation, please do additional tests. Recheck my implementation for errors and so on.

Context

The Type Language (TL) was invented many years ago. It was originally used in VK, and now in Telegram. The creators of this language invented and wrote all the necessary tools to work with it. For example, a parser of the language and its binary format for serialization was developed.

What is this for?

To work with TL Schemes using OOP. To generate the client MTProto code using official TL parsers and binary formats.

Many Open Source MTProto client use their own implementation of parsers, which are not ultimatum. They are hardcoded for their minimal task.

Hardcode is not the way of Telegram. Official Telegram's Open Source projects take the right approach. So, for example, tdlib generates several interfaces for different languages and this is how it looks:

Raw TL Schema -> Tl Parser -> binary TL Object -> TLO reader -> code generator.

| Step name | Description | | --------- | ----------- | | Raw TL Schema | Can be founded here and in official Telegram repositories of client (tdesktop/Telegram/Resources/tl, tdlib/generate/scheme). | | Tl Parser | Official TL parser written in C++. Now it's a part of tdlib/td/generate/tl-parser. In the input it takes raw TL schema file. The output is TLO file. | | binary TL Object | The output of Tl Parser. | | TLO reader | This repository contains implementation of it in Python and JavaScript. Reader of binary file. Provide access to combinators, types, functions, arguments and so on via Object Oriented Programming. | | code generator | Any code generator. In tdlib/td/generate there is generator for C++, JNI, .NET and JSON interfaces. |

Installing

For Python

pip install tlo

For JavaScript/TypeScript

npm install tlo

Usage

You can find TLO files for tests here.

Python (3.6+)

from tlo import read_tl_config_from_file, read_tl_config


# use read_tl_config(data) to pass bytes directly
config = read_tl_config_from_file('td_api.tlo')

JavaScript/TypeScript

const tlo = require('tlo');
//import {read_tl_config_from_file, read_tl_config} from 'tlo';

// use read_tl_config(data) to pass buffer directly
tlo.read_tl_config_from_file('./tlo_for_tests/telegram_api.tlo', (config) => {
    console.log(config);
});

Licence

MIT License