DEV Community

Mr Smithnen
Mr Smithnen

Posted on

YINI CLI v1.0.2-beta โ€” Smarter Number Parsing ๐Ÿš€

Just rolled out YINI v1.0.2-beta, and this one focuses on making the parser more capable and rock-solid when it comes to handling numbers.

๐Ÿ”ง What's New

The internal YINI Parser has been upgraded to v1.0.2-beta, bringing full support for:

  • Negative values
  • Edge cases across all number types:

    - Integers
    - Floats
    - Hexadecimal
    - Binary
    - Octal
    - Duodecimal (base-12)
    - Exponential notation
    

๐Ÿ’ก Why It Matters

If you're working with configs that push the limitsโ€”maybe big integer IDs, scientific values, or alternative base notationsโ€”this update ensures they'll parse correctly, consistently, and without surprises.

Usage

Installation

  1. Install it globally from npm

    Open your terminal and run:

    npm install -g yini-cli
    
  2. Test functionality

    Create a simple test file, for example: config.yini:

    ^ App
      name = 'My App Title'
      version = '1.2.3'
      pageSize = 25
      darkTheme = off
    

    Then run:

    yini parse config.yini
    

    Expected result, your CLI should output a parsed version of the config and output something similar to:

    {
        App: {
            name: 'My App Title',
            version: '1.2.3',
            pageSize: 25,
            darkTheme: false
        }
    }    
    

All Supported Number Format

In YINI config format below:

        @yini

        ^ App
          name = 'My App Title'
          version = "1.2.3"
          pageSize = 25
          darkTheme = off

        ^ NumberFormats

          ^^ HexFormat              // Hexadecimal (base-16)
             hex    = #FF0066       // Default notation
             altHex = 0xFF0066      // Alternative notation
          ^^ BinFormat              // Binary (base-2)
             bin    = %10101111     // Default notation
             altBin = 0b10101111    // Alternative notation
          ^^ OctFormat              // Octal (base-8)
             oct    = 0o755         // (decimal 493)
          ^^ DozFormat              // Duodecimal (base-12)
             doz    = 0z10XE        // Default notation:     X=10, E=11
             altDoz = 0z10AB        // Alternative notation: A=10, B=11
Enter fullscreen mode Exit fullscreen mode

Will produce following JS object:

{
  App: {
    name: 'My App Title',
    version: '1.2.3',
    pageSize: 25,
    darkTheme: false
  },
  NumberFormats: {
    HexFormat: { 
      hex: 16711782,
      altHex: 16711782
    },
    BinFormat: { 
      bin: 175, 
      altBin: 175
    },
    OctFormat: { 
      oct: 493 
    },
    DozFormat: { 
      doz: 1859, 
      altDoz: 1859
    }
  }
}    
Enter fullscreen mode Exit fullscreen mode

Links

Top comments (0)