0.1.0 • Published 3 years ago

uid.macro v0.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
3 years ago

uid.macro

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

Installation

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

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

    import { str } from 'uid.macro';
    const value = str();
    const other = str(7);
    
    ↓ ↓ ↓ ↓ ↓ ↓
    
    const value = 'XwPp9xazJ0ku5CZnlmgAx2Dld8SHkAeT';
    const other = 'xqm5wXX';