@leather.io/utils 0.43.0 → 0.44.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @leather.io/utils@0.43.0 build /home/runner/work/mono/mono/packages/utils
2
+ > @leather.io/utils@0.44.1 build /home/runner/work/mono/mono/packages/utils
3
3
  > tsup
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -8,9 +8,9 @@
8
8
  CLI Using tsup config: /home/runner/work/mono/mono/packages/utils/tsup.config.ts
9
9
  CLI Target: es2022
10
10
  ESM Build start
11
- ESM dist/index.js 71.76 KB
12
- ESM dist/index.js.map 135.06 KB
13
- ESM ⚡️ Build success in 33ms
11
+ ESM dist/index.js 72.48 KB
12
+ ESM dist/index.js.map 137.40 KB
13
+ ESM ⚡️ Build success in 32ms
14
14
  DTS Build start
15
- DTS ⚡️ Build success in 1800ms
16
- DTS dist/index.d.ts 13.38 KB
15
+ DTS ⚡️ Build success in 1847ms
16
+ DTS dist/index.d.ts 14.39 KB
package/CHANGELOG.md CHANGED
@@ -332,6 +332,20 @@
332
332
  * @leather.io/constants bumped to 0.25.1
333
333
  * @leather.io/models bumped to 0.39.1
334
334
 
