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

appolo-utils

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

appolo-utils - npm Package Compare versions

Comparing version 0.0.48 to 0.0.50

29

lib/arrays.js

@@ -24,3 +24,3 @@ "use strict";

}
static remove(list, item) {
static removeBy(list, criteria) {
if (!list || !list.length) {

@@ -30,3 +30,3 @@ return;

for (let i = list.length - 1; i >= 0; i--) {
if (list[i] === item) {
if (criteria(list[i], i)) {
list.splice(i, 1);

@@ -36,2 +36,8 @@ }

}
static remove(list, item) {
Arrays.removeBy(list, current => current === item);
}
static chunk(array, chunkSize) {
return Arrays.splitToChunks(array, chunkSize);
}
static splitToChunks(array, chunkSize) {

@@ -98,2 +104,21 @@ return [].concat.apply([], array.map(function (elem, i) {

}
static map(arr, criteria) {
if (!arr) {
return [];
}
if (!Array.isArray(arr)) {
return Object.keys(arr).map(key => criteria(arr[key], key));
}
return arr.map(criteria);
}
static forEach(arr, criteria) {
if (!arr) {
return;
}
if (!Array.isArray(arr)) {
Object.keys(arr).forEach(key => criteria(arr[key], key));
return;
}
arr.forEach(criteria);
}
static uniqBy(arr, criteria) {

@@ -100,0 +125,0 @@ let dic = new Map(), out = [];

@@ -31,4 +31,4 @@ import {Classes} from "./classes";

public static remove<T>(list: T[], item: T): void {
public static removeBy<T>(list: T[], criteria: (value: T, i?: number) => boolean): void {
if (!list || !list.length) {

@@ -39,3 +39,3 @@ return;

for (let i = list.length - 1; i >= 0; i--) {
if (list[i] === item) {
if (criteria(list[i], i)) {
list.splice(i, 1);

@@ -46,2 +46,10 @@ }

public static remove<T>(list: T[], item: T): void {
Arrays.removeBy(list, current => current === item)
}
public static chunk(array: any[], chunkSize: number): any[] {
return Arrays.splitToChunks(array, chunkSize)
}
public static splitToChunks(array: any[], chunkSize: number): any[] {

@@ -144,2 +152,27 @@

public static map<T, K>(arr: T[] | { [index: string]: T }, criteria: (value: T, i?: number | string) => K): K[] {
if (!arr) {
return []
}
if (!Array.isArray(arr)) {
return Object.keys(arr).map(key => criteria(arr[key], key))
}
return arr.map(criteria)
}
public static forEach<T>(arr: T[] | { [index: string]: T }, criteria: (value: T, i?: number | string) => void): void {
if (!arr) {
return;
}
if (!Array.isArray(arr)) {
Object.keys(arr).forEach(key => criteria(arr[key], key));
return;
}
arr.forEach(criteria);
}
public static uniqBy<T>(arr: T[], criteria: (value: T, i?: number) => any): T[] {

@@ -146,0 +179,0 @@ let dic = new Map<any, 1>(), out = [];

2

package.json

@@ -17,3 +17,3 @@ {

"main": "./index.js",
"version": "0.0.48",
"version": "0.0.50",
"license": "MIT",

@@ -20,0 +20,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

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