Socket
Socket
Sign inDemoInstall

@hapi/hoek

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hapi/hoek - npm Package Compare versions

Comparing version 8.2.4 to 8.2.5

11

lib/deepEqual.js

@@ -240,2 +240,3 @@ 'use strict';

let skipped = 0;
for (const key of objKeys) {

@@ -245,2 +246,6 @@ if (options.skip &&

if (ref[key] === undefined) {
++skipped;
}
continue;

@@ -258,2 +263,8 @@ }

if (!options.part &&
objKeys.length - skipped !== keys(ref).length) {
return false;
}
// Check symbols

@@ -260,0 +271,0 @@

460

lib/index.d.ts
/**
Performs a deep comparison of the two values including support for circular dependencies, prototype, and enumerable properties.
@param obj - The value being compared.
@param ref - The reference value used for comparison.
@return true when the two values are equal, otherwise false.
* Performs a deep comparison of the two values including support for circular dependencies, prototype, and enumerable properties.
*
* @param obj - The value being compared.
* @param ref - The reference value used for comparison.
*
* @return true when the two values are equal, otherwise false.
*/
export function deepEqual(obj: any, ref: any, options?: deepEqual.Options): boolean;
declare namespace deepEqual {
export namespace deepEqual {

@@ -16,34 +16,34 @@ interface Options {

/**
Compare functions with difference references by comparing their internal code and properties.
@default false
*/
* Compare functions with difference references by comparing their internal code and properties.
*
* @default false
*/
readonly deepFunction?: boolean;
/**
Allow partial match.
@default false
*/
* Allow partial match.
*
* @default false
*/
readonly part?: boolean;
/**
Compare the objects' prototypes.
@default true
*/
* Compare the objects' prototypes.
*
* @default true
*/
readonly prototype?: boolean;
/**
List of object keys to ignore different values of.
@default null
*/
* List of object keys to ignore different values of.
*
* @default null
*/
readonly skip?: (string | symbol)[];
/**
Compare symbol properties.
@default true
*/
* Compare symbol properties.
*
* @default true
*/
readonly symbols?: boolean;

@@ -55,12 +55,12 @@ }

/**
Clone any value, object, or array.
@param obj - The value being cloned.
@param options - Optional settings.
@returns A deep clone of `obj`.
*/
* Clone any value, object, or array.
*
* @param obj - The value being cloned.
* @param options - Optional settings.
*
* @returns A deep clone of `obj`.
*/
export function clone<T>(obj: T, options?: clone.Options): T;
declare namespace clone {
export namespace clone {

@@ -70,20 +70,20 @@ interface Options {

/**
Clone the object's prototype.
@default true
*/
* Clone the object's prototype.
*
* @default true
*/
readonly prototype?: boolean;
/**
Include symbol properties.
@default true
*/
* Include symbol properties.
*
* @default true
*/
readonly symbols?: boolean;
/**
Shallow clone the specified keys.
@default undefined
*/
* Shallow clone the specified keys.
*
* @default undefined
*/
readonly shallow?: string[] | string[][] | boolean;

@@ -95,13 +95,13 @@ }

/**
Merge all the properties of source into target.
@param target - The object being modified.
@param source - The object used to copy properties from.
@param options - Optional settings.
@returns The `target` object.
*/
* Merge all the properties of source into target.
*
* @param target - The object being modified.
* @param source - The object used to copy properties from.
* @param options - Optional settings.
*
* @returns The `target` object.
*/
export function merge<T1 extends object, T2 extends object>(target: T1, source: T2, options?: merge.Options): T1 & T2;
declare namespace merge {
export namespace merge {

@@ -111,20 +111,20 @@ interface Options {

/**
When true, null value from `source` overrides existing value in `target`.
@default true
*/
* When true, null value from `source` overrides existing value in `target`.
*
* @default true
*/
readonly nullOverride?: boolean;
/**
When true, array value from `source` is merged with the existing value in `target`.
@default false
*/
* When true, array value from `source` is merged with the existing value in `target`.
*
* @default false
*/
readonly mergeArrays?: boolean;
/**
Compare symbol properties.
@default true
*/
* Compare symbol properties.
*
* @default true
*/
readonly symbols?: boolean;

@@ -136,13 +136,13 @@ }

/**
Apply source to a copy of the defaults.
@param defaults - An object with the default values to use of `options` does not contain the same keys.
@param source - The source used to override the `defaults`.
@param options - Optional settings.
@returns A copy of `defaults` with `source` keys overriding any conflicts.
*/
* Apply source to a copy of the defaults.
*
* @param defaults - An object with the default values to use of `options` does not contain the same keys.
* @param source - The source used to override the `defaults`.
* @param options - Optional settings.
*
* @returns A copy of `defaults` with `source` keys overriding any conflicts.
*/
export function applyToDefaults<T extends object>(defaults: Partial<T>, source: Partial<T> | boolean | null, options?: applyToDefaults.Options): Partial<T>;
declare namespace applyToDefaults {
export namespace applyToDefaults {

@@ -152,13 +152,13 @@ interface Options {

/**
When true, null value from `source` overrides existing value in `target`.
@default true
*/
* When true, null value from `source` overrides existing value in `target`.
*
* @default true
*/
readonly nullOverride?: boolean;
/**
Shallow clone the specified keys.
@default undefined
*/
* Shallow clone the specified keys.
*
* @default undefined
*/
readonly shallow?: string[] | string[][];

@@ -170,14 +170,14 @@ }

/**
Find the common unique items in two arrays.
@param array1 - The first array to compare.
@param array2 - The second array to compare.
@param options - Optional settings.
@return - An array of the common items. If `justFirst` is true, returns the first common item.
*/
* Find the common unique items in two arrays.
*
* @param array1 - The first array to compare.
* @param array2 - The second array to compare.
* @param options - Optional settings.
*
* @return - An array of the common items. If `justFirst` is true, returns the first common item.
*/
export function intersect<T1, T2>(array1: intersect.Array<T1>, array2: intersect.Array<T2>, options?: intersect.Options): Array<T1 | T2>;
export function intersect<T1, T2>(array1: intersect.Array<T1>, array2: intersect.Array<T2>, options?: intersect.Options): T1 | T2;
declare namespace intersect {
export namespace intersect {

@@ -189,6 +189,6 @@ type Array<T> = ArrayLike<T> | Set<T> | null;

/**
When true, return the first overlapping value.
@default false
*/
* When true, return the first overlapping value.
*
* @default false
*/
readonly first?: boolean;

@@ -200,9 +200,9 @@ }

/**
Checks if the reference value contains the provided values.
@param ref - The reference string, array, or object.
@param values - A single or array of values to find within `ref`. If `ref` is an object, `values` can be a key name, an array of key names, or an object with key-value pairs to compare.
@return true if the value contains the provided values, otherwise false.
*/
* Checks if the reference value contains the provided values.
*
* @param ref - The reference string, array, or object.
* @param values - A single or array of values to find within `ref`. If `ref` is an object, `values` can be a key name, an array of key names, or an object with key-value pairs to compare.
*
* @return true if the value contains the provided values, otherwise false.
*/
export function contain(ref: string, values: string | string[], options?: contain.Options): boolean;

@@ -212,3 +212,3 @@ export function contain(ref: any[], values: any, options?: contain.Options): boolean;

declare namespace contain {
export namespace contain {

@@ -218,34 +218,34 @@ interface Options {

/**
Perform a deep comparison.
@default false
*/
* Perform a deep comparison.
*
* @default false
*/
readonly deep?: boolean;
/**
Allow only one occurrence of each value.
@default false
*/
* Allow only one occurrence of each value.
*
* @default false
*/
readonly once?: boolean;
/**
Allow only values explicitly listed.
@default false
*/
* Allow only values explicitly listed.
*
* @default false
*/
readonly only?: boolean;
/**
Allow partial match.
@default false
*/
* Allow partial match.
*
* @default false
*/
readonly part?: boolean;
/**
Include symbol properties.
@default true
*/
* Include symbol properties.
*
* @default true
*/
readonly symbols?: boolean;

@@ -257,9 +257,9 @@ }

/**
Flatten an array with sub arrays
@param array - an array of items or other arrays to flatten.
@param target - if provided, an array to shallow copy the flattened `array` items to
@return a flat array of the provided values (appended to `target` is provided).
*/
* Flatten an array with sub arrays
*
* @param array - an array of items or other arrays to flatten.
* @param target - if provided, an array to shallow copy the flattened `array` items to
*
* @return a flat array of the provided values (appended to `target` is provided).
*/
export function flatten<T>(array: ArrayLike<T | ReadonlyArray<T>>, target?: ArrayLike<T | ReadonlyArray<T>>): T[];

@@ -269,12 +269,12 @@

/**
Convert an object key chain string to reference.
@param obj - the object from which to look up the value.
@param chain - the string path of the requested value. The chain string is split into key names using `options.separator`, or an array containing each individual key name. A chain including negative numbers will work like negative indices on an array.
@return The value referenced by the chain if found, otherwise undefined. If chain is null, undefined, or false, the object itself will be returned.
*/
* Convert an object key chain string to reference.
*
* @param obj - the object from which to look up the value.
* @param chain - the string path of the requested value. The chain string is split into key names using `options.separator`, or an array containing each individual key name. A chain including negative numbers will work like a negative index on an array.
*
* @return The value referenced by the chain if found, otherwise undefined. If chain is null, undefined, or false, the object itself will be returned.
*/
export function reach(obj: object | null, chain: string | (string | number)[] | false | null | undefined, options?: reach.Options): any;
declare namespace reach {
export namespace reach {

@@ -284,34 +284,34 @@ interface Options {

/**
String to split chain path on. Defaults to '.'.
@default false
*/
* String to split chain path on. Defaults to '.'.
*
* @default false
*/
readonly separator?: string;
/**
Value to return if the path or value is not present. No default value.
@default false
*/
* Value to return if the path or value is not present. No default value.
*
* @default false
*/
readonly default?: any;
/**
If true, will throw an error on missing member in the chain. Default to false.
@default false
*/
* If true, will throw an error on missing member in the chain. Default to false.
*
* @default false
*/
readonly strict?: boolean;
/**
If true, allows traversing functions for properties. false will throw an error if a function is part of the chain.
@default true
*/
* If true, allows traversing functions for properties. false will throw an error if a function is part of the chain.
*
* @default true
*/
readonly functions?: boolean;
/**
If true, allows traversing Set and Map objects for properties. false will return undefined regardless of the Set or Map passed.
@default false
*/
* If true, allows traversing Set and Map objects for properties. false will return undefined regardless of the Set or Map passed.
*
* @default false
*/
readonly iterables?: boolean;

@@ -323,9 +323,9 @@ }

/**
Replace string parameters (using format "{path.to.key}") with their corresponding object key values using `Hoek.reach()`.
@param obj - the object from which to look up the value.
@param template - the string containing {} enclosed key paths to be replaced.
@return The template string with the {} enclosed keys replaced with looked-up values.
*/
* Replace string parameters (using format "{path.to.key}") with their corresponding object key values using `Hoek.reach()`.
*
* @param obj - the object from which to look up the value.
* @param template - the string containing {} enclosed key paths to be replaced.
*
* @return The template string with the {} enclosed keys replaced with looked-up values.
*/
export function reachTemplate(obj: object | null, template: string, options?: reach.Options): string;

@@ -335,9 +335,9 @@

/**
Throw an error if condition is falsey.
@param condition - If `condition` is not truthy, an exception is thrown.
@param error - The error thrown if the condition fails.
@return Does not return a value but throws if the `condition` is falsey.
*/
* Throw an error if condition is falsy.
*
* @param condition - If `condition` is not truthy, an exception is thrown.
* @param error - The error thrown if the condition fails.
*
* @return Does not return a value but throws if the `condition` is falsy.
*/
export function assert(condition: any, error: Error): void;

@@ -347,9 +347,9 @@

/**
Throw an error if condition is falsey.
@param condition - If `condition` is not truthy, an exception is thrown.
@param args - Any number of values, concatenated together (space separated) to create the error message.
@return Does not return a value but throws if the `condition` is falsey.
*/
* Throw an error if condition is falsy.
*
* @param condition - If `condition` is not truthy, an exception is thrown.
* @param args - Any number of values, concatenated together (space separated) to create the error message.
*
* @return Does not return a value but throws if the `condition` is falsy.
*/
export function assert(condition: any, ...args: any): void;

@@ -359,3 +359,3 @@

/**
A benchmarking timer, using the internal node clock for maximum accuracy.
* A benchmarking timer, using the internal node clock for maximum accuracy.
*/

@@ -381,8 +381,8 @@ export class Bench {

/**
Escape string for Regex construction by prefixing all reserved characters with a backslash.
@param string - The string to be escaped.
@return The escaped string.
*/
* Escape string for Regex construction by prefixing all reserved characters with a backslash.
*
* @param string - The string to be escaped.
*
* @return The escaped string.
*/
export function escapeRegex(string: string): string;

@@ -392,8 +392,8 @@

/**
Escape string for usage as an attribute value in HTTP headers.
@param attribute - The string to be escaped.
@return The escaped string. Will throw on invalid characters that are not supported to be escaped.
*/
* Escape string for usage as an attribute value in HTTP headers.
*
* @param attribute - The string to be escaped.
*
* @return The escaped string. Will throw on invalid characters that are not supported to be escaped.
*/
export function escapeHeaderAttribute(attribute: string): string;

@@ -403,8 +403,8 @@

/**
Escape string for usage in HTML.
@param string - The string to be escaped.
@return The escaped string.
*/
* Escape string for usage in HTML.
*
* @param string - The string to be escaped.
*
* @return The escaped string.
*/
export function escapeHtml(string: string): string;

@@ -414,8 +414,8 @@

/**
Escape string for usage in JSON.
@param string - The string to be escaped.
@return The escaped string.
*/
* Escape string for usage in JSON.
*
* @param string - The string to be escaped.
*
* @return The escaped string.
*/
export function escapeJson(string: string): string;

@@ -425,7 +425,7 @@

/**
Wraps a function to ensure it can only execute once.
@param method - The function to be wrapped.
@return The wrapped function.
* Wraps a function to ensure it can only execute once.
*
* @param method - The function to be wrapped.
*
* @return The wrapped function.
*/

@@ -436,4 +436,4 @@ export function once<T extends Function>(method: T): T;

/**
A reusable no-op function.
*/
* A reusable no-op function.
*/
export function ignore(...ignore: any): void;

@@ -443,10 +443,10 @@

/**
Converts a JavaScript value to a JavaScript Object Notation (JSON) string with protection against thrown errors.
@param value A JavaScript value, usually an object or array, to be converted.
@param replacer The JSON.stringify() `replacer` argument.
@param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
@return The JSON string. If the operation fails, an error string value is returned (no exception thrown).
*/
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string with protection against thrown errors.
*
* @param value A JavaScript value, usually an object or array, to be converted.
* @param replacer The JSON.stringify() `replacer` argument.
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
*
* @return The JSON string. If the operation fails, an error string value is returned (no exception thrown).
*/
export function stringify(value: any, replacer?: any, space?: string | number): string;

@@ -456,8 +456,8 @@

/**
Returns a Promise that resolves after the requested timeout.
@param timeout - The number of milliseconds to wait before resolving the Promise.
@return A Promise.
*/
* Returns a Promise that resolves after the requested timeout.
*
* @param timeout - The number of milliseconds to wait before resolving the Promise.
*
* @return A Promise.
*/
export function wait(timeout?: number): Promise<void>;

@@ -467,4 +467,4 @@

/**
Returns a Promise that never resolves.
*/
* Returns a Promise that never resolves.
*/
export function block(): Promise<void>;
{
"name": "@hapi/hoek",
"description": "General purpose node utilities",
"version": "8.2.4",
"version": "8.2.5",
"repository": "git://github.com/hapijs/hoek",

@@ -6,0 +6,0 @@ "main": "lib/index.js",

@@ -1,14 +0,18 @@

<a href="http://hapijs.com"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
# hoek
# @hapi/hoek
Utility methods for the hapi ecosystem. This module is not intended to solve every problem for
everyone, but rather as a central place to store hapi-specific methods. If you're looking for a
general purpose utility module, check out [lodash](https://github.com/lodash/lodash) or
[underscore](https://github.com/jashkenas/underscore).
#### Utility methods for the hapi ecosystem.
[![Build Status](https://secure.travis-ci.org/hapijs/hoek.svg)](http://travis-ci.org/hapijs/hoek)
**boom** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) – they work even better together.
## Documentation
This module is not intended to solve every problem for everyone, but rather as a central place to store hapi-specific methods. If you're looking for a general purpose utility module, check out [lodash](https://github.com/lodash/lodash).
[**API Reference**](API.md)
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
## Useful resources
- [Documentation and API](https://hapi.dev/family/hoek/)
- [Version status](https://hapi.dev/resources/status/#hoek) (builds, dependencies, node versions, licenses, eol)
- [Project policies](https://hapi.dev/policies/)
- [Free and commercial support options](https://hapi.dev/support/)
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