
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
randomthing-js
Advanced tools
cdn 安装
<!-- jsdelivr cdn -->
<script src="https://cdn.jsdelivr.net/npm/randomthing-js@latest/dist/randomthing.min.js"></script>
<!-- unpkg cdn -->
<script src="https://unpkg.com/randomthing-js@latest/dist/randomthing.min.js"></script>
<script>
const en = RT.en( 10 );
console.log( en );
</script>
node 安装
// 安装
npm i randomthing-js -S
// 引入
const RT = require( "randomthing-js" );
// 使用
const en = RT.en( 10 );
console.log( en );
RT.number();
RT.en();
RT.EN();
RT.En();
RT.number_en();
RT.number_EN();
RT.number_En();
RT.cn();
RT.number_cn();
RT.en_cn();
RT.EN_cn();
RT.En_cn();
RT.number_en_cn();
RT.number_EN_cn();
RT.number_En_cn();
RT.specialChars();
RT.chars();
RT.custom();
RT.uuid();
RT.repeat();
RT.id();
RT.boolean();
RT.ip();
RT.email();
RT.date();
RT.time();
RT.dateTime();
RT.hex();
RT.rgb();
RT.rgba();
RT.url();
RT.image();
RT.array();
RT.extend();
RT.number()RT.number();
RT.number( length )RT.number( [ minLength, maxLength ] )length, minLength, maxLength 有效范围 1 - 16minLength 必须小于 maxLengthRT.number( 5 );
RT.number( [ 5, 10 ] );
RT.number( min, max )min 必须小于 max(生成的随机数包含 min 和 max 这两个边界值)RT.number( 10, 50 );
RT.en( length )RT.en( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.en( 10 );
RT.en( [ 10, 20 ] );
RT.EN( length )RT.EN( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.EN( 10 );
RT.EN( [ 10, 20 ] );
length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.En( 10 );
RT.En( [ 10, 20 ] );
RT.number_en( length )RT.number_en( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.number_en( 10 );
RT.number_en( [ 10, 20 ] );
RT.number_EN( length )RT.number_EN( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.number_EN( 10 );
RT.number_EN( [ 10, 20 ] );
RT.number_En( length )RT.number_En( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.number_En( 10 );
RT.number_En( [ 10, 20 ] );
RT.cn( length )RT.cn( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.cn( 10 );
RT.cn( [ 10, 20 ] );
RT.number_cn( length )RT.number_cn( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.number_cn( 10 );
RT.number_cn( [ 10, 20 ] );
RT.en_cn( length )RT.en_cn( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.en_cn( 10 );
RT.en_cn( [ 10, 20 ] );
RT.EN_cn( length )RT.EN_cn( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.EN_cn( 10 );
RT.EN_cn( [ 10, 20 ] );
RT.En_cn( length )RT.En_cn( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.En_cn( 10 );
RT.En_cn( [ 10, 20 ] );
RT.number_en_cn( length )RT.number_en_cn( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.number_en_cn( 10 );
RT.number_en_cn( [ 10, 20 ] );
RT.number_EN_cn( length )RT.number_EN_cn( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.number_EN_cn( 10 );
RT.number_EN_cn( [ 10, 20 ] );
RT.number_En_cn( length )RT.number_En_cn( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.number_En_cn( 10 );
RT.number_En_cn( [ 10, 20 ] );
RT.specialChars( length )RT.specialChars( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.specialChars( 10 );
RT.specialChars( [ 10, 20 ] );
RT.chars( length )RT.chars( [ minLength, maxlength ] )length, minLength, maxLength 有效范围 1 - 9007199254740991minLength 必须小于 maxLengthRT.chars( 10 );
RT.chars( [ 10, 20 ] );
RT.custom( opt )opt.chars 自定义的字符集合opt.count 长度RT.custom({
chars: "abcd1234",
count: 5
});
RT.custom({
chars: "abcd1234",
count: [ 5, 10 ]
});
RT.uuid( opt )opt.withoutLine 去掉横线opt.uppercase 转换成大写形式RT.uuid();
RT.uuid({
withoutLine: true,
uppercase: true
});
RT.repeat( opt )opt.chars 自定义的字符opt.count 重复次数RT.repeat({
chars: "abc",
count: 3
});
RT.repeat({
chars: "abc",
count: [ 3, 6 ]
});
RT.id( opt )opt.prefix 前缀opt.suffix 后缀RT.id();
RT.id({
prefix: "aa-",
suffix: "-kk"
});
RT.boolean()RT.boolean();
RT.ip()RT.ip();
RT.email()RT.email();
RT.date( opt )opt.minYear 最小年份(默认:1970)opt.maxYear 最大年份(默认:当前年份)opt.addZero 月份和天数为单数时自动在前面补零(默认:true)opt.format 格式化模式(默认:YYYY-MM-DD)RT.date();
RT.date({
minYear: 1900,
maxYear: 2200,
format: "YYYY/MM/DD"
});
RT.time( opt )opt.minHour 最小小时(默认:0)opt.maxHour 最大小时(默认:23)opt.addZero 时分秒为单数时自动在前面补零(默认:true)opt.format 格式化模式(默认:hh:mm:ss)RT.time();
RT.time({
format: "hh时mm分ss秒"
});
RT.dateTime( opt )opt.minYear 最小年份(默认:1970)opt.maxYear 最大年份(默认:当前年份)opt.minHour 最小小时(默认:0)opt.maxHour 最大小时(默认:23)opt.addZero 月日时分秒为单数时自动在前面补零(默认:true)opt.format 格式化模式(默认:YYYY-MM-DD hh:mm:ss)RT.dateTime();
RT.dateTime({
minYear: 1900,
maxYear: 2200,
minHour:5,
maxHour:10,
format: "YYYY年MM月DD日 hh时mm分ss秒"
});
RT.hex()RT.hex();
RT.rgb()RT.rgb();
RT.rgba()RT.rgba();
RT.url( opt )opt.useHttps 使用 https 协议(默认:false)opt.showProtocol 显示协议(默认:true)opt.showWWW 显示 www(默认:true)opt.domainSuffix 域名后缀集合,多个后缀以逗号分隔(默认:com, cn, com.cn, net, net.cn, org, org.cn, info, cc, edu)RT.url();
RT.url({
showProtocol: false,
domainSuffix: "com, com.cn, cn, net"
});
RT.image( opt )opt.color 图片颜色(默认:#000)RT.image({
color: "#09f"
});
RT.array( length, function )length 数据条数function 返回内容的函数RT.array(10, function () {
return {
num: RT.number( 5 ),
id: RT.uuid()
}
})
RT.extend() 方法可以让开发者根据实际需要自定义返回的内容,从而应对千变万化的需求。RT.extend( obj )obj 是一个纯对象,用来设置自定义的功能集合obj 对象中的键值(即:自定义方法)不能与内置方法同名,否则无效。// 无效扩展,因为 RandomThing 已经内置了 RT.number() 方法
RT.extend({
number () {
return 0;
}
})
// 正确的扩展
RT.extend({
mine () {
return "自定义扩展方法";
}
})
console.log( RT.mine() );
FAQs
We found that randomthing-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.