commit efa12e4d26b95ee256219450ce3e6ed6bab5b261 Author: Alexander Popov Date: Sat Aug 9 00:55:49 2025 +0300 🏴‍☠️ init diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..53fd855 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# EditorConfig is awesome: https://EditorConfig.org +root = true + +# for all files +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# JavaScript +[*.js] +indent_style = space +indent_size = 2 + +# Markdown +[*.md] +trim_trailing_whitespace = false diff --git a/INI.js b/INI.js new file mode 100644 index 0000000..912b953 --- /dev/null +++ b/INI.js @@ -0,0 +1,40 @@ +/** + * @module INI parser + * @description ... + * @version 1.0.0 + * @author Alexander Popov + * @license MIT + */ + +function parse(data) { + const result = {}; + const lines = data.split('\n'); + let section = null; + + lines.forEach((line) => { + line = line.trim(); + if (line.length === 0 || line[0] === ';' || line[0] === '#') return; // Пропустить пустые строки и комментарии + + const sectionMatch = line.match(/^\[(.*)\]$/); + if (sectionMatch) { + section = sectionMatch[1].trim(); + result[section] = {}; + } else { + const keyValueMatch = line.match(/^(.*?)=\s*([^#\s]+)/); + if (keyValueMatch) { + const key = keyValueMatch[1].trim(); + const value = keyValueMatch[2].trim(); + + if (section) { + result[section][key] = value; + } else { + result[key] = value; + } + } + } + }); + + return result; +} + +module.exports = { parse }; diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c11e0fe --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Alexander Popov (https://iiiypuk.me/) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29