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

flkit

v3.1.2

Published

A front-language(HTML,CSS,JS) toolkit that support tempate syntax(Smarty,PHP,ejs,jade)

Downloads

40

Readme

flkit

A JS/HTML/CSS Toolkit(Tokenizer、Parser) Support Template Syntax.

Install

npm install flkit;

Methods

getHtmlAttrValue(attrs, name)

  • attrs {Array} 属性列表
  • name {String} 属性名

获取属性值,如:

import {getHtmlAttrValue} from 'flkit';
let attrs = token.ext.attrs;
let value = getHtmlAttrValue(attrs, 'src'); //获取属性 src 的值

setHtmlAttrValue(attrs, name, value)

  • attrs {Array} 属性列表
  • name {String} 属性名
  • value {String} 属性值

设置属性值,如果没有这个属性,则添加这个属性。如:

import {setHtmlAttrValue} from 'flkit';
let attrs = token.ext.attrs;
attrs = setHtmlAttrValue(attrs, 'src', 'http://flkit.org');

createToken(type, value, referToken)

  • type {TokenType} Token 类型
  • value {String} Token 值
  • referToken {Token} 相关的 Token,主要是提取 Token 的位置

创建一个 Token,如:

import {createToken} from 'flkit';
let token = createToke(TokenType.HTML_TAG_START, '<div name="flkit">');

createRawToken(type, value, referToken)

  • type {style | script} Token 类型
  • value {String | Array} Token 值
  • referToken {Token} 相关的 Token,主要是提取 Token 的位置

创建一个 Script 或者 Style Token,如:

import {createRawToken} from 'flkit';

createRawToken('script', 'var a = 1;');
createRawToken('style', 'a{color: red}');

createRawToken('style', [
  ...tokenList
])

TokenType

import {TokenType} from 'flkit';

包含的 TokenType 如下:

{
  EOS: 'eos',
  TPL: 'tpl',
  RESERVED_COMMENT: 'reserverd_comment',
  IE_HACK: 'ie_hack',
  
  XML_START: 'xml_start',
 
  HTML_TAG_START: 'html_tag_start',
  HTML_TAG_END: 'html_tag_end',
  HTML_TAG_TEXTAREA: 'html_tag_textarea',
  HTML_TAG_SCRIPT: 'html_tag_script',
  HTML_TAG_STYLE: 'html_tag_style',
  HTML_TAG_PRE: 'html_tag_pre',
  HTML_RAW_TEXT: 'html_raw_text',
  HTML_DOCTYPE: 'html_doctype',
  HTML_TEXT: 'html_text',
  HTML_CDATA: 'html_cdata',
  
  CSS_SELECTOR: 'css_selector',
  CSS_PROPERTY: 'css_property',
  CSS_VALUE: 'css_value',
  CSS_KEYFRAMES: 'css_keyframes',
  CSS_LEFT_BRACE: 'css_left_brace',
  CSS_RIGHT_BRACE: 'css_right_brace',
  CSS_SEMICOLON: 'css_semicolon',
  CSS_COLON: 'css_colon',
  CSS_MEDIA: 'css_media',
  CSS_NAMESPACE: 'css_namespace',
  CSS_IMPORT: 'css_import',
  CSS_CHARSET: 'css_charset',
  CSS_FONT_FACE: 'css_font_face',
  CSS_PAGE: 'css_page',
  CSS_AT: 'css_at',
  CSS_BRACK_HACK: 'css_brace_hack', // [;color: red;]
  CSS_VIEWPORT: 'css_viewport',
  CSS_MOZILLA: 'css_mozilla',

  CSS_SELECTOR_NAMESPACE: 'css_selector_namespace',
  CSS_SELECTOR_UNIVERSAL: 'css_selector_universal',
  CSS_SELECTOR_ATTRIBUTE: 'css_selector_attribute',
  CSS_SELECTOR_CLASS: 'css_selector_class',
  CSS_SELECTOR_ID: 'css_selector_id',
  CSS_SELECTOR_PSEUDO_CLASS: 'css_selector_pseudo_class',
  CSS_SELECTOR_PSEUDO_ELEMENT: 'css_selector_pseudo_element',
  CSS_SELECTOR_COMBINATOR: 'css_selector_combinator',
  CSS_SELECTOR_TYPE: 'css_selector_type',
  CSS_SELECTOR_COMMA: 'css_selector_comma'
}