{"id":14665,"library":"levn","title":"Light ECMAScript Value Notation (LEVN)","description":"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.","status":"abandoned","version":"0.4.1","language":"javascript","source_language":"en","source_url":"git://github.com/gkz/levn","tags":["javascript","levn","light","ecmascript","value","notation","json","typed","human"],"install":[{"cmd":"npm install levn","lang":"bash","label":"npm"},{"cmd":"yarn add levn","lang":"bash","label":"yarn"},{"cmd":"pnpm add levn","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for its type format and to validate parsed values.","package":"type-check","optional":false},{"reason":"A utility library, likely for functional programming constructs, though not directly exposed in the main API.","package":"prelude-ls","optional":false}],"imports":[{"note":"Levn is a CommonJS module, primarily designed for Node.js environments with `require`. Direct ESM `import` is not supported.","wrong":"import { parse } from 'levn';","symbol":"parse","correct":"const { parse } = require('levn');"},{"note":"`parsedTypeParse` requires a pre-parsed type object, typically obtained from the `type-check` library. It's a named export from the main `levn` module.","wrong":"import parsedTypeParse from 'levn/parsedTypeParse';","symbol":"parsedTypeParse","correct":"const { parsedTypeParse } = require('levn');"},{"note":"The `VERSION` string is a direct named export, not a property off the default export.","wrong":"const VERSION = require('levn').VERSION;","symbol":"VERSION","correct":"const { VERSION } = require('levn');"}],"quickstart":{"code":"const { parse } = require('levn');\nconst { parseType } = require('type-check'); // Assuming 'type-check' is installed\n\n// Basic type parsing\nconsole.log('Number 2:', parse('Number', '2'));\nconsole.log('String \"levn\":', parse('String', 'levn'));\nconsole.log('Boolean true:', parse('Boolean', 'true'));\n\n// Complex types and implicit delimiters\nconsole.log('Array of Numbers:', parse('[Number]', '1,2,3'));\nconsole.log('Object with properties:', parse('{a: String, b: Number}', 'a: str, b: 2'));\n\n// Parsing with pre-parsed types (from type-check)\nconst parsedNumberArrayType = parseType('[Number]');\nconsole.log('Parsed Type Array:', parse('parsedTypeParse', parsedNumberArrayType, '4,5,6'));","lang":"javascript","description":"Demonstrates basic `parse` usage for various types (Number, String, Boolean, Array, Object) and the `parsedTypeParse` function with a pre-parsed type from `type-check`."},"warnings":[{"fix":"Consider modern alternatives like `yaml`, `toml`, or robust JSON parsers. If `levn` is critical, fork the project, update dependencies, and address any Node.js compatibility issues.","message":"Levn is an abandoned package. Its last major update was in 2013-2014, and the last npm publish was six years ago. It relies on very old Node.js versions (>=0.8.0). Use in modern environments without careful consideration and potential polyfills is not recommended and may lead to compatibility issues or security vulnerabilities through its dependencies.","severity":"breaking","affected_versions":"All versions"},{"fix":"Always use `require()` for importing `levn` and its functions: `const { parse } = require('levn');`.","message":"Levn is a CommonJS-only module. Attempting to use `import` statements (ESM syntax) will result in runtime errors in Node.js environments unless transpiled or configured correctly with a CommonJS wrapper.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Do not use `levn` for performance-critical data serialization/deserialization involving large payloads. Stick to its intended use case for small, human-editable configuration or command-line inputs.","message":"The library explicitly states it is slower and less efficient than JSON for transporting large amounts of data. Its purpose is for human-entered, concise data, not machine-to-machine communication.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with the `type-check` library's documentation, especially its type format, before attempting advanced parsing with `levn`.","message":"Levn's parsing heavily relies on the `type-check` library for its type format and validation. Developers need to understand `type-check`'s syntax and capabilities to effectively use `levn` for complex data structures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure your project is configured for CommonJS, or use dynamic `import()` if absolutely necessary within an ESM file. `levn` is designed for CommonJS (`require`).","cause":"Attempting to use `require` in an ECMAScript Module (ESM) context without proper configuration.","error":"TypeError: require is not a function"},{"fix":"Install the peer dependency: `npm install type-check`.","cause":"`type-check`, a core dependency, is missing from `node_modules`.","error":"Error: Cannot find module 'type-check'"},{"fix":"Review the Levn format documentation and ensure the input string correctly matches the `type` string provided to the `parse` function. Pay attention to delimiters and value formats (e.g., dates with `#`, regex with `/`).","cause":"Input string does not conform to Levn's syntax rules or the specified type, or contains unrecognized literals.","error":"SyntaxError: Unexpected token '...' (or similar parsing errors)"},{"fix":"Verify that `levn` is installed (`npm list levn`) and that the `require` path is correct. Ensure no other module is inadvertently shadowing `levn`.","cause":"The `levn` module was not successfully imported, or `require('levn')` returned `undefined` or an unexpected value.","error":"TypeError: Cannot read properties of undefined (reading 'parse')"}],"ecosystem":"npm"}