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

@blakek/make-lookup

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blakek/make-lookup

📒 Make a lookup object from an array of objects

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

make-lookup

📒 Make a lookup object from an array of objects

Takes a list of items in an array an changes it to an object for fast access.

Install

Using Yarn:

$ yarn add @blakek/make-lookup

…or using npm:

$ npm i --save @blakek/make-lookup

Usage

import { makeLookup } from '@blakek/make-lookup';

const users = [
  { sites: { github: { username: 'blakek' } } },
  { sites: { github: { username: 'gsandf' } } },
  { sites: { github: { username: 'google' } } }
];

const usersByUsername = makeLookup(users, 'sites.github.username');

console.log(usersByUsername.blakek);
// => { sites: { github: { username: 'blakek' } } }

API

makeLookup

function makeLookup<T>(
  inputArray: any[],
  lookupProperty: Array<number | string> | string;
): Record<string, T>;

Creates a lookup object for a given array.

lookupProperty is a path to the property in either dot notation or an array of path parts. See blakek/deep for details on this path.

Contributing

Node.js and Yarn are required to work with this project.

To install all dependencies, run:

yarn

Useful Commands

yarn buildBuilds the project to ./dist
yarn formatFormat the source following the Prettier styles
yarn testRun project tests
yarn test --watchRun project tests, watching for file changes

License

MIT

Keywords

FAQs

Package last updated on 02 Jun 2020

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