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

@augment-vir/common

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@augment-vir/common - npm Package Compare versions

Comparing version 19.5.0 to 19.6.0

25

dist/cjs/augments/object/nested-keys.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getValueFromNestedKeys = void 0;
exports.getValueFromNestedKeys = exports.setValueWithNestedKeys = void 0;
const object_1 = require("./object");
const typed_has_property_1 = require("./typed-has-property");
function setValueWithNestedKeys(inputObject, nestedKeys, value) {
/**
* Lots of as any casts in here because these types are, under the hood, pretty complex. Since
* the inputs and outputs of this function are well typed, these internal as any casts do not
* affect the external API of this function.
*/
const nextKey = nestedKeys[0];
if (!(nextKey in inputObject)) {
inputObject[nextKey] = {};
}
else if (!(0, object_1.isObject)(inputObject[nextKey])) {
throw new Error(`Cannot set value at key '${String(nextKey)}' as its not an object.`);
}
const nextParent = inputObject[nextKey];
if (nestedKeys.length > 2) {
setValueWithNestedKeys(nextParent, nestedKeys.slice(1), value);
}
else {
nextParent[nestedKeys[1]] = value;
}
}
exports.setValueWithNestedKeys = setValueWithNestedKeys;
function getValueFromNestedKeys(inputObject, nestedKeys) {

@@ -6,0 +29,0 @@ /**

@@ -0,2 +1,24 @@

import { isObject } from './object';
import { typedHasProperty } from './typed-has-property';
export function setValueWithNestedKeys(inputObject, nestedKeys, value) {
/**
* Lots of as any casts in here because these types are, under the hood, pretty complex. Since
* the inputs and outputs of this function are well typed, these internal as any casts do not
* affect the external API of this function.
*/
const nextKey = nestedKeys[0];
if (!(nextKey in inputObject)) {
inputObject[nextKey] = {};
}
else if (!isObject(inputObject[nextKey])) {
throw new Error(`Cannot set value at key '${String(nextKey)}' as its not an object.`);
}
const nextParent = inputObject[nextKey];
if (nestedKeys.length > 2) {
setValueWithNestedKeys(nextParent, nestedKeys.slice(1), value);
}
else {
nextParent[nestedKeys[1]] = value;
}
}
export function getValueFromNestedKeys(inputObject, nestedKeys) {

@@ -3,0 +25,0 @@ /**

@@ -11,2 +11,3 @@ import { PropertyValueType } from './object';

export type NestedValue<ObjectGeneric extends object, NestedKeysGeneric extends NestedSequentialKeys<ObjectGeneric>> = NestedKeysGeneric extends readonly [infer FirstEntry, ...infer FollowingEntries] ? FirstEntry extends keyof ObjectGeneric ? FollowingEntries extends never[] ? ObjectGeneric[FirstEntry] : ObjectGeneric[FirstEntry] extends object ? FollowingEntries extends NestedSequentialKeys<ObjectGeneric[FirstEntry]> ? NestedValue<ObjectGeneric[FirstEntry], FollowingEntries> : never : never : never : never;
export declare function setValueWithNestedKeys<const ObjectGeneric extends object, const KeysGeneric extends NestedSequentialKeys<ObjectGeneric>>(inputObject: ObjectGeneric, nestedKeys: KeysGeneric, value: NestedValue<ObjectGeneric, KeysGeneric>): void;
export declare function getValueFromNestedKeys<const ObjectGeneric extends object, const KeysGeneric extends NestedSequentialKeys<ObjectGeneric>>(inputObject: ObjectGeneric, nestedKeys: KeysGeneric): NestedValue<ObjectGeneric, KeysGeneric> | undefined;

2

package.json
{
"name": "@augment-vir/common",
"version": "19.5.0",
"version": "19.6.0",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",

@@ -5,0 +5,0 @@ "bugs": {

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