@augment-vir/common
Advanced tools
Comparing version 28.2.4 to 29.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.filterMap = exports.arrayToObject = exports.groupArrayBy = exports.repeatArray = exports.typedMap = exports.typedArrayIncludes = exports.trimArrayStrings = exports.flatten2dArray = exports.filterOutIndexes = void 0; | ||
exports.filterOutIndexes = filterOutIndexes; | ||
exports.flatten2dArray = flatten2dArray; | ||
exports.trimArrayStrings = trimArrayStrings; | ||
exports.typedArrayIncludes = typedArrayIncludes; | ||
exports.typedMap = typedMap; | ||
exports.repeatArray = repeatArray; | ||
exports.groupArrayBy = groupArrayBy; | ||
exports.arrayToObject = arrayToObject; | ||
exports.filterMap = filterMap; | ||
const get_or_set_1 = require("../object/get-or-set"); | ||
@@ -9,3 +17,2 @@ const object_entries_1 = require("../object/object-entries"); | ||
} | ||
exports.filterOutIndexes = filterOutIndexes; | ||
function flatten2dArray(array2d) { | ||
@@ -15,11 +22,8 @@ const flattened = array2d.reduce((accum, row) => accum.concat(row), []); | ||
} | ||
exports.flatten2dArray = flatten2dArray; | ||
function trimArrayStrings(input) { | ||
return input.map((line) => line.trim()).filter((line) => line !== ''); | ||
} | ||
exports.trimArrayStrings = trimArrayStrings; | ||
function typedArrayIncludes(array, input) { | ||
return array.includes(input); | ||
} | ||
exports.typedArrayIncludes = typedArrayIncludes; | ||
/** Preserves tuple types. */ | ||
@@ -29,7 +33,5 @@ function typedMap(arrayToMap, mapCallback) { | ||
} | ||
exports.typedMap = typedMap; | ||
function repeatArray(repeatCount, array) { | ||
return Array.from({ length: repeatCount }, () => [...array]).flat(); | ||
} | ||
exports.repeatArray = repeatArray; | ||
/** | ||
@@ -47,3 +49,2 @@ * Polyfill for `Object.groupBy`: | ||
} | ||
exports.groupArrayBy = groupArrayBy; | ||
/** | ||
@@ -62,3 +63,2 @@ * Like `groupArrayBy` but maps array entries to a single key. Meaning, the resulting object does | ||
} | ||
exports.arrayToObject = arrayToObject; | ||
function filterMap(inputArray, mapCallback, filterCallback) { | ||
@@ -74,2 +74,1 @@ return inputArray.reduce((accum, entry, index, originalArray) => { | ||
} | ||
exports.filterMap = filterMap; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeDuplicates = void 0; | ||
exports.removeDuplicates = removeDuplicates; | ||
function removeDuplicates(originalArray, calculateUniqueIdCallback) { | ||
@@ -17,2 +17,1 @@ const grouped = new Map(); | ||
} | ||
exports.removeDuplicates = removeDuplicates; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.awaitedFilter = exports.awaitedBlockingMap = exports.awaitedForEach = void 0; | ||
exports.awaitedForEach = awaitedForEach; | ||
exports.awaitedBlockingMap = awaitedBlockingMap; | ||
exports.awaitedFilter = awaitedFilter; | ||
/** | ||
@@ -12,3 +14,2 @@ * Acts like calling Array.prototype.forEach in that all elements are executed upon in order, and | ||
} | ||
exports.awaitedForEach = awaitedForEach; | ||
async function awaitedBlockingMap(input, callback) { | ||
@@ -23,3 +24,2 @@ const mappedValues = await input.reduce(async (accumPromise, currentElement, index, wholeArray) => { | ||
} | ||
exports.awaitedBlockingMap = awaitedBlockingMap; | ||
async function awaitedFilter(arrayInput, filterCallback, options) { | ||
@@ -31,2 +31,1 @@ const callbackResults = options?.blocking | ||
} | ||
exports.awaitedFilter = awaitedFilter; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ifTruthy = exports.isFalsy = exports.isTruthy = void 0; | ||
exports.isTruthy = isTruthy; | ||
exports.isFalsy = isFalsy; | ||
exports.ifTruthy = ifTruthy; | ||
function isTruthy(input) { | ||
return !!input; | ||
} | ||
exports.isTruthy = isTruthy; | ||
function isFalsy(input) { | ||
return !input; | ||
} | ||
exports.isFalsy = isFalsy; | ||
function ifTruthy(checkThis, ifTruthyCallback, ifFalsyCallback) { | ||
@@ -20,2 +20,1 @@ if (isTruthy(checkThis)) { | ||
} | ||
exports.ifTruthy = ifTruthy; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.clamp = exports.round = exports.wrapNumber = exports.toMaybeNumber = exports.toEnsuredNumber = exports.convertIntoNumber = exports.toNumber = exports.ensureMinAndMax = exports.doesRequireScientificNotation = exports.addCommasToNumber = exports.NaNString = void 0; | ||
exports.convertIntoNumber = exports.NaNString = void 0; | ||
exports.addCommasToNumber = addCommasToNumber; | ||
exports.doesRequireScientificNotation = doesRequireScientificNotation; | ||
exports.ensureMinAndMax = ensureMinAndMax; | ||
exports.toNumber = toNumber; | ||
exports.toEnsuredNumber = toEnsuredNumber; | ||
exports.toMaybeNumber = toMaybeNumber; | ||
exports.wrapNumber = wrapNumber; | ||
exports.round = round; | ||
exports.clamp = clamp; | ||
const common_string_1 = require("./common-string"); | ||
@@ -27,7 +36,5 @@ const regexp_1 = require("./regexp"); | ||
} | ||
exports.addCommasToNumber = addCommasToNumber; | ||
function doesRequireScientificNotation(input) { | ||
return String(input).includes('e'); | ||
} | ||
exports.doesRequireScientificNotation = doesRequireScientificNotation; | ||
/** | ||
@@ -45,3 +52,2 @@ * Given a min and max, ensures that they are in correct order. Meaning, min is less than max. If | ||
} | ||
exports.ensureMinAndMax = ensureMinAndMax; | ||
/** | ||
@@ -62,3 +68,2 @@ * Tries to convert the input into a number. Handles strings with commas. Note: this might return | ||
} | ||
exports.toNumber = toNumber; | ||
/** @deprecated Use {@link toNumber} instead. */ | ||
@@ -76,3 +81,2 @@ exports.convertIntoNumber = toNumber; | ||
} | ||
exports.toEnsuredNumber = toEnsuredNumber; | ||
/** Tries to convert the input into a number and returns `undefined` if `NaN` is created. */ | ||
@@ -88,3 +92,2 @@ function toMaybeNumber(input) { | ||
} | ||
exports.toMaybeNumber = toMaybeNumber; | ||
/** | ||
@@ -106,3 +109,2 @@ * If the given value is outside the given min/max bounds, instead of clamping the number (as the | ||
} | ||
exports.wrapNumber = wrapNumber; | ||
function round(inputs) { | ||
@@ -113,3 +115,2 @@ const digitFactor = Math.pow(10, inputs.digits); | ||
} | ||
exports.round = round; | ||
/** Clamp's the given value to within the min and max bounds, inclusive. */ | ||
@@ -119,2 +120,1 @@ function clamp({ value, min, max }) { | ||
} | ||
exports.clamp = clamp; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.typedSplit = exports.getAllIndexesOf = exports.escapeStringForRegExp = exports.replaceStringAtIndex = exports.camelCaseToKebabCase = exports.isCase = exports.hasCase = exports.StringCaseEnum = exports.kebabCaseToCamelCase = exports.capitalizeFirstLetter = exports.splitIncludeSplit = exports.collapseWhiteSpace = exports.removeCommasFromNumberString = exports.removeColor = exports.removeAnsiEscapeCodes = exports.wrapString = exports.joinWithFinalConjunction = void 0; | ||
exports.StringCaseEnum = exports.removeColor = void 0; | ||
exports.joinWithFinalConjunction = joinWithFinalConjunction; | ||
exports.wrapString = wrapString; | ||
exports.removeAnsiEscapeCodes = removeAnsiEscapeCodes; | ||
exports.removeCommasFromNumberString = removeCommasFromNumberString; | ||
exports.collapseWhiteSpace = collapseWhiteSpace; | ||
exports.splitIncludeSplit = splitIncludeSplit; | ||
exports.capitalizeFirstLetter = capitalizeFirstLetter; | ||
exports.kebabCaseToCamelCase = kebabCaseToCamelCase; | ||
exports.hasCase = hasCase; | ||
exports.isCase = isCase; | ||
exports.camelCaseToKebabCase = camelCaseToKebabCase; | ||
exports.replaceStringAtIndex = replaceStringAtIndex; | ||
exports.escapeStringForRegExp = escapeStringForRegExp; | ||
exports.getAllIndexesOf = getAllIndexesOf; | ||
exports.typedSplit = typedSplit; | ||
const ansi_1 = require("./ansi"); | ||
@@ -30,3 +45,2 @@ const regexp_1 = require("./regexp"); | ||
} | ||
exports.joinWithFinalConjunction = joinWithFinalConjunction; | ||
/** Wraps `value` on both sides with `wrapper`. */ | ||
@@ -39,7 +53,5 @@ function wrapString({ value, wrapper }) { | ||
} | ||
exports.wrapString = wrapString; | ||
function removeAnsiEscapeCodes(input) { | ||
return input.replace(ansi_1.ansiRegex, ''); | ||
} | ||
exports.removeAnsiEscapeCodes = removeAnsiEscapeCodes; | ||
exports.removeColor = removeAnsiEscapeCodes; | ||
@@ -49,3 +61,2 @@ function removeCommasFromNumberString(numberString) { | ||
} | ||
exports.removeCommasFromNumberString = removeCommasFromNumberString; | ||
/** Collapse all consecutive white space into just one space and trim surrounding whitespace. */ | ||
@@ -62,3 +73,2 @@ function collapseWhiteSpace(input, { keepNewLines } = {}) { | ||
} | ||
exports.collapseWhiteSpace = collapseWhiteSpace; | ||
/** Same as String.prototype.split but includes the delimiter to split by in the output array. */ | ||
@@ -88,3 +98,2 @@ function splitIncludeSplit(original, splitterInput, caseSensitive) { | ||
} | ||
exports.splitIncludeSplit = splitIncludeSplit; | ||
const defaultCasingOptions = { | ||
@@ -100,3 +109,2 @@ capitalizeFirstLetter: false, | ||
} | ||
exports.capitalizeFirstLetter = capitalizeFirstLetter; | ||
function maybeCapitalize(input, casingOptions) { | ||
@@ -124,3 +132,2 @@ return casingOptions.capitalizeFirstLetter ? capitalizeFirstLetter(input) : input; | ||
} | ||
exports.kebabCaseToCamelCase = kebabCaseToCamelCase; | ||
var StringCaseEnum; | ||
@@ -135,3 +142,2 @@ (function (StringCaseEnum) { | ||
} | ||
exports.hasCase = hasCase; | ||
/** | ||
@@ -168,3 +174,2 @@ * Checks if the given string is exclusively of the specific case. | ||
} | ||
exports.isCase = isCase; | ||
function camelCaseToKebabCase(rawCamelCase) { | ||
@@ -191,3 +196,2 @@ const kebabCase = rawCamelCase | ||
} | ||
exports.camelCaseToKebabCase = camelCaseToKebabCase; | ||
function replaceStringAtIndex(originalString, start, newString, length = newString.length) { | ||
@@ -198,3 +202,2 @@ const before = originalString.substring(0, start); | ||
} | ||
exports.replaceStringAtIndex = replaceStringAtIndex; | ||
/** | ||
@@ -207,3 +210,2 @@ * Escapes characters from the given string so that it can be used within a RegExp without being | ||
} | ||
exports.escapeStringForRegExp = escapeStringForRegExp; | ||
function makeCaseInsensitiveRegExp(searchForInput, caseSensitive) { | ||
@@ -253,6 +255,4 @@ const regExpFlags = `g${!caseSensitive && typeof searchForInput === 'string' ? 'i' : ''}`; | ||
} | ||
exports.getAllIndexesOf = getAllIndexesOf; | ||
function typedSplit(input, splitString) { | ||
return input.split(splitString); | ||
} | ||
exports.typedSplit = typedSplit; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createDebounce = exports.DebounceStyle = void 0; | ||
exports.DebounceStyle = void 0; | ||
exports.createDebounce = createDebounce; | ||
var DebounceStyle; | ||
@@ -38,2 +39,1 @@ (function (DebounceStyle) { | ||
} | ||
exports.createDebounce = createDebounce; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isBrowser = void 0; | ||
exports.isBrowser = isBrowser; | ||
function isBrowser() { | ||
return typeof window !== 'undefined'; | ||
} | ||
exports.isBrowser = isBrowser; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ensureErrorAndPrependMessage = exports.ensureError = exports.extractErrorMessage = exports.combineErrorMessages = exports.combineErrors = void 0; | ||
exports.combineErrors = combineErrors; | ||
exports.combineErrorMessages = combineErrorMessages; | ||
exports.extractErrorMessage = extractErrorMessage; | ||
exports.ensureError = ensureError; | ||
exports.ensureErrorAndPrependMessage = ensureErrorAndPrependMessage; | ||
const boolean_1 = require("./boolean"); | ||
@@ -16,3 +20,2 @@ const typed_has_property_1 = require("./object/typed-has-property"); | ||
} | ||
exports.combineErrors = combineErrors; | ||
function combineErrorMessages(errors) { | ||
@@ -24,3 +27,2 @@ if (!errors) { | ||
} | ||
exports.combineErrorMessages = combineErrorMessages; | ||
function extractErrorMessage(maybeError) { | ||
@@ -40,3 +42,2 @@ if (!maybeError) { | ||
} | ||
exports.extractErrorMessage = extractErrorMessage; | ||
function ensureError(maybeError) { | ||
@@ -50,3 +51,2 @@ if (maybeError instanceof Error) { | ||
} | ||
exports.ensureError = ensureError; | ||
function ensureErrorAndPrependMessage(maybeError, prependMessage) { | ||
@@ -57,2 +57,1 @@ const error = ensureError(maybeError); | ||
} | ||
exports.ensureErrorAndPrependMessage = ensureErrorAndPrependMessage; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getEsmPath = void 0; | ||
exports.getEsmPath = getEsmPath; | ||
function getEsmPath(importMeta) { | ||
@@ -12,2 +12,1 @@ const filePath = new URL('', importMeta.url).pathname; | ||
} | ||
exports.getEsmPath = getEsmPath; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stringifyJson = exports.parseJson = void 0; | ||
exports.parseJson = parseJson; | ||
exports.stringifyJson = stringifyJson; | ||
const wrap_in_try_1 = require("./wrap-in-try"); | ||
@@ -19,3 +20,2 @@ function parseJson({ jsonString, errorHandler, }) { | ||
} | ||
exports.parseJson = parseJson; | ||
function stringifyJson(jsonValue, { whitespace, ...tryOptions } = {}) { | ||
@@ -30,2 +30,1 @@ const result = (0, wrap_in_try_1.wrapInTry)(() => JSON.stringify(jsonValue, undefined, whitespace), tryOptions); | ||
} | ||
exports.stringifyJson = stringifyJson; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.filterToEnumValues = exports.ensureEnum = exports.isEnumValue = exports.getEnumTypedValues = exports.getEnumTypedKeys = void 0; | ||
exports.getEnumTypedKeys = getEnumTypedKeys; | ||
exports.getEnumTypedValues = getEnumTypedValues; | ||
exports.isEnumValue = isEnumValue; | ||
exports.ensureEnum = ensureEnum; | ||
exports.filterToEnumValues = filterToEnumValues; | ||
const object_entries_1 = require("./object-entries"); | ||
@@ -9,3 +13,2 @@ function getEnumTypedKeys(input) { | ||
} | ||
exports.getEnumTypedKeys = getEnumTypedKeys; | ||
function getEnumTypedValues(input) { | ||
@@ -15,3 +18,2 @@ const keys = getEnumTypedKeys(input); | ||
} | ||
exports.getEnumTypedValues = getEnumTypedValues; | ||
/** Check if the given value is within the given enum. */ | ||
@@ -21,3 +23,2 @@ function isEnumValue(input, checkEnum) { | ||
} | ||
exports.isEnumValue = isEnumValue; | ||
/** Interpret a primitive as an enum value with type safety. */ | ||
@@ -33,3 +34,2 @@ function ensureEnum(value, checkEnum) { | ||
} | ||
exports.ensureEnum = ensureEnum; | ||
function filterToEnumValues(inputs, checkEnum, caseInsensitive = false) { | ||
@@ -53,2 +53,1 @@ if (caseInsensitive) { | ||
} | ||
exports.filterToEnumValues = filterToEnumValues; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pickObjectKeys = exports.omitObjectKeys = exports.filterObject = void 0; | ||
exports.filterObject = filterObject; | ||
exports.omitObjectKeys = omitObjectKeys; | ||
exports.pickObjectKeys = pickObjectKeys; | ||
const object_entries_1 = require("./object-entries"); | ||
@@ -15,3 +17,2 @@ function filterObject(inputObject, callback) { | ||
} | ||
exports.filterObject = filterObject; | ||
function omitObjectKeys(inputObject, omitTheseKeys) { | ||
@@ -22,3 +23,2 @@ return filterObject(inputObject, (currentKey) => { | ||
} | ||
exports.omitObjectKeys = omitObjectKeys; | ||
function pickObjectKeys(inputObject, pickTheseKeys) { | ||
@@ -29,2 +29,1 @@ return filterObject(inputObject, (currentKey) => { | ||
} | ||
exports.pickObjectKeys = pickObjectKeys; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getOrSet = exports.getOrSetFromMap = void 0; | ||
exports.getOrSetFromMap = getOrSetFromMap; | ||
exports.getOrSet = getOrSet; | ||
const run_time_assertions_1 = require("run-time-assertions"); | ||
@@ -16,3 +17,2 @@ function getOrSetFromMap(map, key, createNewValueCallback) { | ||
} | ||
exports.getOrSetFromMap = getOrSetFromMap; | ||
function getOrSet(originalObject, key, createCallback) { | ||
@@ -42,2 +42,1 @@ if (key in originalObject) { | ||
} | ||
exports.getOrSet = getOrSet; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.hasKey = void 0; | ||
exports.hasKey = hasKey; | ||
function hasKey(parent, property) { | ||
return property in parent; | ||
} | ||
exports.hasKey = hasKey; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.jsonify = void 0; | ||
exports.jsonify = jsonify; | ||
function jsonify(input) { | ||
return JSON.parse(JSON.stringify(input)); | ||
} | ||
exports.jsonify = jsonify; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mapObjectValues = exports.mapObjectValuesSync = void 0; | ||
exports.mapObjectValuesSync = mapObjectValuesSync; | ||
exports.mapObjectValues = mapObjectValues; | ||
const object_entries_1 = require("./object-entries"); | ||
@@ -27,3 +28,2 @@ /** | ||
} | ||
exports.mapObjectValuesSync = mapObjectValuesSync; | ||
/** | ||
@@ -63,2 +63,1 @@ * Creates a new object with the same properties as the input object, but with values set to the | ||
} | ||
exports.mapObjectValues = mapObjectValues; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mergeDeep = void 0; | ||
exports.mergeDeep = mergeDeep; | ||
const run_time_assertions_1 = require("run-time-assertions"); | ||
@@ -53,2 +53,1 @@ const tuple_1 = require("../tuple"); | ||
} | ||
exports.mergeDeep = mergeDeep; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.mergePropertyArrays = void 0; | ||
exports.mergePropertyArrays = mergePropertyArrays; | ||
const get_or_set_1 = require("./get-or-set"); | ||
@@ -15,2 +15,1 @@ function mergePropertyArrays(...inputs) { | ||
} | ||
exports.mergePropertyArrays = mergePropertyArrays; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.typedObjectFromEntries = exports.getEntriesSortedByKey = exports.getObjectTypedEntries = exports.getObjectTypedValues = exports.getObjectTypedKeys = exports.isKeyof = void 0; | ||
exports.isKeyof = isKeyof; | ||
exports.getObjectTypedKeys = getObjectTypedKeys; | ||
exports.getObjectTypedValues = getObjectTypedValues; | ||
exports.getObjectTypedEntries = getObjectTypedEntries; | ||
exports.getEntriesSortedByKey = getEntriesSortedByKey; | ||
exports.typedObjectFromEntries = typedObjectFromEntries; | ||
const typed_has_property_1 = require("./typed-has-property"); | ||
@@ -9,3 +14,2 @@ /** @deprecated This is the same as hasKey */ | ||
} | ||
exports.isKeyof = isKeyof; | ||
function getObjectTypedKeys(input) { | ||
@@ -23,7 +27,5 @@ let reflectKeys; | ||
} | ||
exports.getObjectTypedKeys = getObjectTypedKeys; | ||
function getObjectTypedValues(input) { | ||
return getObjectTypedKeys(input).map((key) => input[key]); | ||
} | ||
exports.getObjectTypedValues = getObjectTypedValues; | ||
function getObjectTypedEntries(input) { | ||
@@ -35,10 +37,7 @@ return getObjectTypedKeys(input).map((key) => [ | ||
} | ||
exports.getObjectTypedEntries = getObjectTypedEntries; | ||
function getEntriesSortedByKey(input) { | ||
return Object.entries(input).sort((tupleA, tupleB) => tupleA[0].localeCompare(tupleB[0])); | ||
} | ||
exports.getEntriesSortedByKey = getEntriesSortedByKey; | ||
function typedObjectFromEntries(entries) { | ||
return Object.fromEntries(entries); | ||
} | ||
exports.typedObjectFromEntries = typedObjectFromEntries; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.copyThroughJson = exports.isObject = void 0; | ||
exports.isObject = isObject; | ||
exports.copyThroughJson = copyThroughJson; | ||
/** Checks if the input is non-null and an object. Includes arrays. */ | ||
@@ -8,3 +9,2 @@ function isObject(input) { | ||
} | ||
exports.isObject = isObject; | ||
/** The input here must be serializable otherwise JSON parsing errors will be thrown */ | ||
@@ -20,2 +20,1 @@ function copyThroughJson(input) { | ||
} | ||
exports.copyThroughJson = copyThroughJson; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.typedHasProperties = exports.typedHasProperty = void 0; | ||
exports.typedHasProperty = typedHasProperty; | ||
exports.typedHasProperties = typedHasProperties; | ||
const hasPropertyAttempts = [ | ||
@@ -26,6 +27,4 @@ (object, key) => { | ||
} | ||
exports.typedHasProperty = typedHasProperty; | ||
function typedHasProperties(inputObject, inputKeys) { | ||
return inputObject && inputKeys.every((key) => typedHasProperty(inputObject, key)); | ||
} | ||
exports.typedHasProperties = typedHasProperties; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createDeferredPromiseWrapper = void 0; | ||
exports.createDeferredPromiseWrapper = createDeferredPromiseWrapper; | ||
function createDeferredPromiseWrapper() { | ||
@@ -32,2 +32,1 @@ let resolve; | ||
} | ||
exports.createDeferredPromiseWrapper = createDeferredPromiseWrapper; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.executeWithRetries = exports.callAsynchronously = exports.wrapPromiseInTimeout = exports.PromiseTimeoutError = exports.isPromiseLike = void 0; | ||
exports.PromiseTimeoutError = void 0; | ||
exports.isPromiseLike = isPromiseLike; | ||
exports.wrapPromiseInTimeout = wrapPromiseInTimeout; | ||
exports.callAsynchronously = callAsynchronously; | ||
exports.executeWithRetries = executeWithRetries; | ||
const typed_has_property_1 = require("../object/typed-has-property"); | ||
@@ -13,3 +17,2 @@ function isPromiseLike(input) { | ||
} | ||
exports.isPromiseLike = isPromiseLike; | ||
class PromiseTimeoutError extends Error { | ||
@@ -58,3 +61,2 @@ constructor(durationMs, message = `Promised timed out after ${durationMs} ms.`) { | ||
} | ||
exports.wrapPromiseInTimeout = wrapPromiseInTimeout; | ||
/** | ||
@@ -67,3 +69,2 @@ * Call a function asynchronously without interrupting current synchronous execution, even if the | ||
} | ||
exports.callAsynchronously = callAsynchronously; | ||
async function executeWithRetries(retryCount, callback) { | ||
@@ -82,2 +83,1 @@ let currentRetry = 0; | ||
} | ||
exports.executeWithRetries = executeWithRetries; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.waitUntilTruthy = exports.defaultWaitUntilDefinedOptions = exports.waitValue = exports.wait = void 0; | ||
exports.defaultWaitUntilDefinedOptions = void 0; | ||
exports.wait = wait; | ||
exports.waitValue = waitValue; | ||
exports.waitUntilTruthy = waitUntilTruthy; | ||
const error_1 = require("../error"); | ||
@@ -15,7 +18,5 @@ const deferred_promise_1 = require("./deferred-promise"); | ||
} | ||
exports.wait = wait; | ||
async function waitValue(delayMs, returnValue) { | ||
return wait(delayMs).then(() => returnValue); | ||
} | ||
exports.waitValue = waitValue; | ||
exports.defaultWaitUntilDefinedOptions = { | ||
@@ -67,2 +68,1 @@ interval: { | ||
} | ||
exports.waitUntilTruthy = waitUntilTruthy; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.randomString = exports.createUuid = exports.randomBoolean = exports.randomInteger = void 0; | ||
exports.randomInteger = randomInteger; | ||
exports.randomBoolean = randomBoolean; | ||
exports.createUuid = createUuid; | ||
exports.randomString = randomString; | ||
const common_number_1 = require("./common-number"); | ||
@@ -35,3 +38,2 @@ function accessCrypto() { | ||
} | ||
exports.randomInteger = randomInteger; | ||
/** | ||
@@ -65,3 +67,2 @@ * Returns true at rate of the percentLikelyToBeTrue input. Inputs should be whole numbers which | ||
} | ||
exports.randomBoolean = randomBoolean; | ||
/** Creates a cryptographically secure uuid. */ | ||
@@ -71,3 +72,2 @@ function createUuid() { | ||
} | ||
exports.createUuid = createUuid; | ||
const validStringCharacters = [ | ||
@@ -127,2 +127,1 @@ 'a', | ||
} | ||
exports.randomString = randomString; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.safeMatch = exports.addRegExpFlags = exports.deDupeRegExFlags = void 0; | ||
exports.deDupeRegExFlags = deDupeRegExFlags; | ||
exports.addRegExpFlags = addRegExpFlags; | ||
exports.safeMatch = safeMatch; | ||
function deDupeRegExFlags(flags) { | ||
@@ -8,3 +10,2 @@ const deDuped = new Set(Array.from(flags.toLowerCase())); | ||
} | ||
exports.deDupeRegExFlags = deDupeRegExFlags; | ||
function addRegExpFlags(originalRegExp, flags) { | ||
@@ -16,3 +17,2 @@ return new RegExp(originalRegExp.source, deDupeRegExFlags([ | ||
} | ||
exports.addRegExpFlags = addRegExpFlags; | ||
function safeMatch(input, regExp) { | ||
@@ -22,2 +22,1 @@ const match = input.match(regExp); | ||
} | ||
exports.safeMatch = safeMatch; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removePrefix = exports.addPrefix = void 0; | ||
exports.addPrefix = addPrefix; | ||
exports.removePrefix = removePrefix; | ||
function addPrefix({ value, prefix, }) { | ||
@@ -12,3 +13,2 @@ if (String(value).startsWith(prefix)) { | ||
} | ||
exports.addPrefix = addPrefix; | ||
function removePrefix({ value, prefix, }) { | ||
@@ -22,2 +22,1 @@ if (value.startsWith(prefix)) { | ||
} | ||
exports.removePrefix = removePrefix; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.removeSuffix = exports.addSuffix = exports.removePercent = exports.addPercent = exports.removePx = exports.addPx = exports.pxSuffix = exports.percentSuffix = void 0; | ||
exports.pxSuffix = exports.percentSuffix = void 0; | ||
exports.addPx = addPx; | ||
exports.removePx = removePx; | ||
exports.addPercent = addPercent; | ||
exports.removePercent = removePercent; | ||
exports.addSuffix = addSuffix; | ||
exports.removeSuffix = removeSuffix; | ||
const common_number_1 = require("../common-number"); | ||
@@ -10,15 +16,11 @@ exports.percentSuffix = '%'; | ||
} | ||
exports.addPx = addPx; | ||
function removePx(input) { | ||
return (0, common_number_1.toEnsuredNumber)(removeSuffix({ value: input, suffix: exports.pxSuffix })); | ||
} | ||
exports.removePx = removePx; | ||
function addPercent(input) { | ||
return addSuffix({ value: input, suffix: exports.percentSuffix }); | ||
} | ||
exports.addPercent = addPercent; | ||
function removePercent(input) { | ||
return (0, common_number_1.toEnsuredNumber)(removeSuffix({ value: input, suffix: exports.percentSuffix })); | ||
} | ||
exports.removePercent = removePercent; | ||
function addSuffix({ value, suffix, }) { | ||
@@ -32,3 +34,2 @@ if (String(value).endsWith(suffix)) { | ||
} | ||
exports.addSuffix = addSuffix; | ||
function removeSuffix({ value, suffix, }) { | ||
@@ -42,2 +43,1 @@ if (value.endsWith(suffix)) { | ||
} | ||
exports.removeSuffix = removeSuffix; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isUuid = void 0; | ||
exports.isUuid = isUuid; | ||
const uuidRegExp = /[\d\w]{8}-[\d\w]{4}-[\d\w]{4}-[\d\w]{4}-[\d\w]{12}/; | ||
@@ -8,2 +8,1 @@ function isUuid(maybeUuid) { | ||
} | ||
exports.isUuid = isUuid; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.measureCallbackDuration = exports.timeCallback = void 0; | ||
exports.measureCallbackDuration = void 0; | ||
exports.timeCallback = timeCallback; | ||
/** | ||
@@ -27,3 +28,2 @@ * Measures how long (in milliseconds) the given callback takes to run to completion. Automatically | ||
} | ||
exports.timeCallback = timeCallback; | ||
/** | ||
@@ -30,0 +30,0 @@ * Measures how long (in milliseconds) the given callback takes to run to completion. Automatically |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.truncateNumber = void 0; | ||
exports.truncateNumber = truncateNumber; | ||
const common_number_1 = require("./common-number"); | ||
@@ -154,2 +154,1 @@ const common_string_1 = require("./common-string"); | ||
} | ||
exports.truncateNumber = truncateNumber; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.assertLengthAtLeast = exports.isLengthAtLeast = void 0; | ||
exports.isLengthAtLeast = isLengthAtLeast; | ||
exports.assertLengthAtLeast = assertLengthAtLeast; | ||
function isLengthAtLeast(array, length) { | ||
@@ -13,3 +14,2 @@ try { | ||
} | ||
exports.isLengthAtLeast = isLengthAtLeast; | ||
function assertLengthAtLeast(array, length, arrayName) { | ||
@@ -22,2 +22,1 @@ if (array.length < length) { | ||
} | ||
exports.assertLengthAtLeast = assertLengthAtLeast; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ensureType = exports.wrapNarrowTypeWithTypeCheck = exports.makeReadonly = exports.makeWritable = void 0; | ||
exports.makeWritable = makeWritable; | ||
exports.makeReadonly = makeReadonly; | ||
exports.wrapNarrowTypeWithTypeCheck = wrapNarrowTypeWithTypeCheck; | ||
exports.ensureType = ensureType; | ||
function makeWritable(input) { | ||
return input; | ||
} | ||
exports.makeWritable = makeWritable; | ||
function makeReadonly(input) { | ||
return input; | ||
} | ||
exports.makeReadonly = makeReadonly; | ||
/** | ||
@@ -26,3 +27,2 @@ * This function returns another function that simply returns whatever input it's given. However, it | ||
} | ||
exports.wrapNarrowTypeWithTypeCheck = wrapNarrowTypeWithTypeCheck; | ||
/** | ||
@@ -38,2 +38,1 @@ * This is a type helper that ensures the given input matches the given generic type. The generic is | ||
} | ||
exports.ensureType = ensureType; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.wrapInTry = void 0; | ||
exports.wrapInTry = wrapInTry; | ||
const run_time_assertions_1 = require("run-time-assertions"); | ||
@@ -38,2 +38,1 @@ const error_1 = require("./error"); | ||
} | ||
exports.wrapInTry = wrapInTry; |
@@ -37,10 +37,10 @@ "use strict"; | ||
__exportStar(require("./augments/object/jsonify"), exports); | ||
__exportStar(require("./augments/object/key-count"), exports); | ||
__exportStar(require("./augments/object/map-object"), exports); | ||
__exportStar(require("./augments/object/merge-deep"), exports); | ||
__exportStar(require("./augments/object/merge-property-arrays"), exports); | ||
__exportStar(require("./augments/object/nested-keys"), exports); | ||
__exportStar(require("./augments/object/object"), exports); | ||
__exportStar(require("./augments/object/object-entries"), exports); | ||
__exportStar(require("./augments/object/old-union-to-intersection"), exports); | ||
__exportStar(require("./augments/object/pick-deep"), exports); | ||
__exportStar(require("./augments/object/selection-set"), exports); | ||
__exportStar(require("./augments/object/typed-has-property"), exports); | ||
@@ -60,2 +60,3 @@ __exportStar(require("./augments/promise/deferred-promise"), exports); | ||
__exportStar(require("./augments/type-recursion"), exports); | ||
__exportStar(require("./augments/union"), exports); | ||
__exportStar(require("./augments/wrap-in-try"), exports); |
@@ -21,10 +21,10 @@ export * from './augments/ansi'; | ||
export * from './augments/object/jsonify'; | ||
export * from './augments/object/key-count'; | ||
export * from './augments/object/map-object'; | ||
export * from './augments/object/merge-deep'; | ||
export * from './augments/object/merge-property-arrays'; | ||
export * from './augments/object/nested-keys'; | ||
export * from './augments/object/object'; | ||
export * from './augments/object/object-entries'; | ||
export * from './augments/object/old-union-to-intersection'; | ||
export * from './augments/object/pick-deep'; | ||
export * from './augments/object/selection-set'; | ||
export * from './augments/object/typed-has-property'; | ||
@@ -44,2 +44,3 @@ export * from './augments/promise/deferred-promise'; | ||
export * from './augments/type-recursion'; | ||
export * from './augments/union'; | ||
export * from './augments/wrap-in-try'; |
@@ -15,3 +15,3 @@ import { PropertyValueType } from './object'; | ||
*/ | ||
export declare function mapObjectValuesSync<EntireInputGeneric extends object>(inputObject: EntireInputGeneric): <OutputObjectGeneric extends object>(mapCallback: (inputKey: keyof EntireInputGeneric, keyValue: EntireInputGeneric[keyof EntireInputGeneric], fullObject: EntireInputGeneric) => never extends PropertyValueType<OutputObjectGeneric> ? any : PropertyValueType<OutputObjectGeneric>) => OutputObjectGeneric; | ||
export declare function mapObjectValuesSync<EntireInputGeneric extends object>(inputObject: EntireInputGeneric): <OutputObjectGeneric extends object>(mapCallback: (inputKey: keyof EntireInputGeneric, keyValue: EntireInputGeneric[typeof inputKey], fullObject: EntireInputGeneric) => never extends PropertyValueType<OutputObjectGeneric> ? any : PropertyValueType<OutputObjectGeneric>) => OutputObjectGeneric; | ||
/** | ||
@@ -18,0 +18,0 @@ * Creates a new object with the same properties as the input object, but with values set to the |
@@ -6,3 +6,2 @@ import { OptionalKeysOf, RequiredKeysOf } from 'type-fest'; | ||
import { AnyObject } from './any-object'; | ||
import { NestedKeys } from './nested-keys'; | ||
export type InnerPickDeep<OriginalObject extends AnyObject, DeepKeys extends any[], Depth extends TsRecursionTracker> = DeepKeys extends [infer CurrentLevelPick, ...infer RemainingKeys] ? Extract<CurrentLevelPick, keyof OriginalObject> extends never ? OriginalObject : { | ||
@@ -14,9 +13,4 @@ [CurrentProp in Extract<CurrentLevelPick, RequiredKeysOf<OriginalObject>>]: InnerPickDeepValue<OriginalObject, CurrentProp, RemainingKeys, Depth>; | ||
type InnerPickDeepValue<OriginalObject, CurrentProp extends keyof OriginalObject, RemainingKeys extends any[], Depth extends TsRecursionTracker> = AnyFunction extends Extract<OriginalObject[CurrentProp], AnyFunction> ? OriginalObject[CurrentProp] | Exclude<OriginalObject[CurrentProp], AnyFunction> : Array<any> extends Extract<OriginalObject[CurrentProp], Array<any>> ? Array<InnerPickDeep<ArrayElement<Extract<OriginalObject[CurrentProp], Array<any>>>, RemainingKeys, TsRecurse<Depth>>> | Exclude<OriginalObject[CurrentProp], Array<any>> : ReadonlyArray<any> extends Extract<OriginalObject[CurrentProp], ReadonlyArray<any>> ? ReadonlyArray<InnerPickDeep<ArrayElement<Extract<OriginalObject[CurrentProp], ReadonlyArray<any>>>, RemainingKeys, TsRecurse<Depth>>> | Exclude<OriginalObject[CurrentProp], ReadonlyArray<any>> : Extract<OriginalObject[CurrentProp], Record<any, any>> extends never ? OriginalObject[CurrentProp] : InnerPickDeep<Extract<OriginalObject[CurrentProp], Record<any, any>>, RemainingKeys, TsRecurse<Depth>> | Exclude<OriginalObject[CurrentProp], Record<any, any>>; | ||
/** | ||
* Pick nested keys with more strict type parameter requirements. However, these stricter type | ||
* parameter requirements often lead to "excessively deep" TS compiler errors. | ||
*/ | ||
export type PickDeepStrict<OriginalObject extends object, DeepKeys extends NestedKeys<OriginalObject>> = InnerPickDeep<OriginalObject, DeepKeys, TsRecursionStart>; | ||
/** Pick nested keys. */ | ||
export type PickDeep<OriginalObject extends object, DeepKeys extends PropertyKey[]> = InnerPickDeep<OriginalObject, DeepKeys, TsRecursionStart>; | ||
export {}; |
@@ -21,10 +21,10 @@ export * from './augments/ansi'; | ||
export * from './augments/object/jsonify'; | ||
export * from './augments/object/key-count'; | ||
export * from './augments/object/map-object'; | ||
export * from './augments/object/merge-deep'; | ||
export * from './augments/object/merge-property-arrays'; | ||
export * from './augments/object/nested-keys'; | ||
export * from './augments/object/object'; | ||
export * from './augments/object/object-entries'; | ||
export * from './augments/object/old-union-to-intersection'; | ||
export * from './augments/object/pick-deep'; | ||
export * from './augments/object/selection-set'; | ||
export * from './augments/object/typed-has-property'; | ||
@@ -44,2 +44,3 @@ export * from './augments/promise/deferred-promise'; | ||
export * from './augments/type-recursion'; | ||
export * from './augments/union'; | ||
export * from './augments/wrap-in-try'; |
{ | ||
"name": "@augment-vir/common", | ||
"version": "28.2.4", | ||
"version": "29.0.0", | ||
"homepage": "https://github.com/electrovir/augment-vir/tree/main/packages/common", | ||
@@ -32,3 +32,3 @@ "bugs": { | ||
"devDependencies": { | ||
"typescript": "5.4.5" | ||
"typescript": "5.5.2" | ||
}, | ||
@@ -35,0 +35,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137
162638
4156