remove dynamic equality

This commit is contained in:
2025-06-16 13:48:09 -05:00
parent 9c0565d34f
commit 794baf8598
70 changed files with 462 additions and 461 deletions

View File

@@ -42,9 +42,9 @@ function parse_toml(text) {
} else if (value.startsWith('[') && value.endsWith(']')) {
// Array
current_section[key] = parse_array(value)
} else if (value === 'true' || value === 'false') {
} else if (value == 'true' || value == 'false') {
// Boolean
current_section[key] = value === 'true'
current_section[key] = value == 'true'
} else if (!isNaN(Number(value))) {
// Number
current_section[key] = Number(value)
@@ -70,10 +70,10 @@ function parse_array(str) {
for (var i = 0; i < str.length; i++) {
var char = str[i]
if (char === '"' && (i === 0 || str[i-1] !== '\\')) {
if (char == '"' && (i == 0 || str[i-1] != '\\')) {
in_quotes = !in_quotes
current += char
} else if (char === ',' && !in_quotes) {
} else if (char == ',' && !in_quotes) {
items.push(parse_value(current.trim()))
current = ''
} else {
@@ -91,8 +91,8 @@ function parse_array(str) {
function parse_value(str) {
if (str.startsWith('"') && str.endsWith('"')) {
return str.slice(1, -1).replace(/\\"/g, '"')
} else if (str === 'true' || str === 'false') {
return str === 'true'
} else if (str == 'true' || str == 'false') {
return str == 'true'
} else if (!isNaN(Number(str))) {
return Number(str)
} else {
@@ -104,11 +104,11 @@ function encode_toml(obj) {
var result = []
function encode_value(value) {
if (typeof value === 'string') {
if (typeof value == 'string') {
return '"' + value.replace(/"/g, '\\"') + '"'
} else if (typeof value === 'boolean') {
} else if (typeof value == 'boolean') {
return value ? 'true' : 'false'
} else if (typeof value === 'number') {
} else if (typeof value == 'number') {
return String(value)
} else if (Array.isArray(value)) {
var items = []
@@ -125,7 +125,7 @@ function encode_toml(obj) {
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
var value = obj[key]
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
if (value == null || typeof value != 'object' || Array.isArray(value)) {
result.push(key + ' = ' + encode_value(value))
}
}
@@ -138,7 +138,7 @@ function encode_toml(obj) {
var key = keys[i]
var value = obj[key]
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
if (value != null && typeof value == 'object' && !Array.isArray(value)) {
// Nested object - create section
var section_path = path ? path + '.' + key : key
result.push('[' + section_path + ']')
@@ -148,7 +148,7 @@ function encode_toml(obj) {
for (var j = 0; j < section_keys.length; j++) {
var sk = section_keys[j]
var sv = value[sk]
if (sv === null || typeof sv !== 'object' || Array.isArray(sv)) {
if (sv == null || typeof sv != 'object' || Array.isArray(sv)) {
result.push(sk + ' = ' + encode_value(sv))
}
}