🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

happyrandom

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

happyrandom

超轻量级的生成随机数脚本

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

HappyRandom 生成随机数

兼容

Chrome, Firefox, Edge, Safari, IE9+

用法

<script>
    
    // 指定长度的 [ 纯英文字母 ] 随机字符串
    console.log( HRandom.en( 10 ) );

    // 指定长度的 [ 纯英文字母 ](大写形式)随机字符串
    console.log( HRandom.en( 10, true ) );
    
    // 指定长度的 [ 纯英文字母 ](小写形式)随机字符串
    console.log( HRandom.en( 10, false ) );

    // 指定长度的 [ 纯数字 ] 随机数
    console.log( HRandom.num( 10 ) );

    // 0-1 的随机数
    console.log( HRandom.num() );

    // 指定范围的随机数(包含两个边界值)
    console.log( HRandom.num( 9, 99 ) );

    // 指定长度的 [ 英文字母 + 数字 ] 随机字符串
    console.log( HRandom.enNum( 10 ) );

    // 指定长度的 [ 英文字母(大写形式) + 数字 ] 随机字符串
    console.log( HRandom.enNum( 10, true ) );

    // 指定长度的 [ 英文字母(小写形式) + 数字 ] 随机字符串
    console.log( HRandom.enNum( 10, false ) );

    // [ 自由模式 ] 根据自定义的字符集生成指定长度随机字符串
    console.log( HRandom.free( "abcd1234", 10 ) );

    // 生成 uuid
    console.log( HRandom.uuid() );

    // 生成 uuid(大写形式)
    console.log( HRandom.uuid( true ) );

    // enNum 的简写形式 ( 此例等同于 HRandom.enNum( 10 ) )
    console.log( HRandom( 10 ) );

    // enNum 的简写形式 ( 此例等同于 HRandom.enNum( 10, true ) )
    console.log( HRandom( 10, true ) );

    // enNum 的简写形式 ( 此例等同于 HRandom.enNum( 10, false ) )
    console.log( HRandom( 10, false ) );

</script>

FAQs

Package last updated on 28 Jan 2020

Did you know?

Socket

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.

Install

Related posts