@nomicfoundation/hardhat-utils
Advanced tools
+6
-0
| # @nomicfoundation/hardhat-utils | ||
| ## 3.0.5 | ||
| ### Patch Changes | ||
| - d45234d: Fixed Etherscan verification failures by removing hardcoded v1 API URLs from chain descriptors ([#7623](https://github.com/NomicFoundation/hardhat/issues/7623)). Also enhanced config resolution to support partial overrides in block explorer configurations for future extensibility. | ||
| ## 3.0.4 | ||
@@ -4,0 +10,0 @@ |
| export declare function getDeepCloneFunction(): Promise<(<T>(input: T) => T)>; | ||
| export declare function deepMergeImpl<T extends object, U extends object>(target: T, source: U): T & U; | ||
| export declare function deepMergeImpl<T extends object, S extends object>(target: T, source: S, shouldOverwriteUndefined: boolean): T & S; | ||
| //# sourceMappingURL=lang.d.ts.map |
@@ -10,9 +10,8 @@ import { isObject } from "../lang.js"; | ||
| } | ||
| export function deepMergeImpl(target, source) { | ||
| export function deepMergeImpl(target, source, shouldOverwriteUndefined) { | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- The result is expected to include properties from both target and source, | ||
| but initially only target is spread in, so a cast is needed. */ | ||
| -- Result will include properties from both T and S, but starts with only T */ | ||
| const result = { ...target }; | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- TypeScript cannot infer the correct union of string and symbol keys, but all keys come from U */ | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- All keys come from S, TypeScript can't infer the union of string and symbol keys */ | ||
| const keys = [ | ||
@@ -24,11 +23,14 @@ ...Object.keys(source), | ||
| if (isObject(source[key]) && | ||
| // Only merge recursively objects that are not class instances | ||
| // Only merge plain objects, not class instances | ||
| Object.getPrototypeOf(source[key]) === Object.prototype) { | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- The call signature expects the second argument to be of type U; the type is correct, but TypeScript can't infer it here. */ | ||
| result[key] = deepMergeImpl(result[key] ?? {}, source[key]); | ||
| -- result[key] will have the correct type after assignment but TS can't infer it */ | ||
| result[key] = deepMergeImpl(result[key] ?? {}, | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- source[key] is known to be from S but TS can't infer it */ | ||
| source[key], shouldOverwriteUndefined); | ||
| } | ||
| else { | ||
| else if (shouldOverwriteUndefined || source[key] !== undefined) { | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- Cast required because TypeScript can't guarantee that a dynamic key from `U` exists in `T & U` or has the correct value type. */ | ||
| -- result[key] will have the correct type after assignment but TS can't infer it */ | ||
| result[key] = source[key]; | ||
@@ -35,0 +37,0 @@ } |
+13
-5
@@ -21,8 +21,13 @@ /** | ||
| * - Arrays or `undefined` values are not valid inputs. | ||
| * - Functions: If a function exists in both the target and source, the source function overwrites the target. | ||
| * - Symbol properties: Symbol-keyed properties are merged just like string keys. | ||
| * - Class instances: Class instances are not merged recursively. If a class instance exists in the source, it will replace the one in the target. | ||
| * - Functions: If a function exists in both the target and source, the source | ||
| * function overwrites the target. | ||
| * - Symbol properties: Symbol-keyed properties are merged just like string | ||
| * keys. | ||
| * - Class instances: Class instances are not merged recursively. If a class | ||
| * instance exists in the source, it will replace the one in the target. | ||
| * | ||
| * @param target The target object to merge into. | ||
| * @param source The source object to merge from. | ||
| * @param shouldOverwriteUndefined If true, properties with `undefined` values | ||
| * in the source will overwrite those in the target. Default is true. | ||
| * @returns A new object containing the deeply merged properties. | ||
@@ -33,5 +38,8 @@ * | ||
| * | ||
| * deepMerge({ a: { fn: () => "from target" } }, { a: { fn: () => "from source" } }) // => { a: { fn: () => "from source" } } | ||
| * deepMerge( | ||
| * { a: { fn: () => "from target" } }, | ||
| * { a: { fn: () => "from source" } } | ||
| * ) // => { a: { fn: () => "from source" } } | ||
| */ | ||
| export declare function deepMerge<T extends object, U extends object>(target: T, source: U): T & U; | ||
| export declare function deepMerge<T extends object, U extends object>(target: T, source: U, shouldOverwriteUndefined?: boolean): T & U; | ||
| /** | ||
@@ -38,0 +46,0 @@ * Checks if a value is an object. This function returns false for arrays. |
+14
-6
@@ -28,8 +28,13 @@ import { deepMergeImpl, getDeepCloneFunction } from "./internal/lang.js"; | ||
| * - Arrays or `undefined` values are not valid inputs. | ||
| * - Functions: If a function exists in both the target and source, the source function overwrites the target. | ||
| * - Symbol properties: Symbol-keyed properties are merged just like string keys. | ||
| * - Class instances: Class instances are not merged recursively. If a class instance exists in the source, it will replace the one in the target. | ||
| * - Functions: If a function exists in both the target and source, the source | ||
| * function overwrites the target. | ||
| * - Symbol properties: Symbol-keyed properties are merged just like string | ||
| * keys. | ||
| * - Class instances: Class instances are not merged recursively. If a class | ||
| * instance exists in the source, it will replace the one in the target. | ||
| * | ||
| * @param target The target object to merge into. | ||
| * @param source The source object to merge from. | ||
| * @param shouldOverwriteUndefined If true, properties with `undefined` values | ||
| * in the source will overwrite those in the target. Default is true. | ||
| * @returns A new object containing the deeply merged properties. | ||
@@ -40,6 +45,9 @@ * | ||
| * | ||
| * deepMerge({ a: { fn: () => "from target" } }, { a: { fn: () => "from source" } }) // => { a: { fn: () => "from source" } } | ||
| * deepMerge( | ||
| * { a: { fn: () => "from target" } }, | ||
| * { a: { fn: () => "from source" } } | ||
| * ) // => { a: { fn: () => "from source" } } | ||
| */ | ||
| export function deepMerge(target, source) { | ||
| return deepMergeImpl(target, source); | ||
| export function deepMerge(target, source, shouldOverwriteUndefined = true) { | ||
| return deepMergeImpl(target, source, shouldOverwriteUndefined); | ||
| } | ||
@@ -46,0 +54,0 @@ /** |
+1
-1
| { | ||
| "name": "@nomicfoundation/hardhat-utils", | ||
| "version": "3.0.4", | ||
| "version": "3.0.5", | ||
| "description": "Utilities for Hardhat and its plugins", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-utils", |
+21
-16
@@ -16,17 +16,17 @@ import type rfdcT from "rfdc"; | ||
| export function deepMergeImpl<T extends object, U extends object>( | ||
| export function deepMergeImpl<T extends object, S extends object>( | ||
| target: T, | ||
| source: U, | ||
| ): T & U { | ||
| source: S, | ||
| shouldOverwriteUndefined: boolean, | ||
| ): T & S { | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- The result is expected to include properties from both target and source, | ||
| but initially only target is spread in, so a cast is needed. */ | ||
| const result = { ...target } as T & U; | ||
| -- Result will include properties from both T and S, but starts with only T */ | ||
| const result = { ...target } as T & S; | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- TypeScript cannot infer the correct union of string and symbol keys, but all keys come from U */ | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- All keys come from S, TypeScript can't infer the union of string and symbol keys */ | ||
| const keys = [ | ||
| ...Object.keys(source), | ||
| ...Object.getOwnPropertySymbols(source), | ||
| ] as Array<keyof U>; | ||
| ] as Array<keyof S>; | ||
@@ -36,13 +36,18 @@ for (const key of keys) { | ||
| isObject(source[key]) && | ||
| // Only merge recursively objects that are not class instances | ||
| // Only merge plain objects, not class instances | ||
| Object.getPrototypeOf(source[key]) === Object.prototype | ||
| ) { | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- The call signature expects the second argument to be of type U; the type is correct, but TypeScript can't infer it here. */ | ||
| result[key] = deepMergeImpl(result[key] ?? {}, source[key] as U) as (T & | ||
| U)[Extract<keyof U, string>]; | ||
| } else { | ||
| -- result[key] will have the correct type after assignment but TS can't infer it */ | ||
| result[key] = deepMergeImpl( | ||
| result[key] ?? {}, | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- source[key] is known to be from S but TS can't infer it */ | ||
| source[key] as S, | ||
| shouldOverwriteUndefined, | ||
| ) as (T & S)[Extract<keyof S, string>]; | ||
| } else if (shouldOverwriteUndefined || source[key] !== undefined) { | ||
| /* eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
| -- Cast required because TypeScript can't guarantee that a dynamic key from `U` exists in `T & U` or has the correct value type. */ | ||
| result[key] = source[key] as (T & U)[Extract<keyof U, string>]; | ||
| -- result[key] will have the correct type after assignment but TS can't infer it */ | ||
| result[key] = source[key] as (T & S)[Extract<keyof S, string>]; | ||
| } | ||
@@ -49,0 +54,0 @@ } |
+14
-5
@@ -33,8 +33,13 @@ import { deepMergeImpl, getDeepCloneFunction } from "./internal/lang.js"; | ||
| * - Arrays or `undefined` values are not valid inputs. | ||
| * - Functions: If a function exists in both the target and source, the source function overwrites the target. | ||
| * - Symbol properties: Symbol-keyed properties are merged just like string keys. | ||
| * - Class instances: Class instances are not merged recursively. If a class instance exists in the source, it will replace the one in the target. | ||
| * - Functions: If a function exists in both the target and source, the source | ||
| * function overwrites the target. | ||
| * - Symbol properties: Symbol-keyed properties are merged just like string | ||
| * keys. | ||
| * - Class instances: Class instances are not merged recursively. If a class | ||
| * instance exists in the source, it will replace the one in the target. | ||
| * | ||
| * @param target The target object to merge into. | ||
| * @param source The source object to merge from. | ||
| * @param shouldOverwriteUndefined If true, properties with `undefined` values | ||
| * in the source will overwrite those in the target. Default is true. | ||
| * @returns A new object containing the deeply merged properties. | ||
@@ -45,3 +50,6 @@ * | ||
| * | ||
| * deepMerge({ a: { fn: () => "from target" } }, { a: { fn: () => "from source" } }) // => { a: { fn: () => "from source" } } | ||
| * deepMerge( | ||
| * { a: { fn: () => "from target" } }, | ||
| * { a: { fn: () => "from source" } } | ||
| * ) // => { a: { fn: () => "from source" } } | ||
| */ | ||
@@ -51,4 +59,5 @@ export function deepMerge<T extends object, U extends object>( | ||
| source: U, | ||
| shouldOverwriteUndefined: boolean = true, | ||
| ): T & U { | ||
| return deepMergeImpl(target, source); | ||
| return deepMergeImpl(target, source, shouldOverwriteUndefined); | ||
| } | ||
@@ -55,0 +64,0 @@ |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
439541
0.33%8663
0.37%