New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@augment-vir/common

Package Overview
Dependencies
Maintainers
1
Versions
237
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 31.9.1 to 31.9.2

15

dist/augments/array/array-map.d.ts

@@ -15,5 +15,14 @@ import type { ArrayElement } from '@augment-vir/core';

*
* const result = await typedMap([1, 2, 3, 4, 5], (value) => {
* return value + 1;
* });
* const result = await typedMap(
* [
* 1,
* 2,
* 3,
* 4,
* 5,
* ],
* (value) => {
* return value + 1;
* },
* );
* ```

@@ -20,0 +29,0 @@ *

@@ -13,5 +13,14 @@ /**

*
* const result = await typedMap([1, 2, 3, 4, 5], (value) => {
* return value + 1;
* });
* const result = await typedMap(
* [
* 1,
* 2,
* 3,
* 4,
* 5,
* ],
* (value) => {
* return value + 1;
* },
* );
* ```

@@ -18,0 +27,0 @@ *

8

dist/augments/array/array-to-object.d.ts

@@ -13,3 +13,9 @@ import { type MaybePromise } from '@augment-vir/core';

*
* const result = arrayToObject(['a', 'b'], (value) => `key-${value}`);
* const result = arrayToObject(
* [
* 'a',
* 'b',
* ],
* (value) => `key-${value}`,
* );
* // result is `{key-a: ['a'], key-b: ['b']}`

@@ -16,0 +22,0 @@ * ```

@@ -17,3 +17,9 @@ import { check } from '@augment-vir/assert';

*
* const result = arrayToObject(['a', 'b'], (value) => `key-${value}`);
* const result = arrayToObject(
* [
* 'a',
* 'b',
* ],
* (value) => `key-${value}`,
* );
* // result is `{key-a: ['a'], key-b: ['b']}`

@@ -44,5 +50,11 @@ * ```

*
* const result = arrayToObject(['a', 'b'], (value) => {
* return {key: `key-${value}`, value};
* });
* const result = arrayToObject(
* [
* 'a',
* 'b',
* ],
* (value) => {
* return {key: `key-${value}`, value};
* },
* );
* // result is `{key-a: 'a', key-b: 'b'}`

@@ -64,3 +76,6 @@ * ```

else if (output) {
return [output.key, output.value];
return [
output.key,
output.value,
];
}

@@ -83,3 +98,6 @@ else {

else {
return [entry.key, entry.value];
return [
entry.key,
entry.value,
];
}

@@ -86,0 +104,0 @@ }, check.isTruthy);

@@ -13,5 +13,14 @@ /**

*
* const result = await awaitedFilter([1, 2, 3, 4, 5], async (value) => {
* return await Promise.resolve(value > 2);
* });
* const result = await awaitedFilter(
* [
* 1,
* 2,
* 3,
* 4,
* 5,
* ],
* async (value) => {
* return await Promise.resolve(value > 2);
* },
* );
* ```

@@ -18,0 +27,0 @@ *

@@ -14,5 +14,14 @@ import { awaitedBlockingMap } from './awaited-map.js';

*
* const result = await awaitedFilter([1, 2, 3, 4, 5], async (value) => {
* return await Promise.resolve(value > 2);
* });
* const result = await awaitedFilter(
* [
* 1,
* 2,
* 3,
* 4,
* 5,
* ],
* async (value) => {
* return await Promise.resolve(value > 2);
* },
* );
* ```

@@ -19,0 +28,0 @@ *

@@ -15,5 +15,14 @@ /**

*
* await awaitedForEach([1, 2, 3, 4, 5], async (value) => {
* await Promise.resolve(value);
* });
* await awaitedForEach(
* [
* 1,
* 2,
* 3,
* 4,
* 5,
* ],
* async (value) => {
* await Promise.resolve(value);
* },
* );
* ```

@@ -20,0 +29,0 @@ *

@@ -16,5 +16,14 @@ import { awaitedBlockingMap } from './awaited-map.js';

*
* await awaitedForEach([1, 2, 3, 4, 5], async (value) => {
* await Promise.resolve(value);
* });
* await awaitedForEach(
* [
* 1,
* 2,
* 3,
* 4,
* 5,
* ],
* async (value) => {
* await Promise.resolve(value);
* },
* );
* ```

@@ -21,0 +30,0 @@ *

@@ -16,5 +16,14 @@ /**

*
* const result = await awaitedBlockingMap([1, 2, 3, 4, 5], async (value) => {
* return await Promise.resolve(value);
* });
* const result = await awaitedBlockingMap(
* [
* 1,
* 2,
* 3,
* 4,
* 5,
* ],
* async (value) => {
* return await Promise.resolve(value);
* },
* );
* ```

