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

@devs-tang/devkit

v1.0.11

Published

Tang开发库

Downloads

162

Readme

tang-tang

tang 基础库

关于

tang 核心库包含 tang 体系的主要核心概念的抽象

概念

目前 tang 核心库中包含如下概念:编译器、处理器、钩子等

编译器 (compiler)

编译器是 tang 的核心概念,支持对各类资源进行加载,以及生成各类文件。如下为示例代码:

import tang from 'tang-tang';

const compile = async () => {
  // 创建编译器
  const compiler = tang({});

  // 加载文档
  const compilation = await compiler.load('http://example.com/openapi.yaml');

  // 生成文档
  const output = await compiler.generate(compilation.document);

  console.log(output.files);
};

compile();

处理器 (processor)

tang 的编译过程涉及到目标文档的加载、解析、生成以及输出,其对应了一下 4 种类型处理器:加载器(loader),解析器(parser),生成器(generator)。

所有处理器在编译器进行加载或生成过程中,按照优先级和顺序选择特定的处理器进行处理。

  1. 加载器(loader)

    加载器用于从各类资源加载文档并返回字符串。目前内核内置两类加载器:

    • fileLoader: 支持从本地文件系统或文件系统加载文件
    • urlLoader: 支持通过请求 url 地址加载文件
  2. 解析器(parser)

    解析器用于解析字符串为对象,并存储在 compilation 中的 document 对象中。目前内置两类解析器:

    • jsonParser: 支持将 json 文本解析对对象
    • yamlParser: 支持将 yaml 文本解析对对象
  3. 生成器(generator)

    生成器用于将对象生成文本并存储在 generation 对象中。目前内置两类生成器:

    • jsonGenerator: 支持将对象生成 json 文档字符串
    • yamlGenerator: 支持将对象生成 yaml 文档字符串
  4. 输出器(outputer)

    输出器用于对生成器生成的文档字符进行输出。目前内置两类输出器:

    • localOutputer: 将字符文件输出到本地文件系统。
    • memoryOutputer: 将字符文件输出到内存文件系统。

钩子 (hook)

钩子支持在编译器进行加载或生成的过程中加入额外的处理逻辑,以达到功能扩展的目的。

当前支持的 hook 触发点有:

  1. 加载时钩子

    • load: 加载文档前
    • parse: 加载文档后,解析文档前
    • loaded: 加载文档
  2. 生成时钩子

    • generate: 生成操作前
    • output: 生成操作后,输出操作前
    • generated: 输出操作后
  3. 全局钩子

    • *: 所有操作

除了 generated 钩子执行时为并行执行外,其他所有钩子方法都是顺序执行。