mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-14 20:48:17 +08:00
⛅ Sync 2026-10-11 13:16:00
This commit is contained in:
1 parent
705dadd362
commit
e6d1b4e2d7
105 files changed
+26511
-50
No files matched your search
@@ -0,0 +1,15 @@
|
||||
'use strict';
|
||||
const fs = require('node:fs');
|
||||
const fields = fs.readFileSync(process.argv[2], 'utf8').split('\0');
|
||||
const root = {}, stack = [root];
|
||||
for (let i = 0; i + 2 < fields.length; i += 3) {
|
||||
const [type, key, raw] = fields.slice(i, i + 3);
|
||||
if (type === 'init') continue;
|
||||
if (type === 'close') { stack.pop(); continue; }
|
||||
const value = type === 'array' ? [] : type === 'object' ? {} : type === 'boolean' ? raw === '1' : raw;
|
||||
const current = stack[stack.length - 1];
|
||||
if (Array.isArray(current)) current.push(value);
|
||||
else current[key] = value;
|
||||
if (type === 'array' || type === 'object') stack.push(value);
|
||||
}
|
||||
process.stdout.write(JSON.stringify(root) + '\n');
|
||||
Reference in new issue
Block a user