You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@softwareventures/array

Package Overview
Dependencies
Maintainers
1
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@softwareventures/array - npm Package Compare versions

Comparing version

to
7.0.0-alpha.1

14

index.d.ts
import type { Comparator } from "@softwareventures/ordered";
export declare function copy<T>(array: ArrayLike<T>): T[];
export declare function isArray<T = unknown>(value: readonly T[] | unknown): value is readonly T[];
export declare function isArrayLike<T>(value: ArrayLike<T> | unknown): value is ArrayLike<T>;
export declare function isArray(value: unknown): value is readonly unknown[];
export declare function isArrayLike(value: unknown): value is ArrayLike<unknown>;
export declare function coerce<T>(array: ArrayLike<T>): readonly T[];
export declare function first<T>(array: ArrayLike<T>): T | null;
/** @deprecated Use {@link first} instead. */
export declare function head<T>(array: ArrayLike<T>): T | null;
export declare function tail<T>(array: ArrayLike<T>): T[];

@@ -50,8 +48,2 @@ export declare function push<T>(array: ArrayLike<T>, value: T): T[];

export declare function filterFn<T>(predicate: (element: T, index: number) => boolean): (array: ArrayLike<T>) => T[];
/** @deprecated This function is confusing, use {@link excludeFirst} instead,
* and invert the predicate. */
export declare function filterFirst<T>(array: ArrayLike<T>, predicate: (element: T, index: number) => boolean): T[];
/** @deprecated This function is confusing, use {@link excludeFirstFn} instead,
* and invert the predicate. */
export declare function filterFirstFn<T>(predicate: (element: T, index: number) => boolean): (array: ArrayLike<T>) => T[];
export declare function exclude<T, U>(array: ArrayLike<T | U>, predicate: (element: T | U) => element is T): U[];

@@ -245,4 +237,2 @@ export declare function exclude<T>(array: ArrayLike<T>, predicate: (element: T, index: number) => boolean): T[];

export declare function uniqueAdjacentByHashFn<T>(hash: (element: T, index: number) => unknown): (array: ArrayLike<T>) => T[];
/** @deprecated Use [array-shuffle](https://npmjs.com/array-shuffle) instead. */
export declare function shuffle<T>(array: ArrayLike<T>): T[];
export declare function sort(array: ArrayLike<boolean>): boolean[];

@@ -249,0 +239,0 @@ export declare function sort(array: ArrayLike<number>): number[];

64

