Socket
Book a DemoInstallSign in
Socket

diggerize

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diggerize

Fetch keys for object with a default or fail

latest
Source
npmnpm
Version
1.0.9
Version published
Maintainers
1
Created
Source

diggerize

Usage

Import the functions

const {dig, digg, digs} = require("diggerize")
import {dig, digg, digs} from "diggerize"

dig

Traverses through objects to find the given path.

const myObject = {
  people: [
    {
      firstName: "Kasper",
      lastName: "Nielsen"
    }
  ]
}

dig(myObject, "people", 0, "firstName") //=> "Kasper"
dig(myObject, "people", 1, "firstName") //=> null

digg

This functions like dig but it will fail if one of the keys isn't found.

const myObject = {
  people: [
    {
      firstName: "Kasper",
      lastName: "Nielsen"
    }
  ]
}

digg(myObject, "people", 0, "firstName") //=> "Kasper"
digg(myObject, "people", 1, "firstName") //=> Fails because 1 isn't found in the people array

digs

This will fail is object doesn't contain keys named firstKey and secondKey.

const {firstKey, secondKey} = digs(object, "firstKey", "secondKey")

FAQs

Package last updated on 27 May 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.