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

@augment-vir/common

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@augment-vir/common - npm Package Compare versions

Comparing version 23.2.0 to 23.3.0

43

dist/cjs/augments/array.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.repeatArray = exports.typedMap = exports.typedArrayIncludes = exports.trimArrayStrings = exports.flatten2dArray = exports.filterOutIndexes = void 0;
exports.filterMap = exports.arrayToObject = exports.groupArrayBy = exports.repeatArray = exports.typedMap = exports.typedArrayIncludes = exports.trimArrayStrings = exports.flatten2dArray = exports.filterOutIndexes = void 0;
const object_entries_1 = require("./object/object-entries");
function filterOutIndexes(array, indexes) {

@@ -30,1 +31,41 @@ return array.filter((_, index) => !indexes.includes(index));

exports.repeatArray = repeatArray;
/**
* Polyfill for `Object.groupBy`:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy
*/
function groupArrayBy(inputArray, callback) {
return inputArray.reduce((accum, entry, index, originalArray) => {
const key = callback(entry, index, originalArray);
if (!(key in accum)) {
accum[key] = [];
}
accum[key].push(entry);
return accum;
}, {});
}
exports.groupArrayBy = groupArrayBy;
/**
* Like `groupArrayBy` but maps array entries to a single key. Meaning, the resulting object does
* not have an array of elements (unless the original array itself contains arrays).
*/
function arrayToObject(inputArray, callback) {
return (0, object_entries_1.typedObjectFromEntries)(inputArray.map((entry, index, originalArray) => {
const key = callback(entry, index, originalArray);
return [
key,
entry,
];
}));
}
exports.arrayToObject = arrayToObject;
function filterMap(inputArray, mapCallback, filterCallback) {
return inputArray.reduce((accum, entry, index, originalArray) => {
const mapOutput = mapCallback(entry, index, originalArray);
const filterOutput = filterCallback(mapOutput, entry, index, originalArray);
if (filterOutput) {
accum.push(mapOutput);
}
return accum;
}, []);
}
exports.filterMap = filterMap;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.typedObjectFromEntries = exports.getEntriesSortedByKey = exports.getObjectTypedValues = exports.getObjectTypedKeys = exports.isKeyof = void 0;
exports.typedObjectFromEntries = exports.getEntriesSortedByKey = exports.getObjectTypedEntries = exports.getObjectTypedValues = exports.getObjectTypedKeys = exports.isKeyof = void 0;
const typed_has_property_1 = require("./typed-has-property");

@@ -27,2 +27,9 @@ /** @deprecated This is the same as hasKey */

exports.getObjectTypedValues = getObjectTypedValues;
function getObjectTypedEntries(input) {
return getObjectTypedKeys(input).map((key) => [
key,
input[key],
]);
}
exports.getObjectTypedEntries = getObjectTypedEntries;
function getEntriesSortedByKey(input) {

@@ -29,0 +36,0 @@ return Object.entries(input).sort((tupleA, tupleB) => tupleA[0].localeCompare(tupleB[0]));

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

import { typedObjectFromEntries } from './object/object-entries';
export function filterOutIndexes(array, indexes) {

@@ -21,1 +22,38 @@ return array.filter((_, index) => !indexes.includes(index));

}
/**
* Polyfill for `Object.groupBy`:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy
*/
export function groupArrayBy(inputArray, callback) {
return inputArray.reduce((accum, entry, index, originalArray) => {
const key = callback(entry, index, originalArray);
if (!(key in accum)) {
accum[key] = [];
}
accum[key].push(entry);
return accum;
}, {});
}
/**
* Like `groupArrayBy` but maps array entries to a single key. Meaning, the resulting object does
* not have an array of elements (unless the original array itself contains arrays).
*/
export function arrayToObject(inputArray, callback) {
return typedObjectFromEntries(inputArray.map((entry, index, originalArray) => {
const key = callback(entry, index, originalArray);
return [
key,
entry,
];
}));
}
export function filterMap(inputArray, mapCallback, filterCallback) {
return inputArray.reduce((accum, entry, index, originalArray) => {
const mapOutput = mapCallback(entry, index, originalArray);
const filterOutput = filterCallback(mapOutput, entry, index, originalArray);
if (filterOutput) {
accum.push(mapOutput);
}
return accum;
}, []);
}

@@ -21,2 +21,8 @@ import { typedHasProperty } from './typed-has-property';

}
export function getObjectTypedEntries(input) {
return getObjectTypedKeys(input).map((key) => [
key,
input[key],
]);
}
export function getEntriesSortedByKey(input) {

@@ -23,0 +29,0 @@ return Object.entries(input).sort((tupleA, tupleB) => tupleA[0].localeCompare(tupleB[0]));

@@ -14,2 +14,13 @@ import { AtLeastTuple } from './tuple';

export declare function repeatArray<T>(repeatCount: number, array: T[]): T[];
/**
* Polyfill for `Object.groupBy`:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy
*/
export declare function groupArrayBy<ElementType, NewKey extends PropertyKey>(inputArray: ReadonlyArray<ElementType>, callback: (entry: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => NewKey): Record<NewKey, ElementType[]>;
/**
* Like `groupArrayBy` but maps array entries to a single key. Meaning, the resulting object does
* not have an array of elements (unless the original array itself contains arrays).
*/
export declare function arrayToObject<ElementType, NewKey extends PropertyKey>(inputArray: ReadonlyArray<ElementType>, callback: (entry: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => NewKey): Record<NewKey, ElementType>;
export declare function filterMap<ElementType, MapReturn>(inputArray: ReadonlyArray<ElementType>, mapCallback: (entry: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => MapReturn, filterCallback: (mappedOutput: MapReturn, originalEntry: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => boolean): MapReturn[];
export {};

@@ -5,3 +5,4 @@ /** @deprecated This is the same as hasKey */

export declare function getObjectTypedValues<ObjectGeneric extends unknown>(input: ObjectGeneric): ObjectGeneric[keyof ObjectGeneric][];
export declare function getObjectTypedEntries<ObjectGeneric extends unknown>(input: ObjectGeneric): [keyof ObjectGeneric, ObjectGeneric[keyof ObjectGeneric]][];
export declare function getEntriesSortedByKey(input: object): [string, unknown][];
export declare function typedObjectFromEntries<KeyType extends PropertyKey, ValueType>(entries: ReadonlyArray<Readonly<[KeyType, ValueType]>>): Record<KeyType, ValueType>;

2

package.json
{
"name": "@augment-vir/common",
"version": "23.2.0",
"version": "23.3.0",
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common",

@@ -5,0 +5,0 @@ "bugs": {

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