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

@xylabs/object

Package Overview
Dependencies
Maintainers
7
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xylabs/object - npm Package Compare versions

Comparing version 3.0.8 to 3.0.9

67

dist/browser/index.js

@@ -1,4 +0,1 @@

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// src/AsTypeFactory.ts

@@ -10,5 +7,5 @@ import { assertEx } from "@xylabs/assert";

function func(value, assertOrConfig, config) {
const noUndefined = /* @__PURE__ */ __name((resolvedAssert2) => {
const noUndefined = (resolvedAssert2) => {
return resolvedAssert2 !== void 0;
}, "noUndefined");
};
if (value === void 0) {

@@ -25,3 +22,2 @@ return void 0;

}
__name(func, "func");
return func;

@@ -39,3 +35,3 @@ }

// src/isType.ts
var isType = /* @__PURE__ */ __name((value, expectedType) => {
var isType = (value, expectedType) => {
const typeofValue = typeof value;

@@ -62,8 +58,8 @@ switch (expectedType) {

}
}, "isType");
};
// src/isObject.ts
var isObject = /* @__PURE__ */ __name((value) => {
var isObject = (value) => {
return isType(value, "object");
}, "isObject");
};

@@ -75,7 +71,2 @@ // src/asObject.ts

var Base = class _Base {
static {
__name(this, "Base");
}
params;
static defaultLogger;
constructor(params) {

@@ -85,2 +76,3 @@ this.params = params;

}
static defaultLogger;
get logger() {

@@ -93,5 +85,2 @@ return this.params?.logger ?? _Base.defaultLogger;

var IsObjectFactory = class {
static {
__name(this, "IsObjectFactory");
}
create(shape, additionalChecks) {

@@ -112,5 +101,3 @@ return (obj, { log } = {}) => {

}).length === 0 && //perform additional checks
(additionalChecks?.reduce((prev, check) => prev && check(obj, {
log
}), true) ?? true)
(additionalChecks?.reduce((prev, check) => prev && check(obj, { log }), true) ?? true)
);

@@ -122,3 +109,3 @@ };

// src/JsonObject.ts
var isJsonValue = /* @__PURE__ */ __name((value) => {
var isJsonValue = (value) => {
switch (typeof value) {

@@ -134,19 +121,16 @@ case "string":

}
}, "isJsonValue");
var isJsonArray = /* @__PURE__ */ __name((value) => {
};
var isJsonArray = (value) => {
return Array.isArray(value) && !value.some((item) => !isJsonValue(item));
}, "isJsonArray");
var isValidJsonFieldPair = /* @__PURE__ */ __name(([key, value]) => {
};
var isValidJsonFieldPair = ([key, value]) => {
return typeof key === "string" && isJsonValue(value);
}, "isValidJsonFieldPair");
var isJsonObject = /* @__PURE__ */ __name((value) => {
};
var isJsonObject = (value) => {
return isObject(value) && //check if all keys are strings
!Object.entries(value).some((item) => !isValidJsonFieldPair(item));
}, "isJsonObject");
};
// src/ObjectWrapper.ts
var ObjectWrapper = class {
static {
__name(this, "ObjectWrapper");
}
obj;

@@ -162,6 +146,6 @@ constructor(obj) {

// src/toJson.ts
var toJsonArray = /* @__PURE__ */ __name((value, cycleList) => {
var toJsonArray = (value, cycleList) => {
return value.map((item) => toJsonValue(item, cycleList));
}, "toJsonArray");
var toJsonObject = /* @__PURE__ */ __name((value, cycleList) => {
};
var toJsonObject = (value, cycleList) => {
const result = {};

@@ -172,4 +156,4 @@ for (const [key, entry] of Object.entries(value)) {

return result;
}, "toJsonObject");
var toJsonValue = /* @__PURE__ */ __name((value, cycleList) => {
};
var toJsonValue = (value, cycleList) => {
if (cycleList?.includes(value)) {

@@ -196,12 +180,9 @@ return "[Circular]";

}
}, "toJsonValue");
var toJson = /* @__PURE__ */ __name((value) => {
};
var toJson = (value) => {
return toJsonValue(value);
}, "toJson");
};
// src/Validator.ts
var ValidatorBase = class extends ObjectWrapper {
static {
__name(this, "ValidatorBase");
}
};

@@ -208,0 +189,0 @@ export {

@@ -1,9 +0,1 @@

var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
// src/AsTypeFactory.ts

@@ -15,5 +7,5 @@ import { assertEx } from "@xylabs/assert";

function func(value, assertOrConfig, config) {
const noUndefined = /* @__PURE__ */ __name((resolvedAssert2) => {
const noUndefined = (resolvedAssert2) => {
return resolvedAssert2 !== void 0;
}, "noUndefined");
};
if (value === void 0) {

@@ -30,3 +22,2 @@ return void 0;

}
__name(func, "func");
return func;

@@ -44,3 +35,3 @@ }

// src/isType.ts
var isType = /* @__PURE__ */ __name((value, expectedType) => {
var isType = (value, expectedType) => {
const typeofValue = typeof value;

@@ -67,8 +58,8 @@ switch (expectedType) {

}
}, "isType");
};
// src/isObject.ts
var isObject = /* @__PURE__ */ __name((value) => {
var isObject = (value) => {
return isType(value, "object");
}, "isObject");
};

@@ -79,9 +70,9 @@ // src/asObject.ts

// src/Base.ts
var _Base = class _Base {
params;
var Base = class _Base {
constructor(params) {
this.params = params;
var _a;
this.params = params;
(_a = params.logger) == null ? void 0 : _a.debug(`Base constructed [${Object(this).name}]`);
}
static defaultLogger;
get logger() {

@@ -92,8 +83,5 @@ var _a;

};
__name(_Base, "Base");
__publicField(_Base, "defaultLogger");
var Base = _Base;
// src/IsObjectFactory.ts
var _IsObjectFactory = class _IsObjectFactory {
var IsObjectFactory = class {
create(shape, additionalChecks) {

@@ -114,5 +102,3 @@ return (obj, { log } = {}) => {

}).length === 0 && //perform additional checks
((additionalChecks == null ? void 0 : additionalChecks.reduce((prev, check) => prev && check(obj, {
log
}), true)) ?? true)
((additionalChecks == null ? void 0 : additionalChecks.reduce((prev, check) => prev && check(obj, { log }), true)) ?? true)
);

@@ -122,7 +108,5 @@ };

};
__name(_IsObjectFactory, "IsObjectFactory");
var IsObjectFactory = _IsObjectFactory;
// src/JsonObject.ts
var isJsonValue = /* @__PURE__ */ __name((value) => {
var isJsonValue = (value) => {
switch (typeof value) {

@@ -138,16 +122,16 @@ case "string":

}
}, "isJsonValue");
var isJsonArray = /* @__PURE__ */ __name((value) => {
};
var isJsonArray = (value) => {
return Array.isArray(value) && !value.some((item) => !isJsonValue(item));
}, "isJsonArray");
var isValidJsonFieldPair = /* @__PURE__ */ __name(([key, value]) => {
};
var isValidJsonFieldPair = ([key, value]) => {
return typeof key === "string" && isJsonValue(value);
}, "isValidJsonFieldPair");
var isJsonObject = /* @__PURE__ */ __name((value) => {
};
var isJsonObject = (value) => {
return isObject(value) && //check if all keys are strings
!Object.entries(value).some((item) => !isValidJsonFieldPair(item));
}, "isJsonObject");
};
// src/ObjectWrapper.ts
var _ObjectWrapper = class _ObjectWrapper {
var ObjectWrapper = class {
obj;

@@ -161,10 +145,8 @@ constructor(obj) {

};
__name(_ObjectWrapper, "ObjectWrapper");
var ObjectWrapper = _ObjectWrapper;
// src/toJson.ts
var toJsonArray = /* @__PURE__ */ __name((value, cycleList) => {
var toJsonArray = (value, cycleList) => {
return value.map((item) => toJsonValue(item, cycleList));
}, "toJsonArray");
var toJsonObject = /* @__PURE__ */ __name((value, cycleList) => {
};
var toJsonObject = (value, cycleList) => {
const result = {};

@@ -175,4 +157,4 @@ for (const [key, entry] of Object.entries(value)) {

return result;
}, "toJsonObject");
var toJsonValue = /* @__PURE__ */ __name((value, cycleList) => {
};
var toJsonValue = (value, cycleList) => {
if (cycleList == null ? void 0 : cycleList.includes(value)) {

@@ -199,12 +181,10 @@ return "[Circular]";

}
}, "toJsonValue");
var toJson = /* @__PURE__ */ __name((value) => {
};
var toJson = (value) => {
return toJsonValue(value);
}, "toJson");
};
// src/Validator.ts
var _ValidatorBase = class _ValidatorBase extends ObjectWrapper {
var ValidatorBase = class extends ObjectWrapper {
};
__name(_ValidatorBase, "ValidatorBase");
var ValidatorBase = _ValidatorBase;
export {

@@ -211,0 +191,0 @@ AsObjectFactory,

@@ -14,9 +14,9 @@ {

"dependencies": {
"@xylabs/assert": "^3.0.8",
"@xylabs/logger": "^3.0.8",
"@xylabs/promise": "^3.0.8"
"@xylabs/assert": "^3.0.9",
"@xylabs/logger": "^3.0.9",
"@xylabs/promise": "^3.0.9"
},
"devDependencies": {
"@xylabs/ts-scripts-yarn3": "^3.4.1",
"@xylabs/tsconfig": "^3.4.1",
"@xylabs/ts-scripts-yarn3": "^3.5.0",
"@xylabs/tsconfig": "^3.5.0",
"typescript": "^5.4.2"

@@ -62,4 +62,4 @@ },

"sideEffects": false,
"version": "3.0.8",
"version": "3.0.9",
"type": "module"
}

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

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