
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
@juliancoleman/index-by-key
Advanced tools
Converts an array of objects into an object of objects with a given predicate.
A curried function using Ramda that transforms an array of objects into an object of objects, where the key is the key specified and the value is the rest of the object. The function will return a new object and will not mutate or destroy the original array.
yarn
yarn add @juliancoleman/index-by-key
npm
npm i -S @juliancoleman/index-by-key
This package provides the single function mentioned above.
You can specify the key on require
, or you can specify a
key to indexBy
later on.
// initialize without specified key
const indexByKey = require("@juliancoleman/index-by-key");
// initialize with specified key at require
const indexById = require("@juliancoleman/index-by-key")("id");
// initialize with specified key later
const indexByFirstName = indexByKey("first_name");
Once required and a key is specified, you can then call the function on your data to see the transformation. Again, the function will return a new object and will not mutate or destroy the original array.
Below is an example use on a Promise
object returned by
an asynchronous database call:
const indexByKey = require("@juliancoleman/index-by-key");
const { getUsers } = appRequire("path/to/API");
(async () => {
const indexById = indexByKey("id");
const users = await getUsers();
/*
Example `users`
[ { "id": 1,
"first_name": "Julian",
"last_name": "Coleman",
"email_address": "julcol03@gmail.com" },
{ "id": 2,
"first_name": "Bob",
"last_name": "Sagget",
"email_address": "bob@sagget.com" } ]
*/
if (!users) {
throw new Error("Unable to retrieve users");
}
return indexById(users);
})();
/*
results in the following output
{ "1": { "first_name": "Julian",
"last_name": "Coleman",
"email_address": "julcol03@gmail.com"
},
"2": { "first_name": "Bob",
"last_name": "Sagget",
"email_address": "bob@sagget.com" } }
*/
Alternatively, this same thing can be achieved by doing the following:
API.getUsers().then(indexByKey("id"));
FAQs
Converts an array of objects into an object of objects with a given predicate.
We found that @juliancoleman/index-by-key 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.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.