index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeFn = exports.remove = exports.excludeFirstFn = exports.excludeFirst = exports.excludeNull = exports.excludeFn = exports.exclude = exports.filterFirstFn = exports.filterFirst = exports.filterFn = exports.filter = exports.mapFn = exports.map = exports.prefixMatchFn = exports.prefixMatch = exports.notEqualFn = exports.notEqual = exports.equalFn = exports.equal = exports.dropUntilFn = exports.dropUntil = exports.dropWhileFn = exports.dropWhile = exports.takeUntilFn = exports.takeUntil = exports.takeWhileFn = exports.takeWhile = exports.dropFn = exports.drop = exports.takeFn = exports.take = exports.sliceFn = exports.slice = exports.reverse = exports.notEmpty = exports.empty = exports.only = exports.last = exports.initial = exports.unshiftFn = exports.unshift = exports.pushFn = exports.push = exports.tail = exports.head = exports.first = exports.coerce = exports.isArrayLike = exports.isArray = exports.copy = void 0;
exports.concatMapFn = exports.concatMap = exports.append = exports.prepend = exports.concat = exports.allFn = exports.all = exports.anyFn = exports.any = exports.or = exports.and = exports.average = exports.product = exports.sum = exports.minimumByFn = exports.minimumBy = exports.minimumFn = exports.minimum = exports.maximumByFn = exports.maximumBy = exports.maximumFn = exports.maximum = exports.findLastFn = exports.findLast = exports.findFn = exports.find = exports.findLastIndexFn = exports.findLastIndex = exports.findIndexFn = exports.findIndex = exports.lastIndexOfFn = exports.lastIndexOf = exports.indexOfFn = exports.indexOf = exports.containsFn = exports.contains = exports.foldMapRightFn = exports.foldMapRight = exports.foldMapFn = exports.foldMap = exports.foldRight1Fn = exports.foldRight1 = exports.foldRightFn = exports.foldRight = exports.fold1Fn = exports.fold1 = exports.foldFn = exports.fold = exports.removeFirstFn = exports.removeFirst = void 0;
exports.groupAdjacentByEquality = exports.groupAdjacentByIdentityFn = exports.groupAdjacentByIdentity = exports.groupAdjacentFn = exports.groupAdjacent = exports.groupByOrderWithHashFn = exports.groupByOrderWithHash = exports.groupByEqualityWithHashFn = exports.groupByEqualityWithHash = exports.groupByHashFn = exports.groupByHash = exports.groupByOrderFn = exports.groupByOrder = exports.groupByEqualityFn = exports.groupByEquality = exports.groupByIdentityFn = exports.groupByIdentity = exports.groupFn = exports.group = exports.mapKeyLastByFn = exports.mapKeyLastBy = exports.mapKeyFirstByFn = exports.mapKeyFirstBy = exports.mapKeyByFn = exports.mapKeyBy = exports.keyLastByFn = exports.keyLastBy = exports.keyFirstByFn = exports.keyFirstBy = exports.keyByFn = exports.keyBy = exports.zipFn = exports.zip = exports.partitionUntilFn = exports.partitionUntil = exports.partitionWhileFn = exports.partitionWhile = exports.partitionFn = exports.partition = exports.splitFn = exports.split = exports.scanRight1Fn = exports.scanRight1 = exports.scanRightFn = exports.scanRight = exports.scan1Fn = exports.scan1 = exports.scanFn = exports.scan = exports.noneNull = void 0;
exports.forEachFn = exports.forEach = exports.sortByDescendingFn = exports.sortByDescending = exports.sortByFn = exports.sortBy = exports.sortFn = exports.sort = exports.shuffle = exports.uniqueAdjacentByHashFn = exports.uniqueAdjacentByHash = exports.uniqueAdjacentByOrderFn = exports.uniqueAdjacentByOrder = exports.uniqueAdjacentByEqualityFn = exports.uniqueAdjacentByEquality = exports.uniqueAdjacentByIdentityFn = exports.uniqueAdjacentByIdentity = exports.uniqueAdjacentFn = exports.uniqueAdjacent = exports.uniqueByOrderWithHashFn = exports.uniqueByOrderWithHash = exports.uniqueByEqualityWithHashFn = exports.uniqueByEqualityWithHash = exports.uniqueByHashFn = exports.uniqueByHash = exports.uniqueByOrderFn = exports.uniqueByOrder = exports.uniqueByEqualityFn = exports.uniqueByEquality = exports.uniqueByIdentity = exports.uniqueFn = exports.unique = exports.groupAdjacentByHashFn = exports.groupAdjacentByHash = exports.groupAdjacentByOrderFn = exports.groupAdjacentByOrder = exports.groupAdjacentByEqualityFn = void 0;
exports.fold = exports.removeFirstFn = exports.removeFirst = exports.removeFn = exports.remove = exports.excludeFirstFn = exports.excludeFirst = exports.excludeNull = exports.excludeFn = exports.exclude = exports.filterFn = exports.filter = exports.mapFn = exports.map = exports.prefixMatchFn = exports.prefixMatch = exports.notEqualFn = exports.notEqual = exports.equalFn = exports.equal = exports.dropUntilFn = exports.dropUntil = exports.dropWhileFn = exports.dropWhile = exports.takeUntilFn = exports.takeUntil = exports.takeWhileFn = exports.takeWhile = exports.dropFn = exports.drop = exports.takeFn = exports.take = exports.sliceFn = exports.slice = exports.reverse = exports.notEmpty = exports.empty = exports.only = exports.last = exports.initial = exports.unshiftFn = exports.unshift = exports.pushFn = exports.push = exports.tail = exports.first = exports.coerce = exports.isArrayLike = exports.isArray = exports.copy = void 0;
exports.scanFn = exports.scan = exports.noneNull = exports.concatMapFn = exports.concatMap = exports.append = exports.prepend = exports.concat = exports.allFn = exports.all = exports.anyFn = exports.any = exports.or = exports.and = exports.average = exports.product = exports.sum = exports.minimumByFn = exports.minimumBy = exports.minimumFn = exports.minimum = exports.maximumByFn = exports.maximumBy = exports.maximumFn = exports.maximum = exports.findLastFn = exports.findLast = exports.findFn = exports.find = exports.findLastIndexFn = exports.findLastIndex = exports.findIndexFn = exports.findIndex = exports.lastIndexOfFn = exports.lastIndexOf = exports.indexOfFn = exports.indexOf = exports.containsFn = exports.contains = exports.foldMapRightFn = exports.foldMapRight = exports.foldMapFn = exports.foldMap = exports.foldRight1Fn = exports.foldRight1 = exports.foldRightFn = exports.foldRight = exports.fold1Fn = exports.fold1 = exports.foldFn = void 0;
exports.groupAdjacentByOrderFn = exports.groupAdjacentByOrder = exports.groupAdjacentByEqualityFn = exports.groupAdjacentByEquality = exports.groupAdjacentByIdentityFn = exports.groupAdjacentByIdentity = exports.groupAdjacentFn = exports.groupAdjacent = exports.groupByOrderWithHashFn = exports.groupByOrderWithHash = exports.groupByEqualityWithHashFn = exports.groupByEqualityWithHash = exports.groupByHashFn = exports.groupByHash = exports.groupByOrderFn = exports.groupByOrder = exports.groupByEqualityFn = exports.groupByEquality = exports.groupByIdentityFn = exports.groupByIdentity = exports.groupFn = exports.group = exports.mapKeyLastByFn = exports.mapKeyLastBy = exports.mapKeyFirstByFn = exports.mapKeyFirstBy = exports.mapKeyByFn = exports.mapKeyBy = exports.keyLastByFn = exports.keyLastBy = exports.keyFirstByFn = exports.keyFirstBy = exports.keyByFn = exports.keyBy = exports.zipFn = exports.zip = exports.partitionUntilFn = exports.partitionUntil = exports.partitionWhileFn = exports.partitionWhile = exports.partitionFn = exports.partition = exports.splitFn = exports.split = exports.scanRight1Fn = exports.scanRight1 = exports.scanRightFn = exports.scanRight = exports.scan1Fn = exports.scan1 = void 0;
exports.forEachFn = exports.forEach = exports.sortByDescendingFn = exports.sortByDescending = exports.sortByFn = exports.sortBy = exports.sortFn = exports.sort = exports.uniqueAdjacentByHashFn = exports.uniqueAdjacentByHash = exports.uniqueAdjacentByOrderFn = exports.uniqueAdjacentByOrder = exports.uniqueAdjacentByEqualityFn = exports.uniqueAdjacentByEquality = exports.uniqueAdjacentByIdentityFn = exports.uniqueAdjacentByIdentity = exports.uniqueAdjacentFn = exports.uniqueAdjacent = exports.uniqueByOrderWithHashFn = exports.uniqueByOrderWithHash = exports.uniqueByEqualityWithHashFn = exports.uniqueByEqualityWithHash = exports.uniqueByHashFn = exports.uniqueByHash = exports.uniqueByOrderFn = exports.uniqueByOrder = exports.uniqueByEqualityFn = exports.uniqueByEquality = exports.uniqueByIdentity = exports.uniqueFn = exports.unique = exports.groupAdjacentByHashFn = exports.groupAdjacentByHash = void 0;
const nullable_1 = require("@softwareventures/nullable");

