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

@woodenfish/random-data

v0.0.5

Published

随机数据产生姬

Downloads

8

Readme

这是一个字符串拼接工具,可以用于OJ的测试数据生成, 点我在线体验

cli 工具用法见 cli使用指北

语法

现在只支持两种语句

constraint 约束 限制变量取值

repeat 重复 会输出内容

重要 每一个变量都需要有约束

constraint 的语法

int类型

constraint 变量名 int 最小值 最大值

比如

constraint n int 1 233

变量名 最好都是字母(汉字也行)

最小值和最大值可以是别的变量名

区间是左闭右开

set类型

constraint 变量名 set value1 value2 value3

比如

constraint 数字 set 一 二 三 四

value之间使用空格分隔

repeat 的语法

line类型

repeat 重复次数 重复的内容

重复次数 可以是一个数字,也可以是一个变量

从紧跟 重复次数 的空格后面开始,到这一行结束都会被视为一个模板,我们使用 ${变量名} 来引用一个变量

比如

repeat 1 ${n}

亦或者

repeat 1 prefix string ${n}

都是被允许的

group类型

repeat group 重复次数
repeat line
repeat line
repeat line
end group

重复次数 可以是一个数字,也可以是一个变量

案例

普通案例

举个例子,假如我们的数据是

第一行输入一个n,代表接下来有n行数据,每行数据有三个数a b c

那么就是

repeat 1 ${n}
repeat n ${a} ${b} ${c}

然后补充一下约束就好了

再举一个例子

假如我们的数据是这个样子的

第一行是n,代表接下来有n组数据

每组数据的第一行有三个数row min max,代表接下来有row个数字,每个数字的取值是 [min, max)

那我们可以这样写

constraint n int 5 10
constraint row int 10 20
constraint min int 150 200
constraint max int 500 1000
constraint num int min max
repeat 1 ${n}
repeat group n
repeat 1 ${row} ${min} ${max}
repeat row ${num}
end group

来一个set的例子

constraint 姓 set 赵 钱 孙 李
constraint 名 set 一 二 三 四
repeat 10 ${姓}${名}

当然,本质是个字符串拼接,也可以写别的东西

sql测试数据

constraint 姓 set 赵 钱 孙 李
constraint 名 set 一 二 三 四
constraint value int 10 1000
constraint status int 0 2
repeat 10 INSERT INTO list (name, value, status) VALUES ("${姓}${名}", ${value}, ${status});

程序没有检查输入是否合法,所以需要你自己注意一下 :)

高级用法

图、flags 这些的使用,参见 高级用法

更新日志

参见 更新日志

更新计划

不存在的

其他

这个轮子的目的是设计一个足够简单的工具来生成数据,这也就意味着她不能支持所有的场景,也不能对数据做高度定制。

如果有这种需求的话,应该自己写代码,或者使用类似 CYaRon 的工具。