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 🙏

© 2024 – Pkg Stats / Ryan Hefner

array-hash-conversion

v1.1.0

Published

Converts arrays to object keys and values

Downloads

3

Readme

Array to Hash Conversion NPM Package

This is a module used to quickly and easily convert an array or arrays into a hash map. It supports uneven array lengths and incremental values.

Installation

  • Install the package

yarn add array-hash-conversion

  • Require the package

const arrayHashConversion = require('array-hash-conversion')

Changes

1.1 - Parameter Update

  • null is no longer required when only using keyArray and incStart

Usage

The function takes one argument and has two overloads.

arrayHashConversion(keyArray)

arrayHashConversion(keyArray, valueArray)

arrayHashConversion(keyArray, incStart = 0)

keyArray represents the array that will become the object keys and must not be null.

valueArray represents the array that will become the values.

incStart is the starting incrementing value that will become the value of all keys when not using valueArray.

If valueArray is less than keyArray, the values will be repeated once the length of keyArray is exceeded.

If only keyArray is supplied, values will be incremented starting at 0.

Examples

arrayHashConversion(['Name', 'Age', 'Location'], ['John Doe', 27, 'USA']) returns { Name: 'John Doe', Age: 27, Location: 'USA' }

arrayHashConversion(['Answer1', 'Answer2', 'Answer3', 'Answer4'], ['A', 'B']) returns { Answer1: 'A', Answer2: 'B', Answer3: 'A', Answer4: 'B' }

arrayHashConversion(['Key1', 'Key2', 'Key3']) returns { Key1: 0, Key2: 1, Key3: 2 }

arrayHashConversion(['Key1', 'Key2', 'Key3'], 1) returns { Key1: 1, Key2: 2, Key3: 3 }

Bugs and Feature Requests

Please use the Issues to provide any bug reports and array/object-related feature requests.