@@ -49,6 +49,2 @@ const ordered_1 = require("@softwareventures/ordered");

exports.first = first;
/** @internal This implementation is for internal use only, the exported declaration is above */
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore duplicate identifier: This is the actual implementation, the exported declaration is above.
exports.head = first;
function tail(array) {

@@ -220,5 +216,15 @@ return nativeSlice.call(array, 1);

exports.filterFn = filterFn;
/** @deprecated This function is confusing, use {@link excludeFirst} instead,
* and invert the predicate. */
function filterFirst(array, predicate) {
function exclude(array, predicate) {
return filter(array, (element, index) => !predicate(element, index));
}
exports.exclude = exclude;
function excludeFn(predicate) {
return array => exclude(array, predicate);
}
exports.excludeFn = excludeFn;
function excludeNull(array) {
return filter(array, nullable_1.isNotNull);
}
exports.excludeNull = excludeNull;
function excludeFirst(array, predicate) {
const result = [];

@@ -228,3 +234,3 @@ let i = 0;

const element = array[i];
if (predicate(element, i)) {
if (!predicate(element, i)) {
result.push(element);

@@ -241,24 +247,2 @@ }

}
exports.filterFirst = filterFirst;
/** @deprecated This function is confusing, use {@link excludeFirstFn} instead,
* and invert the predicate. */
function filterFirstFn(predicate) {
return array => filterFirst(array, predicate);
}
exports.filterFirstFn = filterFirstFn;
function exclude(array, predicate) {
return filter(array, (element, index) => !predicate(element, index));
}
exports.exclude = exclude;
function excludeFn(predicate) {
return array => exclude(array, predicate);
}
exports.excludeFn = excludeFn;
function excludeNull(array) {
return filter(array, nullable_1.isNotNull);
}
exports.excludeNull = excludeNull;
function excludeFirst(array, predicate) {
return filterFirst(array, (element, index) => !predicate(element, index));
}
exports.excludeFirst = excludeFirst;

@@ -1194,14 +1178,2 @@ function excludeFirstFn(predicate) {

exports.uniqueAdjacentByHashFn = uniqueAdjacentByHashFn;
/** @deprecated Use [array-shuffle](https://npmjs.com/array-shuffle) instead. */
function shuffle(array) {
const result = (0, exports.copy)(array);
for (let i = 0; i < array.length; ++i) {
const j = i + Math.floor(Math.random() * (array.length - i));
const replacement = result[j];
result[j] = result[i];
result[i] = replacement;
}
return result;
}
exports.shuffle = shuffle;
function sort(array, comparator) {

@@ -1208,0 +1180,0 @@ return (0, exports.copy)(array).sort(comparator !== null && comparator !== void 0 ? comparator : ordered_1.compare);

{
"name": "@softwareventures/array",
"version": "6.1.0",
"version": "7.0.0-alpha.1",
"description": "Pure functional array manipulation and traversal",

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

Sorry, the diff of this file is not supported yet