
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
array-object-transformer
Advanced tools
Interconvert between an array of objects and object of arrays.
Two useful functions for data wrangling in javascript- allows for easy transformation between row-wise (array of objects) and column-wise (object of arrays) dataset structure.
$ npm install object-array-transformer
import { arrayToObject } from "object-array-transformer";
let arr = [
{ col1: 1, col2: "a", col3: true },
{ col1: 2, col2: "b", col3: true },
{ col1: 3, col2: "c", col3: false },
];
const obj = arrayToObject(arr);
console.log(obj);
#obj
{
col1: [1,2,3],
col2: ['a','b','c'],
col3: [true, true, false]
}
import { objectToArray } from "object-array-transformer";
let obj = {
col1: [1, 2, 3],
col2: ["a", "b", "c"],
col3: [true, true, false],
};
const arr = objectToArray(obj);
console.log(arr);
#arr
[
{ col1: 1, col2: "a", col3: true },
{ col1: 2, col2: "b", col3: true },
{ col1: 3, col2: "c", col3: false },
]
if checkError is true (default) in arrayToObject, verbose error message is generated if any arrays are not the same length.
if checkError is true (default) in objectToArray, verbose error message is generated if any objects contain extra keys, or are missing keys, compared to the first object's keys in the array. If checkError is set to false, then keys of new objects in array will be the same as the first object's keys. Novel keys in subsequent objects will be lost, and missing keys in subsequent objects will be introduced with the value undefined.
checkError can be set to false to save computation time if you are confident in your input data structures.
const obj = arrayToObject(arr, false)
const arr = objectToArray(obj, false)
For Browser and NodeJS Zero Dependencies
FAQs
Interconvert between an array of objects and object of arrays.
The npm package array-object-transformer receives a total of 2 weekly downloads. As such, array-object-transformer popularity was classified as not popular.
We found that array-object-transformer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.