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.19.3 to 0.19.4

.github/workflows/release.yml

4

package.json
{
"name": "absurdum",
"version": "0.19.3",
"version": "0.19.4",
"description": "Reducio Ad Absurdum - The Riduculous Application of Reduce",

@@ -22,3 +22,3 @@ "keywords": [

"lint": "semistandard",
"types": "npx tsc --checkJs",
"types": "npx tsc --project jsconfig.json",
"package": "npx rimraf package && npm pack | tail -n 1 | xargs tar -xf",

@@ -25,0 +25,0 @@ "preversion": "npm test && npm run lint && npm run types",

@@ -0,2 +1,6 @@

[![GitHub release](https://img.shields.io/github/release/vanillajs2/absurdum.svg)](https://github.com/vanillajs2/absurdum/releases)
[![npm](https://img.shields.io/npm/v/absurdum.svg)](https://www.npmjs.com/package/absurdum)
[![David](https://img.shields.io/david/dev/vanillajs2/absurdum.svg)](https://david-dm.org/vanillajs2/absurdum?type=dev)
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/vanillajs2/absurdum/master/LICENSE)
[![Actions Status](https://github.com/vanillajs2/absurdum/workflows/Release/badge.svg)](https://github.com/vanillajs2/absurdum/actions)

@@ -28,4 +32,17 @@ # Absurdum

## Operator(s) Documentation
## Usage
Import the desired namespace then call the operator from it
```javascript
import { arrays } from 'absurdum';
const input = ['a', 'b', 'c', 'd'];
const output = arrays.reverse(input);
console.log(output);
// > ['d', 'c', 'b', 'a']
```
## API Documentation
### Arrays

@@ -32,0 +49,0 @@

/**
* Splits an array up into an array of equal size chunks.
* Splits the input array up into an subset arrays of equal size
*
* @param {Array} array The input array
* @param {number} [size=1] The size of each chunk
* @returns {Array} An array of chunk arrays
* @param {Array} array input array
* @param {number} [size=1] size of each chunk
* @returns {Array} array of chunk arrays
*

@@ -8,0 +8,0 @@ * @example

/**
* Returns an array with all falsy `[false, null, 0, "", undefined, NaN]` values removed.
* Compact removes all falsy values `[false, null, 0, "", undefined, NaN]` from an array.
*
* @param {Array} array
* @returns {Array} the compacted array
* @param {Array} array input array
* @returns {Array} the input array w/ no falsy values
*

@@ -7,0 +7,0 @@ * @example

/**
* Concat takes any number or arrays or values as input. The arrays can be any level of depth. The output will be a single, one-dimensional array containing all the values.
*
* @param {Array} arrays
* @returns {Array} The concatenated array
* @param {Array} arrays input array(s)
* @returns {Array} an array containing all of the input array values
*

@@ -7,0 +7,0 @@ * @example

/**
* Returns an array containing the difference of the input array vs the specified values.
* Finds the difference of two arrays
*
* @param {Array} array
* @param {Array} values
* @param {Array} arrayA first input array
* @param {Array} arrayB second input array
* @returns {Array} an array containing the difference

@@ -13,6 +13,6 @@ *

*/
function difference (array, values) {
const uniqueValues = new Set(values);
function difference (arrayA, arrayB) {
const uniqueValues = new Set(arrayB);
return array.reduce((acc, curr) => {
return arrayA.reduce((acc, curr) => {
if (!uniqueValues.has(curr)) {

@@ -19,0 +19,0 @@ acc.push(curr);

import test from 'tape';
import { arrays } from '../../index.js';
test('arrays.difference(array, values) - should return the difference between the input array and included values', t => {
test('arrays.difference(arrayA, arrayB) - should return the difference between the input array and included values', t => {
const expect = [1];

@@ -6,0 +6,0 @@ const result = arrays.difference([2, 1], [2, 3]);

/**
* Returns an array with n items dropped from the beginning.
* Remove N items from the beginning of the input array
*
* @param {Array} array
* @param {number} [n=1]
* @returns {Array} The input array sans the dropped items
* @param {Array} array input array
* @param {number} [n=1] number of items to drop
* @returns {Array} input array sans the dropped items
*

@@ -8,0 +8,0 @@ * @example

/**
* Returns an array with n items dropped from the end.
* Remove N items from the end of the input array
*
* @param {Array} array
* @param {number} [n=1]
* @returns {Array} The input array sans the dropped items
* @param {Array} array input array
* @param {number} [n=1] number of items to drop
* @returns {Array} input array sans the dropped items
*

@@ -8,0 +8,0 @@ * @example

/**
* Fills the array items with the value. Can optionally start and/or end from a specific index
* Fills items in an array with a specified value. (Optional) can start and/or end from a specific index.
*
* @param {Array} array
* @param {*} value
* @param {number} [start=0]
* @param {number} [end]
* @returns {Array} The filled array
* @param {Array} array input array
* @param {*} value value that fills the array
* @param {number} [start=0] start index
* @param {number} [end] end index
* @returns {Array} input array filled w/ the value
*

@@ -10,0 +10,0 @@ * @example

/**
* Filter iterates over an array of values and only outputs values where `predicate = true`.
* Iterates over an array of values and only outputs values where `predicate = true`.
*
* @param {Array} array
* @param {Function} predicate
* @returns {Array} A filtered array
* @param {Array} array input array
* @param {Function} predicate predicate function
* @returns {Array} the input array w/ unwanted values removed
*

@@ -8,0 +8,0 @@ * @example

/**
* Map iterates over an array of values and applies a function to each value
*
* @param {Array} array
* @param {Function} func
* @returns {Array} The array of mutated values
* @param {Array} array input array
* @param {Function} func map function
* @returns {Array} array of mutated values
*

@@ -8,0 +8,0 @@ * @example

/**
* Reduce right performs reduce in reverse order (ie last->first). The reducer parameter follows the standard API (ie reducer(accumulator, current, index, array)). The initial parameter can be used to set the starting value for the accumulator.
* Reduce the input in reverse order (ie last->first). The reducer parameter follows the standard API (ie reducer(accumulator, current, index, array)). The initial parameter can be used to set the starting value for the accumulator.
*
* @param {Array} array
* @param {Function} reducer
* @param {*} [initial = []]
* @returns {*} The reduced value
* @param {Array} array input array
* @param {Function} reducer reducer function
* @param {*} [initial = []] initial accumulator value
* @returns {*} accumulated value
*

@@ -9,0 +9,0 @@ * @example

/**
* Returns an array in reverse order
* Reverses the order of the values of an array
*
* @param {Array} array
* @returns {Array} The array in reversed order
* @param {Array} array input array
* @returns {Array} input array in reversed order
*

@@ -7,0 +7,0 @@ * @example

/**
* Applies a function to each element in the array without mutating it
*
* @param {Array} array
* @param {Function} func
* @returns {Array} The source array
* @param {Array} array input array
* @param {Function} func function to apply
* @returns {Array} input array unchanged
*

@@ -8,0 +8,0 @@ * @example

/**
* EndsWith tests a string to see if it ends with a substring
* Tests a string to see if it ends with a substring
*
* @param {string} string
* @param {string} [substr='']
* @returns {boolean}
* @param {string} string input string
* @param {string} [substr=''] substring to test
* @returns {boolean} does the input end with the substring?
*

@@ -19,10 +19,2 @@ * @example

function endsWith (string, substr = '') {
/**
* @private
* @param {*} acc output accumulator
* @param {*} curr the value of the current iteration
* @param {number} [idx] the index of the current iteration
* @param {*[]} [arr] reference to the input array
* @returns
*/
const reducer = (acc, curr, idx, arr) => {

@@ -29,0 +21,0 @@ // exit early on mismatch

/**
* PadEnd pads the end of a string.
* Pads the end of a string w/ repeated spaces|substrings
*
* @param {string} string
* @param {number} length
* @param {string} [substr=' ']
* @returns {string}
* @param {string} string input string
* @param {number} length length of the padded portion
* @param {string} [substr=' '] substring to apply
* @returns {string} the input padded w/ spaces|substrings
*

@@ -9,0 +9,0 @@ * @example

/**
* PadStart pads the start of of a string.
*
* @param {string} string
* @param {number} length
* @param {string} [substr=' ']
* @returns {string}
* @param {string} string input string
* @param {number} length length of the padded portion
* @param {string} [substr=' '] substring to apply
* @returns {string} the input padded w/ spaces|substrings
*

@@ -9,0 +9,0 @@ * @example

/**
* Reverse takes an returns a reversed version of the string input.
* Reversed the characters in a string
*
* @param {string} string
* @returns {string}
* @param {string} string input string
* @returns {string} input string reversed
*

@@ -7,0 +7,0 @@ * @example

/**
* StartsWith tests a string to see if it starts with a substring
*
* @param {string} string
* @param {string} substr
* @returns {string}
* @param {string} string input string
* @param {string} substr substring to test
* @returns {string} does the input start with the substring?
*

@@ -8,0 +8,0 @@ * @example

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