Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
@hapi/hoek
Advanced tools
The @hapi/hoek package is a utility module for the hapi ecosystem, providing a set of common function helpers that are used across multiple hapi modules. It includes functions for manipulating objects, arrays, and other types, as well as utility functions for assertions, cloning, merging, and more.
Object Cloning
Creates a deep clone of an object, ensuring that nested objects are also cloned rather than just copying their references.
const Hoek = require('@hapi/hoek');
const obj = { a: 1, b: { c: 2 } };
const clone = Hoek.clone(obj);
Object Merging
Merges all the properties of the source object into the target object. This is a deep merge operation.
const Hoek = require('@hapi/hoek');
const target = { a: 1 };
const source = { b: 2 };
Hoek.merge(target, source);
Assertion
Throws an error if the condition is not true. Useful for adding assertions in your code to ensure that certain conditions are met.
const Hoek = require('@hapi/hoek');
Hoek.assert(1 === 1, 'This will not throw.');
Hoek.assert(1 === 2, 'This will throw an error.');
Reach
Allows you to access a nested property within an object using a string path.
const Hoek = require('@hapi/hoek');
const obj = { a: { b: { c: 1 } } };
const value = Hoek.reach(obj, 'a.b.c');
Apply To Defaults
Applies a set of default keys and values to an object, only adding values if they are not already present in the object.
const Hoek = require('@hapi/hoek');
const defaults = { a: 1, b: 2 };
const options = { b: 3, c: 4 };
const result = Hoek.applyToDefaults(defaults, options);
Lodash is a comprehensive utility library offering a wide range of functions for tasks such as object manipulation, array manipulation, string manipulation, and more. It is similar to @hapi/hoek but has a broader scope and a larger API surface.
Underscore.js is another utility library that provides functional programming helpers for JavaScript. It is similar to @hapi/hoek in providing utilities for working with objects and arrays but is not tailored specifically to the hapi ecosystem.
Ramda is a functional programming library that focuses on immutability and pure functions. While it provides many utilities similar to those in @hapi/hoek, Ramda emphasizes a functional programming paradigm.
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 or underscore.
Lead Maintainer: Gil Pedersen
FAQs
General purpose node utilities
The npm package @hapi/hoek receives a total of 9,524,951 weekly downloads. As such, @hapi/hoek popularity was classified as popular.
We found that @hapi/hoek demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.