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

@freelog/freelog-cg-collection

v1.0.9

Published

输入文件:

Downloads

566

Readme

组合结构文档

输入文件:

for public

c1 // 广告已授权
c2 = this.all.range(0,9) // 免费
c3 = this.all.range(10,19) // 广告
c4 = this.all.exclude(c2).exclude(c3) // 付费
c5 // 付费已授权
c6 = c1.unionSet(c5) // 已授权

s1[c2,c6]:
	case in c3 ~freelog.e1() => s2 do c1.set(context.id);c1.unset(context.id);c1.set(context.id); // 看完广告
s2[c2,c6]:
	case in c4 ~freelog.e2() => s2 do c5.set(context.id); // 付费
	/*
	 * 定期清理付费的单品,假设付费的单品是有时间期限的
	 * 定期清理广告的单品,假设广告的单品是有时间期限的
	 */
    ~freelog.CycleEndEvent("4","cycle") => s2 do c1.clean();c5.clean();
    ~freelog.e4() => s3 // 合约终止
s3:
	terminate

输出文件:

{
    "audiences": [
        {
            "name": "public",
            "type": "public"
        }
    ],
    "serviceStates": [
        {
            "name": "c1"
        },
        {
            "name": "c2",
            "caller": {
                "name": "this.all",
                "type": "variable"
            },
            "functions": [
                {
                    "functionName": "range",
                    "functionArgs": {
                        "index": "0",
                        "limit": "9"
                    }
                }
            ]
        },
        {
            "name": "c3",
            "caller": {
                "name": "this.all",
                "type": "variable"
            },
            "functions": [
                {
                    "functionName": "range",
                    "functionArgs": {
                        "index": "10",
                        "limit": "19"
                    }
                }
            ]
        },
        {
            "name": "c4",
            "caller": {
                "name": "this.all",
                "type": "variable"
            },
            "functions": [
                {
                    "functionName": "exclude",
                    "functionArgs": {
                        "a": "c2"
                    }
                },
                {
                    "functionName": "exclude",
                    "functionArgs": {
                        "a": "c3"
                    }
                }
            ]
        },
        {
            "name": "c5"
        },
        {
            "name": "c6",
            "caller": {
                "name": "c1",
                "type": "serviceState"
            },
            "functions": [
                {
                    "functionName": "unionSet",
                    "functionArgs": {
                        "a": "c5"
                    }
                }
            ]
        }
    ],
    "stateMachine": {
        "s1": {
            "serviceStates": [
                "c2",
                "c6"
            ],
            "transitions": [
                {
                    "toState": "s2",
                    "service": "freelog",
                    "name": "e1",
                    "condition": {
                        "type": "case",
                        "serviceState": "c3"
                    },
                    "actions": [
                        {
                            "caller": {
                                "name": "c1",
                                "type": "serviceState"
                            },
                            "functions": [
                                {
                                    "functionName": "set",
                                    "functionArgs": {
                                        "a": "context.id"
                                    }
                                }
                            ]
                        },
                        {
                            "caller": {
                                "name": "c1",
                                "type": "serviceState"
                            },
                            "functions": [
                                {
                                    "functionName": "unset",
                                    "functionArgs": {
                                        "a": "context.id"
                                    }
                                }
                            ]
                        },
                        {
                            "caller": {
                                "name": "c1",
                                "type": "serviceState"
                            },
                            "functions": [
                                {
                                    "functionName": "set",
                                    "functionArgs": {
                                        "a": "context.id"
                                    }
                                }
                            ]
                        }
                    ]
                }
            ]
        },
        "s2": {
            "serviceStates": [
                "c2",
                "c6"
            ],
            "transitions": [
                {
                    "toState": "s2",
                    "service": "freelog",
                    "name": "e2",
                    "condition": {
                        "type": "case",
                        "serviceState": "c4"
                    },
                    "actions": [
                        {
                            "caller": {
                                "name": "c5",
                                "type": "serviceState"
                            },
                            "functions": [
                                {
                                    "functionName": "set",
                                    "functionArgs": {
                                        "a": "context.id"
                                    }
                                }
                            ]
                        }
                    ]
                },
                {
                    "toState": "s2",
                    "service": "freelog",
                    "name": "CycleEndEvent",
                    "args": {
                        "cycleCount": 4,
                        "timeUnit": "cycle"
                    },
                    "actions": [
                        {
                            "caller": {
                                "name": "c1",
                                "type": "serviceState"
                            },
                            "functions": [
                                {
                                    "functionName": "clean",
                                    "functionArgs": []
                                }
                            ]
                        },
                        {
                            "caller": {
                                "name": "c5",
                                "type": "serviceState"
                            },
                            "functions": [
                                {
                                    "functionName": "clean",
                                    "functionArgs": []
                                }
                            ]
                        }
                    ],
                    "code": "A101",
                    "description": "raise when n cycle ends",
                    "isSingleton": false
                },
                {
                    "toState": "s3",
                    "service": "freelog",
                    "name": "e4"
                }
            ]
        },
        "s3": {
            "serviceStates": [],
            "transitions": [
                {
                    "name": "terminate"
                }
            ]
        }
    },
    "info": {
        "environmentVariables": [
            "this.all",
            "context.id"
        ]
    },
    "warnings": [
        "该事件未定义:{\"toState\":\"s2\",\"service\":\"freelog\",\"name\":\"e1\",\"condition\":{\"type\":\"case\",\"serviceState\":\"c3\"},\"actions\":[{\"caller\":{\"name\":\"c1\",\"type\":\"serviceState\"},\"functions\":[{\"functionName\":\"set\",\"functionArgs\":[\"context.id\"]}]},{\"caller\":{\"name\":\"c1\",\"type\":\"serviceState\"},\"functions\":[{\"functionName\":\"unset\",\"functionArgs\":[\"context.id\"]}]},{\"caller\":{\"name\":\"c1\",\"type\":\"serviceState\"},\"functions\":[{\"functionName\":\"set\",\"functionArgs\":[\"context.id\"]}]}]}",
        "该事件未定义:{\"toState\":\"s2\",\"service\":\"freelog\",\"name\":\"e2\",\"condition\":{\"type\":\"case\",\"serviceState\":\"c4\"},\"actions\":[{\"caller\":{\"name\":\"c5\",\"type\":\"serviceState\"},\"functions\":[{\"functionName\":\"set\",\"functionArgs\":[\"context.id\"]}]}]}",
        "该事件未定义:{\"toState\":\"s3\",\"service\":\"freelog\",\"name\":\"e4\"}"
    ],
    "warningObjects": [
        {
            "msg": "该事件未定义:{\"toState\":\"s2\",\"service\":\"freelog\",\"name\":\"e1\",\"condition\":{\"type\":\"case\",\"serviceState\":\"c3\"},\"actions\":[{\"caller\":{\"name\":\"c1\",\"type\":\"serviceState\"},\"functions\":[{\"functionName\":\"set\",\"functionArgs\":[\"context.id\"]}]},{\"caller\":{\"name\":\"c1\",\"type\":\"serviceState\"},\"functions\":[{\"functionName\":\"unset\",\"functionArgs\":[\"context.id\"]}]},{\"caller\":{\"name\":\"c1\",\"type\":\"serviceState\"},\"functions\":[{\"functionName\":\"set\",\"functionArgs\":[\"context.id\"]}]}]}"
        },
        {
            "msg": "该事件未定义:{\"toState\":\"s2\",\"service\":\"freelog\",\"name\":\"e2\",\"condition\":{\"type\":\"case\",\"serviceState\":\"c4\"},\"actions\":[{\"caller\":{\"name\":\"c5\",\"type\":\"serviceState\"},\"functions\":[{\"functionName\":\"set\",\"functionArgs\":[\"context.id\"]}]}]}"
        },
        {
            "msg": "该事件未定义:{\"toState\":\"s3\",\"service\":\"freelog\",\"name\":\"e4\"}"
        }
    ],
    "errors": [],
    "errorObjects": []
}

