@nomicfoundation/hardhat-utils
Advanced tools
+6
-0
| # @nomicfoundation/hardhat-utils | ||
| ## 3.0.6 | ||
| ### Patch Changes | ||
| - 2bc18b2: Bumped `viem` version across all packages [7861](https://github.com/NomicFoundation/hardhat/pull/7861). | ||
| ## 3.0.5 | ||
@@ -4,0 +10,0 @@ |
@@ -20,3 +20,3 @@ import { CustomError } from "../error.js"; | ||
| export declare class IsDirectoryError extends CustomError { | ||
| constructor(filePath: string, cause: Error); | ||
| constructor(filePath: string, cause: Error | undefined); | ||
| } | ||
@@ -23,0 +23,0 @@ export declare class DirectoryNotEmptyError extends CustomError { |
+8
-0
@@ -537,2 +537,10 @@ import fsPromises from "node:fs/promises"; | ||
| export async function copy(source, destination) { | ||
| // We must proactively check if the source is a directory. | ||
| // On modern Linux kernels (6.x+), the `copy_file_range` system call used by | ||
| // Node.js may return success (0 bytes copied) when the source is a directory | ||
| // instead of throwing EISDIR. Node.js interprets this 0-byte success as a | ||
| // completed operation, resulting in no error being thrown. | ||
| if (await isDirectory(source)) { | ||
| throw new IsDirectoryError(source, undefined); | ||
| } | ||
| try { | ||
@@ -539,0 +547,0 @@ await fsPromises.copyFile(source, destination); |
| export declare function getDeepCloneFunction(): Promise<(<T>(input: T) => T)>; | ||
| export declare function deepMergeImpl<T extends object, S extends object>(target: T, source: S, shouldOverwriteUndefined: boolean): T & S; | ||
| /** | ||
| * Performs a custom deep equality check using `fast-equals` with specific overrides. | ||
| * | ||
| * @param x The first value to compare. | ||
| * @param y The second value to compare. | ||
| * @returns A promise that resolves to true if the values are deeply equal, false otherwise. | ||
| */ | ||
| export declare function customFastEqual<T>(x: T, y: T): Promise<boolean>; | ||
| //# sourceMappingURL=lang.d.ts.map |
@@ -39,2 +39,32 @@ import { isObject } from "../lang.js"; | ||
| } | ||
| let cachedCustomEqual; | ||
| /** | ||
| * Performs a custom deep equality check using `fast-equals` with specific overrides. | ||
| * | ||
| * @param x The first value to compare. | ||
| * @param y The second value to compare. | ||
| * @returns A promise that resolves to true if the values are deeply equal, false otherwise. | ||
| */ | ||
| export async function customFastEqual(x, y) { | ||
| if (cachedCustomEqual !== undefined) { | ||
| return cachedCustomEqual(x, y); | ||
| } | ||
| const { createCustomEqual } = await import("fast-equals"); | ||
| cachedCustomEqual = createCustomEqual({ | ||
| createCustomConfig: (defaultConfig) => ({ | ||
| areTypedArraysEqual: (a, b, state) => { | ||
| // Node.js uses an internal pool for small Buffers, so multiple Buffers can | ||
| // share the same underlying ArrayBuffer while having different byteOffsets. | ||
| // Structural equality checks (e.g. deep equality) consider offset and length | ||
| // and may fail even if the contents are identical. | ||
| // We use Buffer.equals() to compare content only. | ||
| if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) { | ||
| return a.equals(b); | ||
| } | ||
| return defaultConfig.areTypedArraysEqual(a, b, state); | ||
| }, | ||
| }), | ||
| }); | ||
| return cachedCustomEqual(x, y); | ||
| } | ||
| //# sourceMappingURL=lang.js.map |
+2
-3
@@ -1,2 +0,2 @@ | ||
| import { deepMergeImpl, getDeepCloneFunction } from "./internal/lang.js"; | ||
| import { customFastEqual, deepMergeImpl, getDeepCloneFunction, } from "./internal/lang.js"; | ||
| /** | ||
@@ -20,4 +20,3 @@ * Creates a deep clone of the provided value. | ||
| export async function deepEqual(x, y) { | ||
| const { deepEqual: _deepEqual } = await import("fast-equals"); | ||
| return _deepEqual(x, y); | ||
| return customFastEqual(x, y); | ||
| } | ||
@@ -24,0 +23,0 @@ /** |
+3
-3
| { | ||
| "name": "@nomicfoundation/hardhat-utils", | ||
| "version": "3.0.5", | ||
| "version": "3.0.6", | ||
| "description": "Utilities for Hardhat and its plugins", | ||
@@ -58,3 +58,3 @@ "homepage": "https://github.com/nomicfoundation/hardhat/tree/v-next/v-next/hardhat-utils", | ||
| "@types/debug": "^4.1.7", | ||
| "@types/node": "^20.14.9", | ||
| "@types/node": "^22.0.0", | ||
| "c8": "^9.1.0", | ||
@@ -73,3 +73,3 @@ "eslint": "9.25.1", | ||
| "ethereum-cryptography": "^2.2.1", | ||
| "fast-equals": "^5.0.1", | ||
| "fast-equals": "^5.4.0", | ||
| "json-stream-stringify": "^3.1.6", | ||
@@ -76,0 +76,0 @@ "rfdc": "^1.3.1", |
+1
-1
@@ -38,3 +38,3 @@ import { CustomError } from "../error.js"; | ||
| export class IsDirectoryError extends CustomError { | ||
| constructor(filePath: string, cause: Error) { | ||
| constructor(filePath: string, cause: Error | undefined) { | ||
| super(`Path ${filePath} is a directory`, cause); | ||
@@ -41,0 +41,0 @@ } |
+9
-0
@@ -645,2 +645,11 @@ import type { JsonTypes, ParsedElementInfo } from "@streamparser/json-node"; | ||
| export async function copy(source: string, destination: string): Promise<void> { | ||
| // We must proactively check if the source is a directory. | ||
| // On modern Linux kernels (6.x+), the `copy_file_range` system call used by | ||
| // Node.js may return success (0 bytes copied) when the source is a directory | ||
| // instead of throwing EISDIR. Node.js interprets this 0-byte success as a | ||
| // completed operation, resulting in no error being thrown. | ||
| if (await isDirectory(source)) { | ||
| throw new IsDirectoryError(source, undefined); | ||
| } | ||
| try { | ||
@@ -647,0 +656,0 @@ await fsPromises.copyFile(source, destination); |
+36
-0
@@ -56,1 +56,37 @@ import type rfdcT from "rfdc"; | ||
| } | ||
| let cachedCustomEqual: ((a: unknown, b: unknown) => boolean) | undefined; | ||
| /** | ||
| * Performs a custom deep equality check using `fast-equals` with specific overrides. | ||
| * | ||
| * @param x The first value to compare. | ||
| * @param y The second value to compare. | ||
| * @returns A promise that resolves to true if the values are deeply equal, false otherwise. | ||
| */ | ||
| export async function customFastEqual<T>(x: T, y: T): Promise<boolean> { | ||
| if (cachedCustomEqual !== undefined) { | ||
| return cachedCustomEqual(x, y); | ||
| } | ||
| const { createCustomEqual } = await import("fast-equals"); | ||
| cachedCustomEqual = createCustomEqual({ | ||
| createCustomConfig: (defaultConfig) => ({ | ||
| areTypedArraysEqual: (a, b, state) => { | ||
| // Node.js uses an internal pool for small Buffers, so multiple Buffers can | ||
| // share the same underlying ArrayBuffer while having different byteOffsets. | ||
| // Structural equality checks (e.g. deep equality) consider offset and length | ||
| // and may fail even if the contents are identical. | ||
| // We use Buffer.equals() to compare content only. | ||
| if (Buffer.isBuffer(a) && Buffer.isBuffer(b)) { | ||
| return a.equals(b); | ||
| } | ||
| return defaultConfig.areTypedArraysEqual(a, b, state); | ||
| }, | ||
| }), | ||
| }); | ||
| return cachedCustomEqual(x, y); | ||
| } |
+6
-4
@@ -1,2 +0,6 @@ | ||
| import { deepMergeImpl, getDeepCloneFunction } from "./internal/lang.js"; | ||
| import { | ||
| customFastEqual, | ||
| deepMergeImpl, | ||
| getDeepCloneFunction, | ||
| } from "./internal/lang.js"; | ||
@@ -23,5 +27,3 @@ /** | ||
| export async function deepEqual<T>(x: T, y: T): Promise<boolean> { | ||
| const { deepEqual: _deepEqual } = await import("fast-equals"); | ||
| return _deepEqual(x, y); | ||
| return customFastEqual(x, y); | ||
| } | ||
@@ -28,0 +30,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
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
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
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
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
444500
1.13%8749
0.99%44
-2.22%Updated