WeChat applet development practice - using UUID, Base64, Chance, etc.

WeChat applet development practice - using UUID, Base64, Chance, etc.

[[173391]]

UUID

The node-uuid module can quickly generate UUIDs that comply with RFC4122 version 1 or version 4.

  1. var uuid = require( '../../libs/node-uuid/uuid.modified.js' );
  2.  
  3. // v1 generates uuid based on timestamp
  4.  
  5. console.log(uuid.v1());
  6.  
  7. // v4 is a randomly generated uuid
  8.  
  9. console.log(uuid.v4());

Base64

js-base64 is a JavaScript implementation of Base64.

  1. var Base64 = require( '../../libs/js-base64/base64.modified.js' );
  2.  
  3. console.log(Base64.encode( 'Wechat' ));
  4.  
  5. console.log(Base64.encode( '微信' ));
  6.  
  7. console.log(Base64.decode( 'V2VjaGF0' ));
  8.  
  9. console.log(Base64.decode( '5b6u5L+h' ));

Chance

Chance is a JavaScript-based random number tool class. It can generate random numbers, names, addresses, domain names, email addresses, times, etc. Almost any form of content used in the website can be generated. This random number tool can help reduce the monotonous work of writing test data, especially when writing automated tests.

  1. var Chance = require( '../../libs/chance/chance.modified.js' );
  2.  
  3. var chance = new Chance();
  4.  
  5. console.log(chance.string());
  6.  
  7. console.log( chance.integer ());
  8.  
  9. console.log(chance.bool());
  10.  
  11. console.log(chance.phone());
  12.  
  13. console.log(chance.zip());
  14.  
  15. console.log(chance.guid());

other

Complete code https://github.com/guyoung/Gy...

<<:  Apple is actively fixing iOS 10 security backup vulnerability

>>:  The road to breakthrough in the post-APP era: Alibaba Technology's "three major containers and five major solutions" are unveiled, and Baichuan's openness is fully upgraded

Recommend

It turns out that the Double Eleven copywriting can be written like this

In addition to promotions, how else can you write...

Magneti Marelli to be at CES 2024: Discover a journey of design-led innovation

Co-create with Magneti Marelli to personalize you...

For full-stack operations, this article is enough!

What is Full Stack The concept of full stack orig...

One article is enough for the year-end marketing plan of wine promotion

How to promote alcoholic products? An article wil...

Erhu beginner tutorial video, Erhu beginner tutorial video!

Learn the basics of Erhu The beauty of erhu timbr...

Here is everything you want to know about ranking manipulation!

APP ranking terms Ranking manipulation: refers to...

Is new media operation easy to do? 4 Dimensions of Analysis

Taking a different approach, let everyone use fou...

Where do new growth opportunities come from for information flow advertising?

Native advertising, brand-effect integration, inf...

How to do fan marketing? Five methodologies for fan marketing!

% ignore_pre_1 % Luo Yonghao is the first generati...

【Clown Tutorial】The Road to Redshift Cultivation

[Clown Tutorial] Redshift Cultivation Path Resour...

For the first time, scientists mentioned RNA from extinct animals!

Abstract: It is of great significance to the resu...

Analysis of Tik Tok’s refined operation and promotion techniques!

The author of this article analyzes Douyin’s pers...