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.340 to 0.0.341

core/pruners/pruners.d.ts

7

core/checks.d.ts

@@ -120,2 +120,9 @@ /**

export declare function isTypedArray<T>(typeGuard: (a: unknown) => a is T): (val: unknown) => val is T[];
/**
* Returns true if the specified value is a map.
*
* @param val Variable to test.
* @return Whether variable is a map.
*/
export declare function isMap(val: unknown): val is Map<unknown, unknown>;
export type Tuple<T, N extends number> = N extends N ? (number extends N ? T[] : TupleOfHelper<T, N, []>) : never;

@@ -122,0 +129,0 @@ type TupleOfHelper<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : TupleOfHelper<T, N, [T, ...R]>;

12

core/checks.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInstanceOf = exports.isLiteral = exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isPair = exports.isAtLeastLength = exports.isExactLength = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObjectUnsafer = exports.isObjectUnsafe = exports.isObject = exports.isFunction = exports.isInfinite = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isVoid = exports.isUndefined = exports.isNull = exports.isDef = void 0;
exports.isInstanceOf = exports.isLiteral = exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isPair = exports.isAtLeastLength = exports.isExactLength = exports.isMap = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObjectUnsafer = exports.isObjectUnsafe = exports.isObject = exports.isFunction = exports.isInfinite = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isVoid = exports.isUndefined = exports.isNull = exports.isDef = void 0;
/**

@@ -180,2 +180,12 @@ * Returns true if the specified value is not undefined.

exports.isTypedArray = isTypedArray;
/**
* Returns true if the specified value is a map.
*
* @param val Variable to test.
* @return Whether variable is a map.
*/
function isMap(val) {
return val instanceof Map;
}
exports.isMap = isMap;
function isExactLength(arr, exactLength) {

@@ -182,0 +192,0 @@ return arr.length === exactLength;

3

core/guards.d.ts

@@ -9,2 +9,3 @@ 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;
export type ValidatorWithTracking<TO extends FROM, FROM = unknown> = (p1: FROM, p2?: Map<number, unknown[]>, p3?: number) => p1 is TO;
export type Pruner = (p1: unknown, p2?: Map<number, unknown[]>, p3?: number) => unknown;

@@ -32,7 +32,6 @@ import { isNumber, isString } from '../checks';

/**
* valid if at least one item in the array is valid.
* @param subValidator
* @returns
* This validator functions the same as {@link arrayValidator}, with the option of passing in a map
* which will track all of the elements that were found to be invalid.
*/
export declare function arrayValidatorWithList<T>(subValidator: (p1: unknown, invalidItems?: unknown[]) => p1 is T): (p1: unknown, invalidItems?: unknown[]) => p1 is T[];
export declare function arrayValidatorWithInvalidElementTracking<T>(subValidator: (p1: unknown, invalidElements?: Map<number, unknown[]>, level?: number) => p1 is T): (subject: unknown, invalidElements?: Map<number, unknown[]>, level?: number) => subject is T[];
/**

@@ -80,8 +79,8 @@ * Creates a validator for a fixed width array where each entry

/**
* 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.
* This validator functions the same as {@link objectValidator}, with the option of passing in a map
* which will track all of the fields that were found to be invalid.
*/
export declare function objectValidatorWithList<T extends {
[key: string]: (p1: unknown, invalidFields?: unknown[]) => p1 is unknown;
}>(validatorStructure: T): (subject: unknown, invalidFields?: unknown[]) => subject is DestructureGuardedTypeObj<T>;
export declare function objectValidatorWithInvalidFieldTracking<T extends {
[key: string]: (p1: unknown, invalidFields?: Map<number, unknown[]>, level?: number) => p1 is unknown;
}>(validatorStructure: T): (subject: unknown, invalidFields?: Map<number, unknown[]>, level?: number) => subject is DestructureGuardedTypeObj<T>;
/**

@@ -88,0 +87,0 @@ * Creates a validator which tests if the target is an object

"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.objectValidatorWithList = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidatorWithList = 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.objectValidatorWithInvalidFieldTracking = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidatorWithInvalidElementTracking = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0;
const checks_1 = require("../checks");

@@ -68,15 +68,23 @@ /*********************************************************************************

/**
* valid if at least one item in the array is valid.
* @param subValidator
* @returns
* This validator functions the same as {@link arrayValidator}, with the option of passing in a map
* which will track all of the elements that were found to be invalid.
*/
function arrayValidatorWithList(subValidator) {
return (x, invalidItems) => {
if (!(0, checks_1.isArray)(x)) {
function arrayValidatorWithInvalidElementTracking(subValidator) {
return (subject, invalidElements, level = 0) => {
if (!(0, checks_1.isArray)(subject)) {
return false;
}
return x.some((item) => subValidator(item, invalidItems));
let valid = true;
const invalidList = [];
subject.forEach((item) => {
if (!subValidator(item, invalidElements, level + 1)) {
invalidList.push(item);
valid = false;
}
});
invalidElements === null || invalidElements === void 0 ? void 0 : invalidElements.set(level, invalidList);
return valid;
};
}
exports.arrayValidatorWithList = arrayValidatorWithList;
exports.arrayValidatorWithInvalidElementTracking = arrayValidatorWithInvalidElementTracking;
/**

@@ -164,7 +172,7 @@ * Creates a validator for a fixed width array where each entry

/**
* 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.
* This validator functions the same as {@link objectValidator}, with the option of passing in a map
* which will track all of the fields that were found to be invalid.
*/
function objectValidatorWithList(validatorStructure) {
return (subject, invalidFields) => {
function objectValidatorWithInvalidFieldTracking(validatorStructure) {
return (subject, invalidFields, level = 0) => {
if ((0, checks_1.isArray)(subject) || !(0, checks_1.isObjectUnsafe)(subject)) {

@@ -175,10 +183,12 @@ return false;

let valid = true;
const invalidList = [];
Object.entries(validatorStructure).forEach(([key, validator]) => {
if (!validator(subject[key], invalidFields)) {
if (invalidFields && Array.isArray(invalidFields)) {
invalidFields.push(key);
}
if (!validator(subject[key], invalidFields, level + 1)) {
invalidList.push([key, subject[key]]);
valid = false;
}
});
if ((0, checks_1.isMap)(invalidFields)) {
invalidFields.set(level, invalidList);
}
return valid;

@@ -188,3 +198,3 @@ }

}
exports.objectValidatorWithList = objectValidatorWithList;
exports.objectValidatorWithInvalidFieldTracking = objectValidatorWithInvalidFieldTracking;
/**

@@ -191,0 +201,0 @@ * Creates a validator which tests if the target is an object

{
"name": "lucid-extension-sdk",
"version": "0.0.340",
"version": "0.0.341",
"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