
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
A function that applies a mapping function to an infinite number of input elements, with options to skip certain elements and selectively apply the mapping to keys and/or values of objects.
mapfunc
is a function that applies a mapping function to an infinite number of input elements, with options to skip certain elements and selectively apply the mapping to keys and/or values of objects.
The mapfunc
function has been developed in JavaScript and Python, offering the same functionality in different programming languages.
npm install mapfunc
const mapfunc = require("mapfunc");
import mapfunc from "mapfunc"
<script src="https://unpkg.com/mapfunc@latest/index.js"></script>
mapfunc(fun,{skip,key,value},...X)
fun
: The mapping function that will be applied to each element in the input elements....X
:The elements to be mapped . { skip , key , value }
: Object with three optional properties :
skip
: specifies the elements to skip during the mapping process.key
: boolean flag indicating whether to apply the mapping function to the keys of objects or not. The default value is false
value
: boolean flag indicating whether to apply the mapping function to the values of objects or not. The default value is true
console.log(
mapfunc(n => n + 2,{}, 1,"a", [1, 2, 3], true, {
a: 2,
b: 3,
c: { d: 3, e: [1, 3, 4] },
})
);
/* Expected log
[
3,
"a2",
[3, 4, 5],
3,
{
a: 4,
b: 5,
c: {
d: 5,
e: [3, 5, 6],
},
},
];
*/
const PI=Math.PI
const sin=(...args)=>mapfunc(Math.sin,{},...args)
console.log(sin(0,PI/4,[0,PI/6,PI/4,{x:PI/8,y:PI/12}]))
/* Expected log
[
0,
0.7071067811865475,
[
0,
0.49999999999999994,
0.7071067811865475,
{
x: 0.3826834323650898,
y: 0.25881904510252074,
},
],
];
*/
const A=new Map([["a",1],["b",2]]);
// Map { 'a' => 1, 'b' => 2 }
console.log(mapfunc(n=>n+1,{},A));
/* Expected log
Map { 'a' => 2, 'b' => 3 }
*/
console.log(mapfunc(n=>n+1,{key:true},A));
/* Expected log
Map { 'a1' => 2, 'b1' => 3 }
*/
console.log(mapfunc(n=>n+1,{value:false},A));
/* Expected log
Map { 'a' => 1, 'b' => 2 }
*/
console.log(mapfunc(n=>n+1,{key:true,value:false},A));
/* Expected log
Map { 'a1' => 1, 'b1' => 2 }
*/
This projet is licensed under the terms of MIT License .
FAQs
A function that applies a mapping function to an infinite number of input elements, with options to skip certain elements and selectively apply the mapping to keys and/or values of objects.
The npm package mapfunc receives a total of 0 weekly downloads. As such, mapfunc popularity was classified as not popular.
We found that mapfunc 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.