Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse-ini-string

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-ini-string - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

build/es/src/__tests__/indexTest.mjs

36

build/cjs/src/index.js
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.__esModule = true;
exports["default"] = void 0;
// @ts-check
var commentReg = /^\s*[;]/;

@@ -13,2 +13,5 @@ var kvReg = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;

/**
* @param {string} s
*/
var isQuoted = function isQuoted(s) {

@@ -18,3 +21,2 @@ if (s.length <= 1) {

}
var bAndE = s.charAt(0) + "" + s.slice(-1);

@@ -25,2 +27,5 @@ var bAndE2 = s.charAt(0) + "" + s.slice(-2);

/**
* @param {string} s
*/
var stripQuote = function stripQuote(s) {

@@ -30,12 +35,16 @@ return s.replace(stripQuoteReg, '"').substring(1, s.length - (s.slice(-1) === ";" ? 2 : 1));

/**
* @param {string} s
*/
var isMultiLine = function isMultiLine(s) {
var n = s.trim();
if (isQuoted(n)) {
return false;
}
return n.charAt(0) === '"' ? true : false;
};
/**
* @param {string} s
*/
var parse = function parse(s) {

@@ -48,10 +57,7 @@ var lines = s.split(linesReg);

var isEnd = false;
if (!line || commentReg.test(line)) {
return;
}
if (!key) {
var match = line.match(kvReg);
if (!match) {

@@ -61,9 +67,6 @@ console.error("Ini Parse Fail: " + line);

}
key = match[2];
value = match[3] ? match[4] || "" : "";
if (key.length > 2 && key.slice(-2) === "[]") {
key = key.substring(0, key.length - 2);
if (!p[key]) {

@@ -75,3 +78,2 @@ p[key] = [];

}
if (!isMultiLine(value)) {

@@ -82,14 +84,10 @@ isEnd = true;

var lineTrim = line.trim();
if (lineTrim === '"' || lineTrim === '";') {
isEnd = true;
}
if (!isEnd) {
value += "\n";
}
value += line;
}
if (isEnd) {

@@ -107,5 +105,3 @@ if (isQuoted(value)) {

}
key = key.trim();
if (key) {

@@ -118,3 +114,2 @@ if (isArray(p[key])) {

}
key = "";

@@ -126,5 +121,4 @@ value = "";

};
var _default = parse;
exports["default"] = _default;
module.exports = exports.default;
{
"version": "0.2.0",
"name": "parse-ini-string",
"version": "0.1.1",
"repository": {
"type": "git",
"url": "https://github.com/react-atomic/react-atomic-organism",
"directory": "packages/lib/parse-ini-string"
},
"homepage": "https://github.com/react-atomic/react-atomic-organism/tree/main/packages/lib/parse-ini-string",
"description": "PHP parse-ini-string like library, support multi line",
"repository": "react-atomic/react-atomic-organism",
"main": "./build/cjs/src/index.js",
"module": "./build/es/src/index.js",
"keywords": [

@@ -13,18 +17,27 @@ "ini"

"license": "MIT",
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.x",
"chai": "*",
"mocha": "*"
"reshow-unit-dom": "*"
},
"exports": {
"require": "./build/cjs/src/index.js",
"import": "./build/es/src/index.mjs"
},
"main": "./build/cjs/src/index.js",
"module": "./build/es/src/index.mjs",
"scripts": {
"clean": "find ./build -name '*.*' | xargs rm -rf",
"build": "npm run clean && npm run build:cjs && npm run build:es",
"build:cjs": "BABEL_ENV=build babel src -d build/cjs/src --root-mode upward",
"build:es": "BABEL_ENV=es babel src -d build/es/src --root-mode upward",
"mocha": "mocha 'build/cjs/**/__tests__/*.js'",
"build:cjs": "BABEL_ENV=cjs babel src -d build/cjs/src --ignore /**/__tests__ --root-mode upward",
"build:es": "BABEL_ENV=es babel src -d build/es/src --out-file-extension .mjs --root-mode upward",
"build:type": "npx -p typescript tsc src/*.js src/**/*.js --declaration --allowJs --emitDeclarationOnly --skipLibCheck --declarationDir types",
"build": "npm run clean && npm run build:cjs && npm run build:es && npm run build:type",
"mochaFor": "mocha -r global-jsdom/register",
"mocha": "npm run mochaFor -- 'build/es/**/__tests__/*.mjs'",
"test:report": "npm run build && npm run mochaFor -- --reporter mocha-junit-reporter --reporter-options mochaFile=./test_output/mocha.xml 'build/es/**/__tests__/*.mjs'",
"test": "npm run build && npm run mocha",
"prepublishOnly": "npm run test && npm run build"
"prepublishOnly": "npm run test"
},
"types": "./types/index.d.ts",
"files": [
"types",
"build",

@@ -31,0 +44,0 @@ "package.json",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc