Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

absurdum

Package Overview
Dependencies
Maintainers
1
Versions
177
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

absurdum - npm Package Compare versions

Comparing version 0.23.1 to 0.24.0

src/arrays/zip.js

38

dist/absurdum.cjs.js

@@ -399,4 +399,39 @@ 'use strict';

/**
* Zip applies a specified function to the corresponding elements of two sequences,
* producing a sequence of the results.
*
* @param {Array} array1 input array
* @param {Array} array2 input array
* @param {Function} predicate optional to be applied to corresponding values
* @returns {Array} input array filled value pairs after the function has been applied
*
* @example
* const result = zip([5, 12, 8, 130, 44], ["ham", "cheese", "bread"]);
* console.log(result)
* > [ [ 'ham', 5 ], [ 'cheese', 12 ], [ 'bread', 8 ] ]
* @example
* const result = zip([5, 12, 8], ["ham", "cheese", "bread"], (x, y) => x + " " + y);
* console.log(result)
* > [ 'ham 5', 'cheese 12', 'bread 8' ]
*/
function zip (array1, array2, predicate = (a, b) => [a, b]) {
if (predicate && typeof predicate !== 'function') {
throw TypeError('predicate must be a function');
}
if (array1.length <= array2.length) {
return array1.reduce((res, cur, i) => {
res[i] = predicate(cur, array2[i]);
return res;
}, []);
} else {
return array2.reduce((res, cur, i) => {
res[i] = predicate(array1[i], cur);
return res;
}, []);
}
}
var index = /*#__PURE__*/Object.freeze({

@@ -419,3 +454,4 @@ __proto__: null,

reverse: reverse,
tap: tap
tap: tap,
zip: zip
});

@@ -422,0 +458,0 @@

@@ -395,4 +395,39 @@ /**

/**
* Zip applies a specified function to the corresponding elements of two sequences,
* producing a sequence of the results.
*
* @param {Array} array1 input array
* @param {Array} array2 input array
* @param {Function} predicate optional to be applied to corresponding values
* @returns {Array} input array filled value pairs after the function has been applied
*
* @example
* const result = zip([5, 12, 8, 130, 44], ["ham", "cheese", "bread"]);
* console.log(result)
* > [ [ 'ham', 5 ], [ 'cheese', 12 ], [ 'bread', 8 ] ]
* @example
* const result = zip([5, 12, 8], ["ham", "cheese", "bread"], (x, y) => x + " " + y);
* console.log(result)
* > [ 'ham 5', 'cheese 12', 'bread 8' ]
*/
function zip (array1, array2, predicate = (a, b) => [a, b]) {
if (predicate && typeof predicate !== 'function') {
throw TypeError('predicate must be a function');
}
if (array1.length <= array2.length) {
return array1.reduce((res, cur, i) => {
res[i] = predicate(cur, array2[i]);
return res;
}, []);
} else {
return array2.reduce((res, cur, i) => {
res[i] = predicate(array1[i], cur);
return res;
}, []);
}
}
var index = /*#__PURE__*/Object.freeze({

@@ -415,3 +450,4 @@ __proto__: null,

reverse: reverse,
tap: tap
tap: tap,
zip: zip
});

@@ -418,0 +454,0 @@

2

package.json
{
"name": "absurdum",
"version": "0.23.1",
"version": "0.24.0",
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce",

@@ -5,0 +5,0 @@ "keywords": [

@@ -65,2 +65,3 @@ [![GitHub release](https://img.shields.io/github/release/vanillaes/absurdum.svg)](https://github.com/vanillaes/absurdum/releases)

- [tap][arrays.tap]
- [zip][arrays.zip]

@@ -83,2 +84,3 @@ [arrays.chunk]: ./docs/arrays/chunk.md

[arrays.tap]: ./docs/arrays/tap.md
[arrays.zip]: ./docs/arrays/zip.md

@@ -85,0 +87,0 @@ ### Objects

@@ -16,1 +16,2 @@ export { chunk } from "./chunk.js";

export { tap } from "./tap.js";
export { zip } from "./zip.js";

@@ -17,1 +17,2 @@ export { chunk } from './chunk.js';

export { tap } from './tap.js';
export { zip } from './zip.js';
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc