
Security News
Open Source Maintainers Feeling the Weight of the EU’s Cyber Resilience Act
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
A super simple utility for mapping one object to another using key-value pairs or a function.
simple-map is a super small utility function to map one object to another based on a key-value-pair map or a function.
var map = require('simple-map');
var person = {
firstName: "John",
lastName: "Doe"
};
var m = {
"firstName": "first_name",
"lastName": "last_name"
};
map(person, m); // { "first_name": "John", "last_name": "Doe" }
function convertKey(k) {
var m = { "x": "a", "y": "b", "z": "c" };
return m[k];
}
map({"x": 1, "y": 2, "z": 3}, convertKey); // { "a": 1, "b": 2, "c": 3 }
FYI - repattern is a nice complement to simple-map
var map = require('simple-map');
var repattern = require('repattern');
var columnCase = repattern.make('cam$_');
map({'firstName': 'John', 'lastName': 'Doe'}, columnCase); // {'first_name': 'John', 'last_name': 'Doe'}
In some cases, its useful to map with a function, but restrict to only specific properties. You can pass an array of keys to include for this.
var person = {
first_name: "John",
last_name: "Doe",
password: "a"
}
function convertKey(k) {
return k.toUpperCase().replace("_", "");
}
map(person, convertKey, ["first_name", "last_name"]); // { "FIRSTNAME": "John", "LASTNAME": "Doe" }
map.make
is super useful. It creates a curried function with an enclosed map and include list. You can use this with array#map to map objects within a collection.
var peopleRecords = [{"first_name": "John", "last_name": "Doe", "password", "a"}];
var personMapper = map.make(convertKey, ['first_name', 'last_name']);
var dtos = peopleRecords.map(personMapper);
npm install simple-map
var map = require('simple-map');
FAQs
A super simple utility for mapping one object to another using key-value pairs or a function.
The npm package simple-map receives a total of 2 weekly downloads. As such, simple-map popularity was classified as not popular.
We found that simple-map 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
The EU Cyber Resilience Act is prompting compliance requests that open source maintainers may not be obligated or equipped to handle.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.