项目作者: jedrzejginter

项目描述 :
Insert uuid v4 or random string at build-time with babel macros.
高级语言: JavaScript
项目地址: git://github.com/jedrzejginter/uid.macro.git
创建时间: 2021-01-21T19:55:43Z
项目社区:https://github.com/jedrzejginter/uid.macro

开源协议:MIT License

下载


uid.macro

Insert uuid v4 or random string at build-time with babel macros.

Installation

  1. npm install --save-dev uid.macro

You’ll also need to install and configure babel-plugin-macros if you haven’t already.

Usage

  • uuid version 4

    1. import { uuid } from 'uid.macro';
    2. const value = uuid();
    3. const value = '44a79dfb-6805-46c7-bd79-04420e7d6bcc';
  • random string (optional length)

    1. import { str } from 'uid.macro';
    2. const value = str();
    3. const other = str(7);
    4. const value = 'XwPp9xazJ0ku5CZnlmgAx2Dld8SHkAeT';
    5. const other = 'xqm5wXX';