UNPKG

ls-json

Version:
50 lines 1.75 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.parse = parse; exports.parseStreaming = parseStreaming; const parsers_1 = require("./parsers"); // Export all types - these are the public API __exportStar(require("./types"), exports); // Implementation function parse(data, options) { const opts = options || {}; if (opts.recursive) { return parsers_1.LsRecursiveParser.parse(data, opts); } else { return parsers_1.LsParser.parse(data, opts); } } /** * Parse ls output in streaming mode * * @param lines - Iterable of ls output lines * @param options - Parse options (same as parse function, but recursive mode not supported) * @returns Generator that yields LsStreamEntry objects * * @example * ```typescript * const lines = lsOutput.split('\n'); * for (const entry of parseStreaming(lines)) { * console.log(entry.filename); * } * ``` */ function parseStreaming(lines, options) { return parsers_1.LsStreamingParser.parse(lines, options); } //# sourceMappingURL=index.js.map