npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

getinto

v0.1.1

Published

A simple JS package to access a value in a object

Readme

getinto

getinto is a simple package to deep get something in an object, array and function.
If not exist, return undefined. Never a error.
Say bye for the error "Cannot read property of undefined".

  • Simple sintax
  • Javascript and TypeScript compatibility
  • Can be used with object chain, function chain and array chain mixed

Quick Example

const into = require('getinto')
const pets: [
  {
    name: 'Rex',
    owner: {
      name: 'Jon',
      address: {
        country: 'Canada',
        province: 'British Columbia'
      }
    }
  },
  {
    ...
  }
]

const ownerProvince = into('pets', 0)
    .into('owner')
    .into('address')
    .get('province') //the get method return an array, function, object, string, number... or undefined. Never a error.
console.log(ownerProvince) //log: 'British Columbia'

//with Vanilla JS
const errorPetName = animals.notExist.name //errror: Cannot read property 'name' of undefined
//with getinto package
const petName = into(animals)
    .into('notExist')
    .get('name') 
console.log(petName) //log: undefined. Never a error.

Installation

$ npm install getinto
or
$ yarn add getinto

Usage

I suggest the following import:

const into = require('getinto')

You can write a chan of 'into'. The first into comes from import and receive an object (or a function, see in 'More examples' or in 'API' for details).
The nexts intos come from previous into. The latter statement must be 'get'.
THe get method always return an array, function, string, object... or undefined. Never a error (if you use the correct syntax).

const value = into(object)
  .into('objectProperty')
  .into('nextObjectProperty')
  ...
  ...
  .into('aIndex')
  .get('returnedProperty')
console.log(value) //log: valueOfreturnedProperty

Typescript Usage

I suggest the following import:

import into from 'getinto'

getinto has the same usage for Typescript but, you can to specify the return type on get method.

into(someObject)
  .get('someProperty')<T>

More Examples

const into = require('getinto')
const business = {
 stories: [
  {
    companyName: 'megaPet, INC',
    products: ['dogFood', 'dogBed'],
    stack: ['react', 'node.js', 'mongoDB'],
    doSomething: function (name) {console.log(name + ' says Hello World')}
  },
  {
    companyName: function (baseName) { return baseName + ', INC' },
    products: function (a, b) { return [a + 'Product', b + 'Product']},
    doSomething: function () {console.log('Hello World')}
  }
 ]
}

business.notExist.techs[0] //error: Cannot read property 'techs' of undefined
into(business)
  .into('notExist')
  .get('techs', 0) //undefined
   
into(business)
  .into('stories', 0)
  .get('companyName') // 'megaPet, INC' - if something don't exist return undefined

into(business)
  .into('stories', 0)
  .get('products') // ['dogFood', 'dogBed'] - if something don't exist return undefined
  
into(business)
  .into('stories', 0)
  .get('stack', 1) // 'node.js' - if something don't exist return undefined
  
const functionExample = into(business)
  .into('stories', 0)
  .get('doSomething')
  functionExample('Jonathan') //log: 'Jonathan says Hello World' - if something don't exist return undefined
  
into(business)
  .into('stories', 1)
  .get('companyName', 'superMarket') // 'superMarket, INC' - executed like companyName('superMarket')

const productA = 'fishmonger'  
into(business)
  .into('stories', 1)
  .get('products', [productA, 'bakery']) // ['fishmongerProduct', 'bakeryProduct'] - executed like products(productA, 'bakery')
  
into(business)
  .into('stories', 1)
  .get('doSomething', []) //log: 'Hello World - executed like doSomething()
}

API

• First into

into(entry: Function | Object | Array<any>, params?: any | any[], thisArg?: object): GetintoObject
  • if entry is an object or any dictionary, you can select a property to continue the chain passing its name as string in params;
  • if entry is an array, you can select an item to continue the chain passsaing its position as number or string in params;
  • if entry is a function, you can select the function return to continue the chain passaing one param or many params in an array for the function be execute. Use [] (empty array) to execute with no one param.

• Nexts into

into(key: string | number, params?: any | any[]): GetintoObject
  • key can be a property name as string or can be a index as string or number;
  • if the key return an object or any dictionary, you can select a property to continue the chain passing its name as string in params;
  • if the key return an array, you can select an item to continue the chain passsaing its position as number or string in params;
  • if the key return a function, you can select the function return to continue the chain passaing param or array of params for the function be execute. Use [] (empty array) to execute with no one param.

• get

get<T>(key: string | number, params?: any | any[], callback?: (gotten: T) => any): T
  • key can be a property name as string or can be a index as string or number
  • if the key return an object or any dictionary, you can get a property passing its name as string in params;
  • if the key return an array, you can get an item passsaing its position as number or string in params.
  • if you are using typescript, can to specify the type of get return
  • if the key return a function, you can get the function return to continue the chain passaing param or array of params for the function be execute. Use [] (empty array) to execute with no one param.

Tests

We use Jest to test this package.

  • Many mixed tests: ok
  • Specific Arrays tests: ok
  • Specific Objects tests: doing
  • Specific funcctions tests: doing

Releases

v0.1.0
Index as number
Improved array and function support
Added tests
Other fixes
v0.0.2
Import fixs
v0.0.1
Inicial idea

To-do

  • Function tests
  • Obkject tests
  • More examples
  • Search for bugs

array example

Writing

object example

Writing

function example

Writing