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 2.89.0 to 2.89.1

30

dist/browser/index.js

@@ -113,2 +113,26 @@ var __defProp = Object.defineProperty;

// src/JsonObject.ts
var isJsonValue = /* @__PURE__ */ __name((value) => {
switch (typeof value) {
case "string":
case "number":
case "boolean": {
return true;
}
default: {
return value === null || isJsonObject(value) || isJsonArray(value);
}
}
}, "isJsonValue");
var isJsonArray = /* @__PURE__ */ __name((value) => {
return Array.isArray(value) && !value.some((item) => !isJsonValue(item));
}, "isJsonArray");
var isValidJsonFieldPair = /* @__PURE__ */ __name(([key, value]) => {
return typeof key === "string" && isJsonValue(value);
}, "isValidJsonFieldPair");
var isJsonObject = /* @__PURE__ */ __name((value) => {
return isObject(value) && //check if all keys are strings
!Object.entries(value).some((item) => !isValidJsonFieldPair(item));
}, "isJsonObject");
// src/ObjectWrapper.ts

@@ -142,5 +166,9 @@ var ObjectWrapper = class {

asAnyObject,
isJsonArray,
isJsonObject,
isJsonValue,
isObject,
isType
isType,
isValidJsonFieldPair
};
//# sourceMappingURL=index.js.map

@@ -6,2 +6,6 @@ export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;

export type JsonArray = JsonValue[];
export declare const isJsonValue: (value: unknown) => value is JsonValue;
export declare const isJsonArray: (value: unknown) => value is JsonArray;
export declare const isValidJsonFieldPair: ([key, value]: [key: unknown, value: unknown]) => boolean;
export declare const isJsonObject: (value: unknown) => value is JsonObject;
//# sourceMappingURL=JsonObject.d.ts.map

@@ -118,2 +118,26 @@ var __defProp = Object.defineProperty;

// src/JsonObject.ts
var isJsonValue = /* @__PURE__ */ __name((value) => {
switch (typeof value) {
case "string":
case "number":
case "boolean": {
return true;
}
default: {
return value === null || isJsonObject(value) || isJsonArray(value);
}
}
}, "isJsonValue");
var isJsonArray = /* @__PURE__ */ __name((value) => {
return Array.isArray(value) && !value.some((item) => !isJsonValue(item));
}, "isJsonArray");
var isValidJsonFieldPair = /* @__PURE__ */ __name(([key, value]) => {
return typeof key === "string" && isJsonValue(value);
}, "isValidJsonFieldPair");
var isJsonObject = /* @__PURE__ */ __name((value) => {
return isObject(value) && //check if all keys are strings
!Object.entries(value).some((item) => !isValidJsonFieldPair(item));
}, "isJsonObject");
// src/ObjectWrapper.ts

@@ -145,5 +169,9 @@ var _ObjectWrapper = class _ObjectWrapper {

asAnyObject,
isJsonArray,
isJsonObject,
isJsonValue,
isObject,
isType
isType,
isValidJsonFieldPair
};
//# sourceMappingURL=index.js.map

@@ -6,2 +6,6 @@ export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;

export type JsonArray = JsonValue[];
export declare const isJsonValue: (value: unknown) => value is JsonValue;
export declare const isJsonArray: (value: unknown) => value is JsonArray;
export declare const isValidJsonFieldPair: ([key, value]: [key: unknown, value: unknown]) => boolean;
export declare const isJsonObject: (value: unknown) => value is JsonObject;
//# sourceMappingURL=JsonObject.d.ts.map

8

package.json

@@ -14,5 +14,5 @@ {

"dependencies": {
"@xylabs/assert": "^2.14.0",
"@xylabs/logger": "^2.14.0",
"@xylabs/promise": "^2.14.0"
"@xylabs/assert": "^2.14.1",
"@xylabs/logger": "^2.14.1",
"@xylabs/promise": "^2.14.1"
},

@@ -62,4 +62,4 @@ "devDependencies": {

"sideEffects": false,
"version": "2.89.0",
"version": "2.89.1",
"type": "module"
}

@@ -0,3 +1,34 @@

import { isObject } from './isObject'
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray
export type JsonObject = { [key: string]: JsonValue }
export type JsonArray = JsonValue[]
export const isJsonValue = (value: unknown): value is JsonValue => {
switch (typeof value) {
case 'string':
case 'number':
case 'boolean': {
return true
}
default: {
return value === null || isJsonObject(value) || isJsonArray(value)
}
}
}
export const isJsonArray = (value: unknown): value is JsonArray => {
return Array.isArray(value) && !value.some((item) => !isJsonValue(item))
}
export const isValidJsonFieldPair = ([key, value]: [key: unknown, value: unknown]) => {
return typeof key === 'string' && isJsonValue(value)
}
export const isJsonObject = (value: unknown): value is JsonObject => {
return (
isObject(value) &&
//check if all keys are strings
!Object.entries(value).some((item) => !isValidJsonFieldPair(item))
)
}

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

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