Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hypefactors/js-get

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hypefactors/js-get

Retrieve deeply nested properties from mixed objects and arrays using dot notation.

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
3
Weekly downloads
 
Created
Source

JS-Get

A simple and lightweight dot-notiation based property resolver.

Build Status GitHub release npm

Contents

Why JS-Get

  • Lightweight, well-documented source code bundled as CJS, EM and UMD
  • 100% test coverage
  • Supports objects and arrays

Installation

To install JS-Get, just run the following:

$ npm install @hypefactors/js-get

Note: This package was only tested on Node.js versions 9 and 8 or higher.

Usage

Import the module via import get from '@hypefactors/js-get' or if you're not using a bundler use require instead (Node environment).

Given that there is an object with the following structure:

const profile = {
  age: 15,
  name: {
    first: 'John'
  },
  activities: [
    'sports',
    {
      name: 'fishing',
      frequency: 'weekly'
    }
  ]
}

The properties can be accessed using dot notation:

get(profile, 'age') // 15
get(profile, 'name.first') // 'John'
get(profile, 'activities[0]') // 'sports'
get(profile, 'activities.0') // 'sports'
get(profile, 'activities[1].frequency') // 'weekly'
get(profile, 'foobar', 'not-found') // 'not-found'

Contributing

Thanks for your interest in JS-Get! If you'd like to contribute, please read our contribution guide.

License

JS-Get is open-sourced software licensed under the ISC license. If you'd like to read the license agreement, click here.

Keywords

FAQs

Package last updated on 21 Apr 2018

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

  • 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