Light ECMAScript Value Notation (LEVN)

0.4.1 · abandoned · verified Sun Apr 19

Levn is a JavaScript library for parsing human-readable string input into structured JavaScript values, leveraging type validation. It is designed for concise, human-authored data, such as configuration files or command-line arguments, distinguishing itself from JSON by prioritizing human readability, conciseness, and built-in type validation via `type-check`. It supports regex and date literals and is extensible with custom types. Unlike JSON, it is not optimized for large-scale data transport due to its parsing overhead. The current stable version is 0.4.1. This package appears to be largely unmaintained, with its last npm publish over six years ago and minimal activity on its GitHub repository in recent years.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates basic `parse` usage for various types (Number, String, Boolean, Array, Object) and the `parsedTypeParse` function with a pre-parsed type from `type-check`.

const { parse } = require('levn');
const { parseType } = require('type-check'); // Assuming 'type-check' is installed

// Basic type parsing
console.log('Number 2:', parse('Number', '2'));
console.log('String "levn":', parse('String', 'levn'));
console.log('Boolean true:', parse('Boolean', 'true'));

// Complex types and implicit delimiters
console.log('Array of Numbers:', parse('[Number]', '1,2,3'));
console.log('Object with properties:', parse('{a: String, b: Number}', 'a: str, b: 2'));

// Parsing with pre-parsed types (from type-check)
const parsedNumberArrayType = parseType('[Number]');
console.log('Parsed Type Array:', parse('parsedTypeParse', parsedNumberArrayType, '4,5,6'));

view raw JSON →