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

@tars/dyeing

v2.0.1

Published

TARS 染色基础模块

Downloads

89

Readme

@tars/dyeing

TARS 染色基础模块,提供获取与判断 染色对象 的方法。

使用者:不应该直接使用此模块,而应使用其他符合 染色标准 的模块获取 染色对象

模块开发者:获取 TARS染色对象 应使用此模块的 gen() 方法获取 染色对象

染色(简介)

染色是在接口的调用链(服务端 <==> 客户端)上传递的一种状态,用于标识一次特定的请求处理过程。

这种状态由一个 标志位 与 附加信息 KEY (可选) 构成。

调用链上的服务可以设置(发起)与读取(接收)这种状态,并作对应的处理(如输出特定的日志、特性)。

在系统中,染色由此模块与其对应的约定构成。

标准(约定)

如模块使用染色体系,则需遵守如下约定(与此同时,我们将符合约定的模块称之为符合 染色标准 的模块):

  1. 提供 getDyeingObj() 方法,返回 染色对象
  2. 通过 @tars/dyeing.gen 方法,生成 染色对象
  3. 通过 @tars/dyeing.is() 方法,判断 染色对象 是否有效。

模块方法

TarsDyeing.gen(dyeing[, key, args])

通过调用此方法,可获得 染色对象

dyeing: 是否需要染色
key: 染色附加信息 KEY(可选)
args: 程序的附加参数(可选)

key 会通过调用链传递给下一个服务,而 args 仅只会在当前的染色对象中有效(并不会进行传递)。

请注意:染色对象 与 染色发起原因,这是不同的(东西)。此模块仅关心 染色对象,而不关心 染色发起原因。

TarsDyeing.is(obj)

调用此方法,可以判断 一个传入的对象是否是 染色对象

如传入空对象,方法同样会返回 false

染色对象 属性

dyeingObj.dyeing

是否需要染色,此为 Boolean

dyeingObj.key

染色传递的附加信息,此为 String 且为可选值,不一定存在

dyeingObj.args

染色对象本身的附加信息,业务代码不应将其在服务间进行传递(仅作为本地参数使用)。

此对象类型不限,同时也为可选值