@xylabs/object
Advanced tools
Comparing version
@@ -15,4 +15,5 @@ export * from './AnyObject'; | ||
export * from './StringKeyObject'; | ||
export * from './toJson'; | ||
export * from './Validator'; | ||
export * from './WithAdditional'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -151,2 +151,40 @@ var __defProp = Object.defineProperty; | ||
// src/toJson.ts | ||
var toJsonArray = /* @__PURE__ */ __name((value, cycleList) => { | ||
return value.map((item) => toJsonValue(item, cycleList)); | ||
}, "toJsonArray"); | ||
var toJsonObject = /* @__PURE__ */ __name((value, cycleList) => { | ||
const result = {}; | ||
for (const [key, entry] of Object.entries(value)) { | ||
result[key] = value === void 0 ? "[Undefined]" : toJsonValue(entry, cycleList); | ||
} | ||
return result; | ||
}, "toJsonObject"); | ||
var toJsonValue = /* @__PURE__ */ __name((value, cycleList) => { | ||
if (cycleList?.includes(value)) { | ||
return "[Circular]"; | ||
} | ||
switch (typeof value) { | ||
case "string": | ||
case "boolean": | ||
case "number": { | ||
return value; | ||
} | ||
case "object": { | ||
if (value === null) { | ||
return null; | ||
} | ||
const newCycleList = cycleList ?? []; | ||
newCycleList.push(value); | ||
return Array.isArray(value) ? toJsonArray(value) : toJsonObject(value); | ||
} | ||
default: { | ||
return `[${typeof value}]`; | ||
} | ||
} | ||
}, "toJsonValue"); | ||
var toJson = /* @__PURE__ */ __name((value) => { | ||
return toJsonValue(value); | ||
}, "toJson"); | ||
// src/Validator.ts | ||
@@ -171,4 +209,5 @@ var ValidatorBase = class extends ObjectWrapper { | ||
isType, | ||
isValidJsonFieldPair | ||
isValidJsonFieldPair, | ||
toJson | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -15,4 +15,5 @@ export * from './AnyObject'; | ||
export * from './StringKeyObject'; | ||
export * from './toJson'; | ||
export * from './Validator'; | ||
export * from './WithAdditional'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -155,2 +155,40 @@ var __defProp = Object.defineProperty; | ||
// src/toJson.ts | ||
var toJsonArray = /* @__PURE__ */ __name((value, cycleList) => { | ||
return value.map((item) => toJsonValue(item, cycleList)); | ||
}, "toJsonArray"); | ||
var toJsonObject = /* @__PURE__ */ __name((value, cycleList) => { | ||
const result = {}; | ||
for (const [key, entry] of Object.entries(value)) { | ||
result[key] = value === void 0 ? "[Undefined]" : toJsonValue(entry, cycleList); | ||
} | ||
return result; | ||
}, "toJsonObject"); | ||
var toJsonValue = /* @__PURE__ */ __name((value, cycleList) => { | ||
if (cycleList == null ? void 0 : cycleList.includes(value)) { | ||
return "[Circular]"; | ||
} | ||
switch (typeof value) { | ||
case "string": | ||
case "boolean": | ||
case "number": { | ||
return value; | ||
} | ||
case "object": { | ||
if (value === null) { | ||
return null; | ||
} | ||
const newCycleList = cycleList ?? []; | ||
newCycleList.push(value); | ||
return Array.isArray(value) ? toJsonArray(value) : toJsonObject(value); | ||
} | ||
default: { | ||
return `[${typeof value}]`; | ||
} | ||
} | ||
}, "toJsonValue"); | ||
var toJson = /* @__PURE__ */ __name((value) => { | ||
return toJsonValue(value); | ||
}, "toJson"); | ||
// src/Validator.ts | ||
@@ -174,4 +212,5 @@ var _ValidatorBase = class _ValidatorBase extends ObjectWrapper { | ||
isType, | ||
isValidJsonFieldPair | ||
isValidJsonFieldPair, | ||
toJson | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -14,5 +14,5 @@ { | ||
"dependencies": { | ||
"@xylabs/assert": "^3.0.2", | ||
"@xylabs/logger": "^3.0.2", | ||
"@xylabs/promise": "^3.0.2" | ||
"@xylabs/assert": "^3.0.3", | ||
"@xylabs/logger": "^3.0.3", | ||
"@xylabs/promise": "^3.0.3" | ||
}, | ||
@@ -62,4 +62,4 @@ "devDependencies": { | ||
"sideEffects": false, | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"type": "module" | ||
} |
@@ -15,3 +15,4 @@ export * from './AnyObject' | ||
export * from './StringKeyObject' | ||
export * from './toJson' | ||
export * from './Validator' | ||
export * from './WithAdditional' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
210979
8.49%246
5.58%1361
16.92%Updated
Updated
Updated