@@ -21,0 +30,0 @@ *

@@ -16,5 +16,14 @@ /**

*
* const result = await awaitedBlockingMap([1, 2, 3, 4, 5], async (value) => {
* return await Promise.resolve(value);
* });
* const result = await awaitedBlockingMap(
* [
* 1,
* 2,
* 3,
* 4,
* 5,
* ],
* async (value) => {
* return await Promise.resolve(value);
* },
* );
* ```

@@ -21,0 +30,0 @@ *

@@ -11,3 +11,13 @@ /**

*
* const result = filterOutIndexes(['a', 'b', ''], [0, 2]);
* const result = filterOutIndexes(
* [
* 'a',
* 'b',
* '',
* ],
* [
* 0,
* 2,
* ],
* );
* // result is `['b']`

@@ -14,0 +24,0 @@ * ```

@@ -11,3 +11,13 @@ /**

*
* const result = filterOutIndexes(['a', 'b', ''], [0, 2]);
* const result = filterOutIndexes(
* [
* 'a',
* 'b',
* '',
* ],
* [
* 0,
* 2,
* ],
* );
* // result is `['b']`

@@ -37,3 +47,7 @@ * ```

* const result = filterMap(
* ['a', 'b', ''],
* [
* 'a',
* 'b',
* '',
* ],
* // map callback

@@ -40,0 +54,0 @@ * (value) => {

@@ -12,3 +12,11 @@ /**

*
* const result = removeDuplicates([1, 1, 1, 1, 1, 2, 4]);
* const result = removeDuplicates([
* 1,
* 1,
* 1,
* 1,
* 1,
* 2,
* 4,
* ]);
* // result is `[1, 2, 4]`

@@ -38,3 +46,9 @@ *

* const result2 = removeDuplicates(
* [{id: 1}, {id: 1}, exampleEntry, exampleEntry, {id: 4}],
* [
* {id: 1},
* {id: 1},
* exampleEntry,
* exampleEntry,
* {id: 4},
* ],
* (entry) => entry.id,

@@ -41,0 +55,0 @@ * );

@@ -12,3 +12,11 @@ /**

*
* const result = removeDuplicates([1, 1, 1, 1, 1, 2, 4]);
* const result = removeDuplicates([
* 1,
* 1,
* 1,
* 1,
* 1,
* 2,
* 4,
* ]);
* // result is `[1, 2, 4]`

@@ -38,3 +46,9 @@ *

* const result2 = removeDuplicates(
* [{id: 1}, {id: 1}, exampleEntry, exampleEntry, {id: 4}],
* [
* {id: 1},
* {id: 1},
* exampleEntry,
* exampleEntry,
* {id: 4},
* ],
* (entry) => entry.id,

@@ -41,0 +55,0 @@ * );

@@ -12,3 +12,7 @@ /**

*
* const result = repeatArray(3, ['a', 'b', 'c']);
* const result = repeatArray(3, [
* 'a',
* 'b',
* 'c',
* ]);
* // result is `['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']`

@@ -15,0 +19,0 @@ * ```

@@ -12,3 +12,7 @@ /**

*
* const result = repeatArray(3, ['a', 'b', 'c']);
* const result = repeatArray(3, [
* 'a',
* 'b',
* 'c',
* ]);
* // result is `['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']`

@@ -15,0 +19,0 @@ * ```

@@ -16,3 +16,13 @@ import type { EnumBaseType } from '@augment-vir/core';

*
* const result = filterToEnumValues([1, 2, 3, 'a', 'b', MyEnum.A], MyEnum); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]`
* const result = filterToEnumValues(
* [
* 1,
* 2,
* 3,
* 'a',
* 'b',
* MyEnum.A,
* ],
* MyEnum,
* ); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]`
* ```

@@ -19,0 +29,0 @@ *

@@ -16,3 +16,13 @@ import { check } from '@augment-vir/assert';

*
* const result = filterToEnumValues([1, 2, 3, 'a', 'b', MyEnum.A], MyEnum); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]`
* const result = filterToEnumValues(
* [
* 1,
* 2,
* 3,
* 'a',
* 'b',
* MyEnum.A,
* ],
* MyEnum,
* ); // result is `[MyEnum.A, MyEnum.B, MyEnum.A]`
* ```

@@ -19,0 +29,0 @@ *

@@ -15,3 +15,6 @@ /**

*
* const result1 = combineErrors([new Error('message 1'), new Error('message 2')]); // result1 is a single error with the message 'message 1\nmessage 2'
* const result1 = combineErrors([
* new Error('message 1'),
* new Error('message 2'),
* ]); // result1 is a single error with the message 'message 1\nmessage 2'
* ```

@@ -18,0 +21,0 @@ *

@@ -17,3 +17,6 @@ import { check } from '@augment-vir/assert';

*
* const result1 = combineErrors([new Error('message 1'), new Error('message 2')]); // result1 is a single error with the message 'message 1\nmessage 2'
* const result1 = combineErrors([
* new Error('message 1'),
* new Error('message 2'),
* ]); // result1 is a single error with the message 'message 1\nmessage 2'
* ```

@@ -20,0 +23,0 @@ *

@@ -21,3 +21,13 @@ import { check } from '@augment-vir/assert';

* // `result3` will be `['a', ['b', 'c'], 'd', 'e']`
* const result3 = appendJson(['a'], [['b', 'c']], ['d'], 'e');
* const result3 = appendJson(
* ['a'],
* [
* [
* 'b',
* 'c',
* ],
* ],
* ['d'],
* 'e',
* );
* ```

@@ -24,0 +34,0 @@ *

@@ -19,4 +19,10 @@ import { Jsonify, Writable } from 'type-fest';

* map: new Map([
* ['q', 'r'],
* ['s', 't'],
* [
* 'q',
* 'r',
* ],
* [
* 's',
* 't',
* ],
* ]),

@@ -23,0 +29,0 @@ * b: 'b',

@@ -18,4 +18,10 @@ /**

* map: new Map([
* ['q', 'r'],
* ['s', 't'],
* [
* 'q',
* 'r',
* ],
* [
* 's',
* 't',
* ],
* ]),

@@ -22,0 +28,0 @@ * b: 'b',

@@ -16,4 +16,10 @@ import { Jsonify } from 'type-fest';

* map: new Map([
* ['q', 'r'],
* ['s', 't'],
* [
* 'q',
* 'r',
* ],
* [
* 's',
* 't',
* ],
* ]),

@@ -20,0 +26,0 @@ * b: 'b',

@@ -16,4 +16,10 @@ import JSON5 from 'json5';

* map: new Map([
* ['q', 'r'],
* ['s', 't'],
* [
* 'q',
* 'r',
* ],
* [
* 's',
* 't',
* ],
* ]),

@@ -20,0 +26,0 @@ * b: 'b',

@@ -110,3 +110,6 @@ import { perEnv, RuntimeEnv } from '@augment-vir/core';

[LogColorKey.Mutate]: {
colors: [logColors.mutate, logColors.bold],
colors: [
logColors.mutate,
logColors.bold,
],
logType: LogOutputType.Standard,

@@ -124,7 +127,13 @@ },

[LogColorKey.Success]: {
colors: [logColors.success, logColors.bold],
colors: [
logColors.success,
logColors.bold,
],
logType: LogOutputType.Standard,
},
[LogColorKey.Error]: {
colors: [logColors.error, logColors.bold],
colors: [
logColors.error,
logColors.bold,
],
logType: LogOutputType.Error,

@@ -131,0 +140,0 @@ },

@@ -35,3 +35,6 @@ import { safeMatch } from '../regexp/match.js';

}
return [beforeDot, slicedAfterDot].join('.');
return [
beforeDot,
slicedAfterDot,
].join('.');
}

@@ -42,11 +45,18 @@ }

function truncateBigNumber(numberAsString, suffixes, maxLength) {
const [beforeDot, afterDot] = safeSplit(numberAsString, '.');
const [beforeDot, afterDot,] = safeSplit(numberAsString, '.');
const withCommas = addCommasToNumber(beforeDot);
const truncationDepth = safeMatch(withCommas, /,/g).length;
const suffix = suffixes[truncationDepth - 1];
const [beforeComma, afterComma] = safeSplit(withCommas, ',');
const trailing = [afterComma, afterDot].join('');
const [beforeComma, afterComma,] = safeSplit(withCommas, ',');
const trailing = [
afterComma,
afterDot,
].join('');
if (beforeComma.length + 1 > maxLength) {
// will look like 0.9M
return ['0.', beforeComma[0], suffixes[truncationDepth]].join('');
return [
'0.',
beforeComma[0],
suffixes[truncationDepth],
].join('');
}

@@ -59,3 +69,6 @@ else {

});
return [combined, suffix].join('');
return [
combined,
suffix,
].join('');
}

@@ -66,12 +79,19 @@ }

const valueString = String(input);
const [beforeExponent, rawExponent] = safeSplit(valueString, 'e');
const [beforeExponent, rawExponent,] = safeSplit(valueString, 'e');
const exponent = rawExponent.replace(/^[-+]/, '');
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const plusOrMinus = rawExponent[0];
const eSuffix = ['e', plusOrMinus, exponent].join('');
const [beforeDot, afterDot] = safeSplit(beforeExponent, '.');
const eSuffix = [
'e',
plusOrMinus,
exponent,
].join('');
const [beforeDot, afterDot,] = safeSplit(beforeExponent, '.');
const minLength = exponent.length + minScientificNotationLength;
if (minLength === maxLength) {
// this will look like "4e+4" or "5e-234"
return [beforeDot, eSuffix].join('');
return [
beforeDot,
eSuffix,
].join('');
}

@@ -94,7 +114,10 @@ else if (minLength > maxLength) {

});
return [beforeE, eSuffix].join('');
return [
beforeE,
eSuffix,
].join('');
}
}
function handleSmallNumbers(numberAsString, maxLength) {
const [beforeDot, afterDot] = safeSplit(addCommasToNumber(numberAsString), '.');
const [beforeDot, afterDot,] = safeSplit(addCommasToNumber(numberAsString), '.');
if (beforeDot.length <= maxLength) {

@@ -101,0 +124,0 @@ return combineBeforeAndAfterDot({

@@ -13,3 +13,6 @@ import { check } from '@augment-vir/assert';

export function diffObjects(object0, object1) {
const allObjectKeys = Array.from(new Set([...getObjectTypedKeys(object0), ...getObjectTypedKeys(object1)]));
const allObjectKeys = Array.from(new Set([
...getObjectTypedKeys(object0),
...getObjectTypedKeys(object1),
]));
const diffOutput = allObjectKeys.reduce((accum, objectKey) => {

@@ -33,3 +36,6 @@ const value0 = object0[objectKey];

return accum;
}, [{}, {}]);
}, [
{},
{},
]);
if (!Object.keys(diffOutput[0]).length && !Object.keys(diffOutput[1]).length) {

@@ -52,3 +58,6 @@ return [];

export function diffArrays(array0, array1) {
const allArrayIndexes = Array.from(new Set([...Object.keys(array0), ...Object.keys(array1)].map((index) => Number(index)))).sort();
const allArrayIndexes = Array.from(new Set([
...Object.keys(array0),
...Object.keys(array1),
].map((index) => Number(index)))).sort();
const diffArrays = allArrayIndexes.reduce((accum, arrayIndex) => {

@@ -69,3 +78,6 @@ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion

return accum;
}, [[], []]);
}, [
[],
[],
]);
if (!diffArrays[0].length && !diffArrays[1].length) {

@@ -94,3 +106,6 @@ return [];

else {
return [value0, value1];
return [
value0,
value1,
];
}

@@ -97,0 +112,0 @@ }

@@ -32,3 +32,3 @@ import { check } from '@augment-vir/assert';

const mappedEntries = getObjectTypedEntries(originalObject)
.map(([originalKey, originalValue]) => {
.map(([originalKey, originalValue,]) => {
const output = mapCallback(originalKey, originalValue, originalObject);

@@ -40,3 +40,6 @@ if (output instanceof Promise) {

else if (output) {
return [output.key, output.value];
return [
output.key,
output.value,
];
}

@@ -59,3 +62,6 @@ else {

else {
return [entry.key, entry.value];
return [
entry.key,
entry.value,
];
}

@@ -62,0 +68,0 @@ }, check.isTruthy);

@@ -33,3 +33,3 @@ import { check } from '@augment-vir/assert';

}
Object.entries(individualInput).forEach(([key, value]) => {
Object.entries(individualInput).forEach(([key, value,]) => {
if (!mergeProps[key]) {

@@ -42,3 +42,3 @@ mergeProps[key] = [];

if (check.isObject(result)) {
Object.entries(mergeProps).forEach(([key, mergeValues]) => {
Object.entries(mergeProps).forEach(([key, mergeValues,]) => {
const newValue = mergeDeep(...mergeValues);

@@ -45,0 +45,0 @@ if (newValue === undefined && key in result) {

@@ -25,3 +25,3 @@ import { getObjectTypedEntries } from './object-entries.js';

}
getObjectTypedEntries(entry).forEach(([key, value]) => {
getObjectTypedEntries(entry).forEach(([key, value,]) => {
if (value != undefined) {

@@ -28,0 +28,0 @@ finalObject[key] = value;

@@ -13,6 +13,12 @@ /**

* {
* a: ['a', 'b'],
* a: [
* 'a',
* 'b',
* ],
* },
* {
* a: ['c', 'd'],
* a: [
* 'c',
* 'd',
* ],
* },

@@ -19,0 +25,0 @@ * ); // output is `{a: ['a', 'b', 'c', 'd']}`

@@ -14,6 +14,12 @@ import { getOrSet } from './get-or-set.js';

* {
* a: ['a', 'b'],
* a: [
* 'a',
* 'b',
* ],
* },
* {
* a: ['c', 'd'],
* a: [
* 'c',
* 'd',
* ],
* },

@@ -28,3 +34,3 @@ * ); // output is `{a: ['a', 'b', 'c', 'd']}`

inputs.forEach((input) => {
Object.entries(input).forEach(([key, newArray]) => {
Object.entries(input).forEach(([key, newArray,]) => {
const currentArray = getOrSet(combined, key, () => []);

@@ -31,0 +37,0 @@ currentArray.push(...newArray);

@@ -12,3 +12,6 @@ import { getObjectTypedKeys } from '@augment-vir/core';

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

@@ -15,0 +18,0 @@ /**

@@ -23,3 +23,3 @@ import { getObjectTypedEntries, typedObjectFromEntries } from './object-entries.js';

export function filterObject(inputObject, callback) {
const filteredEntries = getObjectTypedEntries(inputObject).filter(([key, value]) => {
const filteredEntries = getObjectTypedEntries(inputObject).filter(([key, value,]) => {
return callback(key, value, inputObject);

@@ -26,0 +26,0 @@ });

@@ -20,3 +20,6 @@ import { removeDuplicateCharacters } from '../string/remove-duplicate-characters.js';

export function addRegExpFlags(originalRegExpOrString, flags) {
const allFlags = removeDuplicateCharacters([typeof originalRegExpOrString === 'string' ? '' : originalRegExpOrString.flags, flags]
const allFlags = removeDuplicateCharacters([
typeof originalRegExpOrString === 'string' ? '' : originalRegExpOrString.flags,
flags,
]
.join('')

@@ -23,0 +26,0 @@ .toLowerCase());

@@ -36,3 +36,3 @@ import { safeMatch } from '../regexp/match.js';

const stringValue = String(Math.abs(numericValue));
const [digits = '', decimalValues] = stringValue.split('.');
const [digits = '', decimalValues,] = stringValue.split('.');
const decimalString = decimalValues ? `.${decimalValues}` : '';

@@ -44,3 +44,7 @@ const separated = safeMatch(digits.split('').reverse().join(''), /.{1,3}/g)

const negativeMarker = isNegative ? '-' : '';
return [negativeMarker, valueWithCommas, decimalString].join('');
return [
negativeMarker,
valueWithCommas,
decimalString,
].join('');
}
{
"name": "@augment-vir/common",
"version": "31.9.1",
"version": "31.9.2",
"description": "A collection of augments, helpers types, functions, and classes for any JavaScript environment.",

@@ -42,13 +42,13 @@ "keywords": [

"dependencies": {
"@augment-vir/assert": "^31.9.1",
"@augment-vir/core": "^31.9.1",
"@date-vir/duration": "^7.1.2",
"@augment-vir/assert": "^31.9.2",
"@augment-vir/core": "^31.9.2",
"@date-vir/duration": "^7.2.0",
"ansi-styles": "^6.2.1",
"json5": "^2.2.3",
"type-fest": "^4.33.0",
"type-fest": "^4.35.0",
"typed-event-target": "^4.0.2"
},
"devDependencies": {
"@web/dev-server-esbuild": "^1.0.3",
"@web/test-runner": "^0.19.0",
"@web/dev-server-esbuild": "^1.0.4",
"@web/test-runner": "^0.20.0",
"@web/test-runner-commands": "^0.9.0",

@@ -60,3 +60,3 @@ "@web/test-runner-playwright": "^0.11.0",

"istanbul-smart-text-reporter": "^1.1.5",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
},

@@ -63,0 +63,0 @@ "engines": {

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