New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

atoo

Package Overview
Dependencies
Maintainers
3
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atoo

array to object | Convert any array to object with/without given key-prefix.

latest
Source
npmnpm
Version
2025.4.17
Version published
Maintainers
3
Created
Source

atoo: array to object

Convert any array to object with/without given key-prefix.

npm install atoo

This package: github | npm

Also see: otoa: github | npm

Usage

// var {arrayToObject} = require('atoo');
import {arrayToObject} from "atoo";
const obj = arrayToObject(array [, keyPrefix]);
arrayToObject([1, 2, 3, "a", , , , "b"], "i-");
// Object {i-0: 1, i-1: 2, i-2: 3, i-3: "a", i-7: "b"}

arrayToObject([1, 2, 3, "a", , , , "b"]);
// Object {0: 1, 1: 2, 2: 3, 3: "a", 7: "b"}

Note: Takes care of sparse arrays too.

License

The MIT License (MIT)

Copyright (c) 2016-2025 Anubhav Saini

Keywords

array to object

FAQs

Package last updated on 16 Apr 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