结构说明:

export interface Result {
    // 目标用户
    audiences: Audience[];
    // 色块声明
    serviceStates: ServiceState[];
    // 状态机
    stateMachine: StateMachine;
    // 信息
    info: Info;
}

// 目标用户
export interface Audience {
    // 名称
    name: string;
    // 类型
    type: string;
}

// 色块声明
export interface ServiceState {
    // 色块名
    name: string;
    // 色块赋值调用者
    caller?: Caller;
    // 函数集合,链式调用
    functions?: Function[];
}

// 调用者
export interface Caller {
    // 名称
    name: string;
    // 类型 variable:变量 | serviceState:色块
    type: string;
}

// 函数
export interface Function {
    // 函数名
    functionName: string;
    // 函数参数
    functionArgs: { name: "value" };
}

// 状态机
export interface StateMachine {
    // 状态名
    state: {
        // 色块集合
        serviceStates: string[];
        // 事件转换集合
        transitions: Transition[];
    }
}

// 事件转换
export interface Transition {
    // 条件
    condition?: Condition;
    // 事件名
    name: string;
    // 事件服务
    service: string;
    // 事件路径
    path?: string;
    // 转换目标状态
    toState: string;
    // 事件参数
    args: {
        // 参数名,参数值
        argName: string;
    };
    // 事件代码
    code: string;
    // 事件描述
    description: string;
    // 是否是单例
    isSingleton: boolean;
    // 动作
    actions?: Action[];
}

// 条件
export interface Condition {
    // 类型 case
    type: string;
    // 色块 当类型是case时,有该属性
    serviceState?: string;
}

// 动作
export interface Action {
    // 调用者
    caller?: Caller;
    // 函数集合
    functions: Function[];
}

// 信息
export interface Info {
    // 组合策略中使用到的环境变量
    environmentVariables: string[];
}