335
+ ### Dependencies
336
+
337
+ * The following workspace dependencies were updated
338
+ * dependencies
339
+ * @leather.io/constants bumped to 0.25.3
340
+ * @leather.io/models bumped to 0.41.0
341
+
342
+ ## [0.44.0](https://github.com/leather-io/mono/compare/@leather.io/utils-v0.43.0...@leather.io/utils-v0.44.0) (2025-08-27)
343
+
344
+
345
+ ### Features
346
+
347
+ * flatten object util ([cdebfec](https://github.com/leather-io/mono/commit/cdebfec46d68cb1ac9d12b844b9b4c7e976237d4))
348
+
335
349
  ## [0.43.0](https://github.com/leather-io/mono/compare/@leather.io/utils-v0.42.4...@leather.io/utils-v0.43.0) (2025-08-26)
336
350
 
337
351
 
package/dist/index.d.ts CHANGED
@@ -170,6 +170,37 @@ declare function createCurrencyFormatter({ locale, onError }: CreateCurrencyForm
170
170
  formatPercentage: (amount: number, decimals?: number) => string;
171
171
  };
172
172
 
173
+ type ObjectValue = string | number | boolean | null | NestedObject | ObjectValue[];
174
+ interface NestedObject {
175
+ [key: string]: ObjectValue;
176
+ }
177
+ interface FlattenedObject {
178
+ [key: string]: string | number | boolean | null;
179
+ }
180
+ /**
181
+ * Flattens a nested object or array into a flat object with dot-notation key paths.
182
+ *
183
+ * @param input - The object or array to flatten
184
+ * @param prefix - Internal parameter for recursion, represents the current key path
185
+ * @returns A flat object where keys represent the path to the original nested value
186
+ *
187
+ * @example
188
+ * ```typescript
189
+ * // Object example
190
+ * flattenObject({ layer1: { layer2: 'value' } })
191
+ * // Returns: { 'layer1.layer2': 'value' }
192
+ *
193
+ * // Array example
194
+ * flattenObject([{ key: 'value' }])
195
+ * // Returns: { '[0].key': 'value' }
196
+ *
197
+ * // Mixed example
198
+ * flattenObject({ users: [{ name: 'John', age: 30 }] })
199
+ * // Returns: { 'users[0].name': 'John', 'users[0].age': 30 }
200
+ * ```
201
+ */
202
+ declare function flattenObject(input: ObjectValue, prefix?: string): FlattenedObject;
203
+
173
204
  interface SpamFilterArgs {
174
205
  input: string;
175
206
  whitelist: string[];
@@ -249,4 +280,4 @@ declare function match<Variant extends string | number>(): <T>(variant: Variant,
249
280
  declare function removeTrailingNullCharacters(s: string): string;
250
281
  declare function isNumberOrNumberList(value: unknown): value is number | number[];
251
282
 
252
- export { type CreateInscriptionData, type FormatAmountOptions, aggregateBaseCryptoAssetBalances, aggregateBtcBalances, aggregateStxBalances, assertExistence, assertIsTruthy, assertUnreachable, baseCurrencyAmountInQuote, baseCurrencyAmountInQuoteWithFallback, btcToSat, calculateMeanAverage, capitalize, convertAmountToBaseUnit, convertAmountToFractionalUnit, convertToMoneyTypeWithDefaultOfZero, countDecimals, createAccountAddresses, createBaseCryptoAssetBalance, createBtcBalance, createCounter, createCurrencyFormatter, createInscriptionAsset, createMoney, createMoneyFromDecimal, createNullArrayOfLength, createNumArrayOfRange, createStxBalance, dateToUnixTimestamp, daysInMs, daysInSec, defaultWalletKeyId, delay, ensureArray, extractPhraseFromString, fibonacciGenerator, fiveMinInMs, getAssetDisplayName, getAssetId, getTicker, hasBitcoinAddress, hasStacksAddress, hexToNumber, hoursInMs, hoursInSec, increaseValueByOneMicroStx, initBigNumber, invertExchangeRate, isBigInt, isBoolean, isDefined, isEmpty, isEmptyArray, isEmptyString, isError, isEven, isFiatCurrencyCode, isFulfilled, isFunction, isHexString, isMoney, isMoneyGreaterThanZero, isNumber, isNumberOrNumberList, isObject, isRejected, isString, isTypedArray, isUndefined, isValidPrecision, makeNumberRange, makeStacksTxExplorerLink, mapObject, match, matchesAssetId, maxMoney, microStxToStx, migratePositiveAssetBalancesToTop, minMoney, minutesInMs, minutesInSec, moneyToBaseUnit, noop, oneDayInMs, oneMinInMs, oneWeekInMs, propIfDefined, pxStringToNumber, quoteCurrencyAmountToBase, rebaseMarketData, removeTrailingNullCharacters, reverseBytes, safelyFormatHexTxid, sanitizeContent, satToBtc, scaleValue, secondsInMs, sortAssetsByName, spamFilter, stxToMicroStx, subtractMoney, sumMoney, sumNumbers, toHexString, truncateMiddle, undefinedIfLengthZero, uniqueArray, unitToFractionalUnit, weeksInMs, weeksInSec, whenInscriptionMimeType, whenNetwork };
283
+ export { type CreateInscriptionData, type FormatAmountOptions, aggregateBaseCryptoAssetBalances, aggregateBtcBalances, aggregateStxBalances, assertExistence, assertIsTruthy, assertUnreachable, baseCurrencyAmountInQuote, baseCurrencyAmountInQuoteWithFallback, btcToSat, calculateMeanAverage, capitalize, convertAmountToBaseUnit, convertAmountToFractionalUnit, convertToMoneyTypeWithDefaultOfZero, countDecimals, createAccountAddresses, createBaseCryptoAssetBalance, createBtcBalance, createCounter, createCurrencyFormatter, createInscriptionAsset, createMoney, createMoneyFromDecimal, createNullArrayOfLength, createNumArrayOfRange, createStxBalance, dateToUnixTimestamp, daysInMs, daysInSec, defaultWalletKeyId, delay, ensureArray, extractPhraseFromString, fibonacciGenerator, fiveMinInMs, flattenObject, getAssetDisplayName, getAssetId, getTicker, hasBitcoinAddress, hasStacksAddress, hexToNumber, hoursInMs, hoursInSec, increaseValueByOneMicroStx, initBigNumber, invertExchangeRate, isBigInt, isBoolean, isDefined, isEmpty, isEmptyArray, isEmptyString, isError, isEven, isFiatCurrencyCode, isFulfilled, isFunction, isHexString, isMoney, isMoneyGreaterThanZero, isNumber, isNumberOrNumberList, isObject, isRejected, isString, isTypedArray, isUndefined, isValidPrecision, makeNumberRange, makeStacksTxExplorerLink, mapObject, match, matchesAssetId, maxMoney, microStxToStx, migratePositiveAssetBalancesToTop, minMoney, minutesInMs, minutesInSec, moneyToBaseUnit, noop, oneDayInMs, oneMinInMs, oneWeekInMs, propIfDefined, pxStringToNumber, quoteCurrencyAmountToBase, rebaseMarketData, removeTrailingNullCharacters, reverseBytes, safelyFormatHexTxid, sanitizeContent, satToBtc, scaleValue, secondsInMs, sortAssetsByName, spamFilter, stxToMicroStx, subtractMoney, sumMoney, sumNumbers, toHexString, truncateMiddle, undefinedIfLengthZero, uniqueArray, unitToFractionalUnit, weeksInMs, weeksInSec, whenInscriptionMimeType, whenNetwork };
package/dist/index.js CHANGED
@@ -1942,6 +1942,29 @@ function deriveFractionOptions(amount, decimals, compact, presetNumberFormatOpti
1942
1942
  };
1943
1943
  }
1944
1944
 
1945
+ // src/flatten-object.ts
1946
+ function flattenObject(input, prefix = "") {
1947
+ const result = {};
1948
+ if (input === null || typeof input !== "object") {
1949
+ if (prefix === "") return { value: input };
1950
+ return { [prefix]: input };
1951
+ }
1952
+ if (Array.isArray(input)) {
1953
+ input.forEach((item, index) => {
1954
+ const key = prefix === "" ? `[${index}]` : `${prefix}[${index}]`;
1955
+ const flattened = flattenObject(item, key);
1956
+ Object.assign(result, flattened);
1957
+ });
1958
+ } else {
1959
+ Object.entries(input).forEach(([key, value]) => {
1960
+ const newKey = prefix === "" ? key : `${prefix}.${key}`;
1961
+ const flattened = flattenObject(value, newKey);
1962
+ Object.assign(result, flattened);
1963
+ });
1964
+ }
1965
+ return result;
1966
+ }
1967
+
1945
1968
  // src/spam-filter/tlds-list.ts
1946
1969
  var tlds = [
1947
1970
  "AAA",
@@ -3651,6 +3674,7 @@ export {
3651
3674
  extractPhraseFromString,
3652
3675
  fibonacciGenerator,
3653
3676
  fiveMinInMs,
3677
+ flattenObject,
3654
3678
  getAssetDisplayName,
3655
3679
  getAssetId,
3656
3680
  getTicker,