Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
fisher-yates-map
Advanced tools
[![npm](https://img.shields.io/npm/v/fisher-yates-map.svg?maxAge=2592000)](https://www.npmjs.com/package/fisher-yates-map) ![fisher-yates-map](https://img.shields.io/npm/l/fisher-yates-map.svg?maxAge=2592000) [![Build Status](https://travis-ci.org/ticky/f
A map implementation which calls the callback for each element in a random order
fyMap
is a simple map function which accepts an array and a callback;
import fyMap from 'fisher-yates-map';
const myArray = ['meow', 'purr', 'nya'];
const output = fyMap(myArray, (item, index, array) => {
console.log(`cat ${index + 1} ${item}s!`);
return `${item}~!`;
});
// => 'cat 2 purrs!'
// => 'cat 1 meows!'
// => 'cat 3 nyas!'
console.log(output);
// => ['meow~!', 'purr~!', 'nya~!']
The output will be the same as calling the equivalent built-in Array.prototype.map
method, however, each item will be sent to the callback in a random order.
If you're using babel-plugin-transform-function-bind
, you can also call fyMap
with an alternate syntax;
const output = myArray::fyMap((item, index, array) => {
console.log(`cat ${index + 1} ${item}s!`);
return `${item}~!`;
});
More information about this syntax extension can be found on Babel's website.
This could be useful in situations where the order of operations doesn't matter, or you want to enforce that per-item operations not rely on prior results. It could also be useful if you have a large number of operations which you'd like to scatter the application of.
fyMap
doesn't implement the standard Array.prototype.map
handling of this
. If that doesn't work for you, you should probably use something else!
Performance is also imperfect - if you need something as fast as Array.prototype.map
or a traditional loop, this isn't it.
FAQs
[![npm](https://img.shields.io/npm/v/fisher-yates-map.svg?maxAge=2592000)](https://www.npmjs.com/package/fisher-yates-map) ![fisher-yates-map](https://img.shields.io/npm/l/fisher-yates-map.svg?maxAge=2592000) [![Build Status](https://travis-ci.org/ticky/f
The npm package fisher-yates-map receives a total of 0 weekly downloads. As such, fisher-yates-map popularity was classified as not popular.
We found that fisher-yates-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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.