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

@royjs/ast

v0.6.0

Published

A quick static tools for royjs

Downloads

18

Readme

Roy-Ast buildStatus

A quick static tools for royjs.

Install

npm install @royjs/ast --save

Usage

import {Store} from '@royjs/ast';
const store = new Store(code);

API

Classes

Store

解析Royjs的Store数据

Kind: global class

new Store(code)

Store的构造函数

| Param | Type | Description | | --- | --- | --- | | code | String | 传入的store的代码 |

store.parse() ⇒

解析store文件

Kind: instance method of Store Returns: 返回state,actions,urls

store.remove(name) ⇒

根据name移除某个定义的action

Kind: instance method of Store Returns: 修改后的代码

| Param | Type | Description | | --- | --- | --- | | name | String | action的名字 |

store.renameState(oldName, newName) ⇒

重命名某个state

Kind: instance method of Store Returns: 修改后的代码

| Param | Type | Description | | --- | --- | --- | | oldName | String | 旧的state的名字 | | newName | String | 新的state的名字 |

store.modifyState(name, value) ⇒

修改状态的值

Kind: instance method of Store Returns: 修改后的代码

| Param | Type | Description | | --- | --- | --- | | name | String | 状态的名称 | | value | String | 状态的值 |

store.addState(name, value)

增加状态的值

Kind: instance method of Store

| Param | Type | Description | | --- | --- | --- | | name | String | 状态的名称 | | value | String | 状态的值 |

store.modify(name, content) ⇒

根据action的名字,修改action内容

Kind: instance method of Store Returns: 修改后的代码

| Param | Type | Description | | --- | --- | --- | | name | String | action的名字 | | content | String | action的内容 |

store.rename(oldName, newName) ⇒

重命名某个action

Kind: instance method of Store Returns: 修改后的代码

| Param | Type | Description | | --- | --- | --- | | oldName | String | action的名称 | | newName | String | action的新的名称 |

store.add(name) ⇒

增加一个action, 如果存在同名action则不会添加

Kind: instance method of Store Returns: 修改后的代码

| Param | Type | Description | | --- | --- | --- | | name | String | action的名称 |

store.modifyByStartEnd(node, content) ⇒

根据位置修改内容

Kind: instance method of Store Returns: 返回修改的代码

| Param | Type | Description | | --- | --- | --- | | node | Node | 指定的节点,该节点需包含start和end两个属性 | | content | String | 替换的content |

View

解析Royjs的视图数据

Kind: global class

new View(code)

View的构造函数

| Param | Type | Description | | --- | --- | --- | | code | String | 传入的view的代码 |

view.parse() ⇒

解析视图数据

Kind: instance method of View Returns: 返回 class和elements值

view.attrs(node, name, value)

为一个节点设置属性

Kind: instance method of View

| Param | Type | | --- | --- | | node | Node | String | | name | String | | value | String |

view.removeAttr(node, name)

移除一个节点属性

Kind: instance method of View

| Param | Type | Description | | --- | --- | --- | | node | Node | String | | | name | String | 要移除的属性名称 |

view.remove(name)

根据名称移除一个节点

Kind: instance method of View

| Param | Type | | --- | --- | | name | String |

view.removeByStart(start)

根据起始位置移除一个节点

Kind: instance method of View

| Param | Type | | --- | --- | | start | String | Int |

view.cloneByStart(start)

根据起始位置复制一个节点

Kind: instance method of View

| Param | Type | | --- | --- | | start | String | Int |

view.add(node, child)

为一个节点加入子节点

Kind: instance method of View

| Param | Type | Description | | --- | --- | --- | | node | String | node | 父节点 | | child | String | 子节点的代码 |

view.rename(}, newName)

重命名一个节点,如果寻找到多个节点,只会重命名第一个

Kind: instance method of View

| Param | Type | Description | | --- | --- | --- | | } | String | oldName | | newName | String | |

view.find(}) ⇒ Array

根据name寻找节点

Kind: instance method of View

| Param | Type | Description | | --- | --- | --- | | } | String | name |

view.findByStart(start, isPath)

根据起始位置寻找节点,如果第二个参数为true,则返回节点的路径

Kind: instance method of View

| Param | Type | | --- | --- | | start | String | Int | | isPath | Boolean |

view.findBy(callback, isPath)

根据callback过滤节点,如果第二个参数为true,则返回节点的路径

Kind: instance method of View

| Param | Type | | --- | --- | | callback | function | | isPath | Boolean |