From efa12e4d26b95ee256219450ce3e6ed6bab5b261 Mon Sep 17 00:00:00 2001 From: Alexander Popov Date: Sat, 9 Aug 2025 00:55:49 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B4=E2=80=8D=E2=98=A0=EF=B8=8F=20init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 20 ++++++++++++++++++++ INI.js | 40 ++++++++++++++++++++++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ README.md | 0 4 files changed, 81 insertions(+) create mode 100644 .editorconfig create mode 100644 INI.js create mode 100644 LICENSE create mode 100644 README.md 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