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

lucid-extension-sdk

Package Overview
Dependencies
Maintainers
0
Versions
318
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lucid-extension-sdk - npm Package Compare versions

Comparing version 0.0.301 to 0.0.302

1

core/guards.d.ts

@@ -9,1 +9,2 @@ import { WithUndefinedAsOptional } from './optionalkey';

export type Validator<TO extends FROM, FROM = unknown> = (p1: FROM) => p1 is TO;
export type ValidatorWithList<TO extends FROM, FROM = unknown> = (p1: FROM, p2: unknown[]) => p1 is TO;

3

core/object.d.ts

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

export declare function objectEvery<T, O extends {
[key: string]: any;
}>(obj: O, f: (this: T | undefined, _0: O[typeof _1], _1: string & keyof O, _2: O) => any, opt_this?: T): boolean;
export declare function flatten<T>(a: T[][]): T[];

@@ -5,0 +2,0 @@ export declare function fromEntries<K extends PropertyKey, T>(entries: Iterable<readonly [K, T]>): {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromEntries = exports.flatten = exports.objectEvery = void 0;
function objectEvery(obj, f, opt_this) {
for (const key in obj) {
if (!f.call(opt_this, obj[key], key, obj)) {
return false;
}
}
return true;
}
exports.objectEvery = objectEvery;
exports.fromEntries = exports.flatten = void 0;
function flatten(a) {

@@ -14,0 +5,0 @@ const result = [];

@@ -73,2 +73,9 @@ import { isNumber, isString } from '../checks';

/**
* This validator functions the same as {@link objectValidator}, with the option of passing in a list
* which will return all of the fields that were found to be invalid.
*/
export declare function objectValidatorWithList<T extends {
[key: string]: (p1: unknown) => p1 is unknown;
}>(validatorStructure: T): (subject: unknown, invalidFields?: unknown[]) => subject is DestructureGuardedTypeObj<T>;
/**
* Creates a validator which tests if the target is an object

@@ -75,0 +82,0 @@ * and if the structure of the object matches the structure of the passed-in

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isFalse = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.typedRecordValidator = exports.recordValidator = exports.strictObjectValidator = exports.partialObjectValidator = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isFalse = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.typedRecordValidator = exports.recordValidator = exports.strictObjectValidator = exports.partialObjectValidator = exports.objectValidatorWithList = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
const checks_1 = require("../checks");
const object_1 = require("../object");
/*********************************************************************************

@@ -120,3 +119,3 @@ * Validator generators: These functions construct new composite validators

return (x) => {
return (0, checks_1.isObject)(x) && !(0, checks_1.isArray)(x) && (0, object_1.objectEvery)(x, subValidator);
return (0, checks_1.isObject)(x) && !(0, checks_1.isArray)(x) && Object.entries(x).every(([key, value]) => subValidator(value));
};

@@ -143,3 +142,3 @@ }

else {
return (0, object_1.objectEvery)(validatorStructure, (validator, key) => {
return Object.entries(validatorStructure).every(([key, validator]) => {
return validator(subject[key]);

@@ -152,2 +151,24 @@ });

/**
* This validator functions the same as {@link objectValidator}, with the option of passing in a list
* which will return all of the fields that were found to be invalid.
*/
function objectValidatorWithList(validatorStructure) {
return (subject, invalidFields) => {
if ((0, checks_1.isArray)(subject) || !(0, checks_1.isObjectUnsafe)(subject)) {
return false;
}
else {
let valid = true;
Object.entries(validatorStructure).forEach(([key, validator]) => {
if (!validator(subject[key])) {
invalidFields === null || invalidFields === void 0 ? void 0 : invalidFields.push(key);
valid = false;
}
});
return valid;
}
};
}
exports.objectValidatorWithList = objectValidatorWithList;
/**
* Creates a validator which tests if the target is an object

@@ -163,3 +184,3 @@ * and if the structure of the object matches the structure of the passed-in

else {
return (0, object_1.objectEvery)(validatorStructure, (validator, key) => {
return Object.entries(validatorStructure).every(([key, validator]) => {
return subject[key] === undefined || validator(subject[key]);

@@ -184,3 +205,3 @@ });

return (looseValidator(subject) &&
(0, object_1.objectEvery)(subject, (subx, key) => subx === undefined || validatorStructure.hasOwnProperty(key)));
Object.entries(subject).every(([key, subx]) => subx === undefined || validatorStructure.hasOwnProperty(key)));
};

@@ -194,3 +215,3 @@ }

keyList.every((k) => k in x) &&
(0, object_1.objectEvery)(x, (val, key) => {
Object.entries(x).every(([key, val]) => {
return valueValidator(val);

@@ -308,3 +329,3 @@ }));

function isSet(x) {
return (0, checks_1.isObject)(x) && !(0, checks_1.isArray)(x) && (0, object_1.objectEvery)(x, (val) => (0, checks_1.isBoolean)(val) && !!val);
return (0, checks_1.isObject)(x) && !(0, checks_1.isArray)(x) && Object.entries(x).every(([key, value]) => (0, checks_1.isBoolean)(value) && !!value);
}

@@ -311,0 +332,0 @@ exports.isSet = isSet;

{
"name": "lucid-extension-sdk",
"version": "0.0.301",
"version": "0.0.302",
"description": "Utility classes for writing Lucid Software editor extensions",

@@ -5,0 +5,0 @@ "main": "index.js",

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