schemaglobin
Advanced tools
Comparing version 4.3.3 to 4.4.0
@@ -0,1 +1,2 @@ | ||
import type { UnknownObject } from "../types"; | ||
/** Is a value an unknown object? (is a TypeScript assertion object that asserts various things). */ | ||
@@ -36,1 +37,4 @@ export declare const isObject: <T extends Record<string, unknown>>(value: unknown) => value is T; | ||
export declare const updateProp: <O extends Record<string, unknown>, K extends keyof O>(obj: O, key: K, value: O[K]) => O; | ||
/** Extract a named (possibly deep) prop from an object. */ | ||
export declare function getProp<O extends UnknownObject, K extends keyof O | string | number>(obj: O, key: K): K extends keyof O ? O[K] : undefined; | ||
export declare function getProp<O extends UnknownObject>(obj: O, key: string | number, ...deeperKeys: (string | number)[]): unknown; |
"use strict"; | ||
/* eslint-disable no-param-reassign */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.updateProp = exports.setProp = exports.deleteProp = exports.mapKeys = exports.mapObject = exports.SKIP = exports.objectFromEntries = exports.isObject = void 0; | ||
exports.getProp = exports.updateProp = exports.setProp = exports.deleteProp = exports.mapKeys = exports.mapObject = exports.SKIP = exports.objectFromEntries = exports.isObject = void 0; | ||
/** Is a value an unknown object? (is a TypeScript assertion object that asserts various things). */ | ||
@@ -82,1 +83,14 @@ exports.isObject = (value) => typeof value === "object" && value !== null; | ||
}; | ||
function getProp(obj, key, ...deeperKeys) { | ||
if (!(key in obj)) | ||
return undefined; | ||
let current = obj[key]; | ||
if (deeperKeys.length) | ||
for (const k of deeperKeys) { | ||
if (!exports.isObject(current) || !(k in current)) | ||
return undefined; | ||
current = current[k]; | ||
} | ||
return current; | ||
} | ||
exports.getProp = getProp; |
{ | ||
"name": "schemaglobin", | ||
"description": "Validate user-entered data.", | ||
"version": "4.3.3", | ||
"version": "4.4.0", | ||
"repository": "https://github.com/dhoulb/schemaglobin", | ||
@@ -6,0 +6,0 @@ "author": "Dave Houlbrooke <dave@shax.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133988
2443