Wondering what’s next for npm?Check out our public roadmap! »

    qtoml

    2.0.0 • Public • Published

    qtoml

    Use TOML to construct object literals directly in JavaScript

    Coverage Status

    const toml = require('qtoml')
     
    let obj = toml`
      [example]
      key1 = ${5 + 8}
      key2 = 17
     
      [elpmaxe]
      1yek = 31`
     
    console.log(obj) // {example: {key1: 13, key2: 17}, elpmaxe: {1yek: 31}}

    DESCRIPTION

    This module provides a tagged template string for contructing objects using TOML.

    toml`string` -> Object

    The provided string must be valid TOML or an error will be thrown. Embedded expressions are evaluted and included and can evaluate to any datatype that can be used in TOML. For example, the following is valid:

    obj = toml`a = ${new Date()}` // equivalent of {a: new Date()}

    Only values that can be represented as TOML are allowed. Trying to include other values will throw. For example, a single-type array is fine:

    let value = [1, 2, 3]
    obj = toml`a = ${value}` // {a: [1, 2, 3]}

    But a mixed-type array is not:

    let value = ['a', 'b', 1, 2]
    obj = toml`a = ${value}` // throws

    Install

    npm i qtoml

    DownloadsWeekly Downloads

    2

    Version

    2.0.0

    License

    ISC

    Unpacked Size

    4.04 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar