@goodbyenjn/utils 1.3.1 → 26.1.0

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.
package/dist/remeda.js CHANGED
@@ -1,3 +1,3 @@
1
- import { A, C as C$1, C$1 as C, D, T as T$2, T$1, T$2 as T, T$3, a as a$7, a$1 as a$10, a$10 as a$9, a$11 as a$5, a$12 as a$3, a$2 as a$4, a$3 as a$6, a$4 as a$8, a$5 as a$1, a$6 as a$12, a$7 as a$11, a$8 as a, a$9 as a$2, accumulateAsync, awaitAll, b as b$1, b$1 as b$2, b$2 as b, buffer, c, c$1 as c$2, c$2 as c$1, chunkAsync, compose, concatAsync, concurrency, d as d$1, d$1 as d, d$10 as d$7, d$11 as d$2, d$2 as d$4, d$3 as d$10, d$4 as d$6, d$5 as d$8, d$6 as d$9, d$7 as d$5, d$8 as d$3, d$9 as d$11, differenceAsync, differenceByAsync, differenceWithAsync, dropAsync, e as e$3, e$1 as e, e$2 as e$1, e$3 as e$2, everyAsync, executeAsync, f as f$1, f$1 as f$2, f$2 as f, filterAsync, findAsync, flatMapAsync, flattenAsync, forEachAsync, h, hasOwnProperty, i as i$11, i$1 as i$15, i$10 as i$13, i$11 as i$8, i$12 as i$7, i$13 as i$9, i$14 as i$17, i$15 as i$10, i$16 as i, i$17 as i$14, i$2 as i$16, i$3 as i$2, i$4 as i$6, i$5 as i$1, i$6 as i$12, i$7 as i$4, i$8 as i$5, i$9 as i$3, intersectionAsync, intersectionByAsync, intersectionWithAsync, isPromiseLike, j, k, l as l$1, l$1 as l$2, l$2 as l$3, l$3 as l$6, l$4 as l, l$5 as l$4, l$6 as l$7, l$7 as l$5, m as m$9, m$1 as m$10, m$10 as m$6, m$2 as m, m$3 as m$8, m$4, m$5, m$6 as m$3, m$7, m$8 as m$2, m$9 as m$1, mapAsync, n as n$1, n$1 as n$7, n$2 as n$4, n$3 as n$2, n$4 as n$5, n$5 as n$6, n$6 as n, n$7 as n$3, o as o$2, o$1 as o$4, o$2 as o, o$3, o$4 as o$7, o$5 as o$6, o$6 as o$5, o$7 as o$1, o$8, p as p$1, p$1 as p, peekAsync, r as r$3, r$1 as r, r$10 as r$7, r$2 as r$8, r$3 as r$5, r$4 as r$2, r$5 as r$10, r$6 as r$9, r$7 as r$1, r$8 as r$6, r$9 as r$4, reduceAsync, s as s$5, s$1 as s$4, s$2, s$3 as s, s$4 as s$6, s$5 as s$3, s$6 as s$1, s$7, serializeAsync, someAsync, t as t$3, t$1 as t$4, t$10 as t$12, t$11 as t$1, t$12 as t$2, t$2 as t$10, t$3 as t$5, t$4 as t$7, t$5 as t, t$6 as t$9, t$7 as t$8, t$8 as t$6, t$9 as t$11, takeAsync, throttle, toArrayAsync, toIteratorAsync, u as u$9, u$1 as u$8, u$10 as u$3, u$11, u$12 as u$7, u$2, u$3 as u$6, u$4 as u$12, u$5 as u$1, u$6 as u$5, u$7 as u$4, u$8 as u$10, u$9 as u, uniqueAsync, uniqueByAsync, uniqueWithAsync, x, y, y$1 as y$2, y$2 as y$4, y$3 as y$5, y$4 as y$3, y$5 as y$1 } from "./libs/remeda-16106be4.js";
1
+ import { $ as t$84, $n as n$4, $t as e$24, A as awaitAll, An as e$9, Ar as t$4, At as t$62, B as t$89, Bn as e$3, Bt as t$53, C as toIteratorAsync, Cn as e$16, Cr as e, Ct as t$68, D as concurrency, Dn as e$12, Dr as t$6, Dt as n$13, E as buffer, En as e$13, Er as t$7, Et as t$65, F as isFunction, Fn as e$4, Fr as t$59, Ft as t$58, G as e$33, Gn as n$7, Gt as t$50, H as n$25, Hn as t$32, Ht as t$51, I as hasOwnProperty, In as t$31, It as e$28, J as n$22, Jn as t$24, Jt as n$12, K as t$87, Kn as t$26, Kt as e$25, L as t$91, Ln as n$9, Lt as t$57, M as toArrayAsync, Mn as e$7, Mr as t$2, Mt as t$60, N as compose, Nn as e$6, Nr as t$1, Nt as e$30, O as throttle, On as e$11, Or as t$5, Ot as t$64, P as isPromiseLike, Pn as e$5, Pr as t, Pt as e$29, Q as t$85, Qn as n$5, Qt as n$11, R as t$90, Rn as r$4, Rt as t$56, S as serializeAsync, Sn as e$17, Sr as t$10, St as e$31, T as chunkAsync, Tn as e$14, Tr as t$8, Tt as t$66, U as n$24, Un as t$28, Ut as e$27, V as n$26, Vn as n$8, Vt as t$52, W as t$88, Wn as t$27, Wt as e$26, X as n$21, Xn as n$6, Xt as a, Y as t$86, Yn as t$23, Yt as t$48, Z as n$20, Zn as t$22, Zt as t$47, _ as uniqueWithAsync, _n as t$34, _r as n$1, _t as n$16, a as forEachAsync, an as t$43, ar as n$2, at as t$80, b as uniqueAsync, bn as e$19, br as t$11, bt as t$70, c as everyAsync, cn as t$40, cr as t$16, ct as t$76, d as intersectionWithAsync, dn as t$37, dr as t$13, dt as t$73, en as t$46, er as n$3, et as t$83, f as intersectionByAsync, fn as t$36, fr as r$2, ft as t$72, g as differenceAsync, gn as e$21, gr as t$12, gt as n$17, h as differenceByAsync, hn as e$22, hr as e$2, ht as n$18, i as peekAsync, in as t$77, ir as r$3, it as n$19, j as executeAsync, jn as e$8, jr as t$3, jt as t$61, k as accumulateAsync, kn as e$10, kr as n, kt as t$63, l as mapAsync, ln as t$39, lr as t$15, lt as t$75, m as differenceWithAsync, mn as e$23, mr as r$1, mt as t$71, n as dropAsync, nn as t$44, nr as t$20, nt as t$81, o as reduceAsync, on as t$42, or as t$18, ot as t$79, p as intersectionAsync, pn as t$35, pr as t$29, pt as e$32, q as n$23, qn as t$25, qt as t$49, r as concatAsync, rn as n$10, rr as t$19, rt as r$5, s as findAsync, sn as t$41, sr as t$17, st as t$78, t as takeAsync, tn as t$45, tr as t$21, tt as t$82, u as flatMapAsync, un as t$38, ur as t$14, ut as t$74, v as someAsync, vn as t$33, vr as r, vt as n$15, w as flattenAsync, wn as e$15, wr as t$9, wt as t$67, x as filterAsync, xn as e$18, xr as e$1, xt as t$69, y as uniqueByAsync, yn as e$20, yr as t$55, yt as n$14, z as e$34, zn as t$30, zt as t$54 } from "./chunks/chunk-267b337b.js";
2
2
 
3
- export { accumulateAsync as accumulateP, t$4 as add, d$1 as addProp, t$3 as allPass, y as anyPass, awaitAll, buffer, n$1 as capitalize, u$8 as ceil, o$2 as chunk, chunkAsync as chunkP, u$9 as clamp, d$4 as clone, compose, a$7 as concat, concatAsync as concatP, concurrency, b$1 as conditional, r$3 as constant, c as countBy, y$2 as debounce, d as difference, differenceByAsync as differenceByP, differenceAsync as differenceP, T$2 as differenceWith, differenceWithAsync as differenceWithP, o$4 as divide, t$10 as doNothing, s$5 as drop, c$2 as dropFirstBy, a$10 as dropLast, i$11 as dropLastWhile, dropAsync as dropP, m$9 as dropWhile, f$1 as endsWith, n$7 as entries, everyAsync as everyP, u$2 as evolve, executeAsync as executeP, m$10 as filter, filterAsync as filterP, f$2 as find, d$8 as findIndex, o as findLast, d$6 as findLastIndex, findAsync as findP, d$10 as first, l$1 as firstBy, y$4 as flat, u$12 as flatMap, flatMapAsync as flatMapP, flattenAsync as flattenP, i$16 as floor, u$6 as forEach, i$15 as forEachObj, forEachAsync as forEachP, n$4 as fromEntries, m as fromKeys, A as funnel, i$2 as groupBy, i as hasAtLeast, hasOwnProperty, j as hasSubObject, e$3 as identity, u$1 as indexBy, s$2 as intersection, intersectionByAsync as intersectionByP, intersectionAsync as intersectionP, s$4 as intersectionWith, intersectionWithAsync as intersectionWithP, p$1 as invert, o$3 as isArray, i$6 as isBigInt, e as isBoolean, t$5 as isDate, k as isDeepEqual, n$6 as isDefined, n$5 as isEmpty, t as isError, t$7 as isFunction, a$4 as isIncludedIn, n$2 as isNonNull, l$2 as isNonNullish, o$7 as isNot, n as isNullish, e$2 as isNumber, o$6 as isObjectType, r$2 as isPlainObject, e$1 as isPromise, isPromiseLike, c$1 as isShallowEqual, a$6 as isStrictEqual, t$9 as isString, r$8 as isSymbol, n$3 as isTruthy, r as join, t$8 as keys, a$8 as last, l$3 as length, m$8 as map, d$9 as mapKeys, mapAsync as mapP, l$6 as mapToObj, i$4 as mapValues, i$12 as mapWithFeedback, u$5 as mean, y$5 as meanBy, i$1 as median, t$6 as merge, r$5 as mergeAll, D as mergeDeep, m$4 as multiply, C$1 as nthBy, u$4 as objOf, y$3 as omit, i$5 as omitBy, l as once, t$11 as only, i$8 as partialBind, f as partialLastBind, d$3 as partition, r$10 as pathOr, i$13 as pick, d$5 as pickBy, C as pipe, i$3 as piped, a$11 as product, p as prop, b$2 as pullObject, u$7 as purry, l$4 as randomBigInt, o$5 as randomInteger, m$5 as randomString, a$12 as range, u$10 as rankBy, l$7 as reduce, reduceAsync as reduceP, t$12 as reverse, i$7 as round, m$3 as sample, serializeAsync as serializeP, s as set, h as setPath, d$11 as shuffle, t$2 as sliceString, someAsync as someP, m$1 as sort, a as sortBy, u$3 as sortedIndex, m$2 as sortedIndexBy, t$1 as sortedIndexWith, u as sortedLastIndex, m$7 as sortedLastIndexBy, y$1 as splice, i$10 as split, i$17 as splitAt, i$9 as splitWhen, s$3 as startsWith, s$6 as stringToPath, b as subtract, a$1 as sum, s$7 as sumBy, x as swapIndices, T$1 as swapProps, l$5 as take, s$1 as takeFirstBy, o$8 as takeLast, o$1 as takeLastWhile, takeAsync as takeP, u$11 as takeWhile, r$4 as tap, peekAsync as tapP, throttle, a$5 as times, toArrayAsync as toArrayP, r$6 as toCamelCase, toIteratorAsync as toIteratorP, a$9 as toKebabCase, r$1 as toLowerCase, a$2 as toSnakeCase, r$9 as toUpperCase, a$3 as uncapitalize, i$14 as unique, T$3 as uniqueBy, uniqueByAsync as uniqueByP, uniqueAsync as uniqueP, m$6 as uniqueWith, uniqueWithAsync as uniqueWithP, r$7 as values, d$2 as when, d$7 as zip, T as zipWith };
3
+ export { accumulateAsync as accumulateP, t as add, t$1 as addProp, t$2 as allPass, t$3 as anyPass, awaitAll, buffer, t$4 as capitalize, n as ceil, t$5 as chunk, chunkAsync as chunkP, t$6 as clamp, t$7 as clone, compose, t$8 as concat, concatAsync as concatP, concurrency, t$9 as conditional, e as constant, t$10 as countBy, e$1 as debounce, t$11 as defaultTo, r as difference, differenceByAsync as differenceByP, differenceAsync as differenceP, n$1 as differenceWith, differenceWithAsync as differenceWithP, t$12 as divide, e$2 as doNothing, r$1 as drop, r$2 as dropFirstBy, t$13 as dropLast, t$14 as dropLastWhile, dropAsync as dropP, t$15 as dropWhile, t$16 as endsWith, t$17 as entries, everyAsync as everyP, t$18 as evolve, executeAsync as executeP, n$2 as filter, filterAsync as filterP, r$3 as find, t$19 as findIndex, t$20 as findLast, t$21 as findLastIndex, findAsync as findP, n$3 as first, n$4 as firstBy, n$5 as flat, t$22 as flatMap, flatMapAsync as flatMapP, flattenAsync as flattenP, n$6 as floor, t$23 as forEach, t$24 as forEachObj, forEachAsync as forEachP, t$25 as fromEntries, t$26 as fromKeys, n$7 as funnel, t$27 as groupBy, t$28 as groupByProp, t$29 as hasAtLeast, hasOwnProperty, n$8 as hasSubObject, e$3 as identity, t$30 as indexBy, r$4 as intersection, intersectionByAsync as intersectionByP, intersectionAsync as intersectionP, n$9 as intersectionWith, intersectionWithAsync as intersectionWithP, t$31 as invert, e$4 as isArray, e$5 as isBigInt, e$6 as isBoolean, e$7 as isDate, t$32 as isDeepEqual, e$8 as isDefined, e$9 as isEmpty, e$10 as isEmptyish, e$11 as isError, isFunction, e$12 as isIncludedIn, e$13 as isNonNull, e$14 as isNonNullish, e$15 as isNot, e$16 as isNullish, e$17 as isNumber, e$18 as isObjectType, e$19 as isPlainObject, e$20 as isPromise, isPromiseLike, t$33 as isShallowEqual, t$34 as isStrictEqual, e$21 as isString, e$22 as isSymbol, e$23 as isTruthy, t$35 as join, t$36 as keys, t$37 as last, t$38 as length, t$39 as map, t$40 as mapKeys, mapAsync as mapP, t$41 as mapToObj, t$42 as mapValues, t$43 as mapWithFeedback, n$10 as mean, t$44 as meanBy, t$45 as median, t$46 as merge, e$24 as mergeAll, n$11 as mergeDeep, t$47 as multiply, a as nthBy, t$48 as objOf, n$12 as omit, t$49 as omitBy, e$25 as once, t$50 as only, e$26 as partialBind, e$27 as partialLastBind, t$51 as partition, t$52 as pathOr, t$53 as pick, t$54 as pickBy, t$55 as pipe, t$56 as piped, t$57 as product, e$28 as prop, t$58 as pullObject, t$59 as purry, e$29 as randomBigInt, e$30 as randomInteger, t$60 as randomString, t$61 as range, t$62 as rankBy, t$63 as reduce, reduceAsync as reduceP, t$64 as reverse, n$13 as round, t$65 as sample, serializeAsync as serializeP, t$66 as set, t$67 as setPath, t$68 as shuffle, e$31 as sliceString, someAsync as someP, t$69 as sort, t$70 as sortBy, n$14 as sortedIndex, n$15 as sortedIndexBy, n$16 as sortedIndexWith, n$17 as sortedLastIndex, n$18 as sortedLastIndexBy, t$71 as splice, e$32 as split, t$72 as splitAt, t$73 as splitWhen, t$74 as startsWith, t$75 as stringToPath, t$76 as subtract, t$77 as sum, t$78 as sumBy, t$79 as swapIndices, t$80 as swapProps, n$19 as take, r$5 as takeFirstBy, t$81 as takeLast, t$82 as takeLastWhile, takeAsync as takeP, t$83 as takeWhile, t$84 as tap, peekAsync as tapP, throttle, t$85 as times, toArrayAsync as toArrayP, n$20 as toCamelCase, toIteratorAsync as toIteratorP, n$21 as toKebabCase, t$86 as toLowerCase, n$22 as toSnakeCase, n$23 as toTitleCase, t$87 as toUpperCase, e$33 as truncate, t$88 as uncapitalize, n$24 as unique, n$25 as uniqueBy, uniqueByAsync as uniqueByP, uniqueAsync as uniqueP, n$26 as uniqueWith, uniqueWithAsync as uniqueWithP, t$89 as values, e$34 as when, t$90 as zip, t$91 as zipWith };
package/dist/result.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- import "./libs/types-92e74e19.js";
2
- import { Err, Ok, Result, err, ok, safeTry } from "./libs/result-c7c586dd.js";
3
- export { Err, Ok, Result, err, ok, safeTry };
1
+ import { a as err, c as ExtractOkTypes, d as ResultAll, f as ResultError, i as Result, l as InferErrType, n as Err, o as ok, r as Ok, s as ExtractErrTypes, t as safeTry, u as InferOkType } from "./chunks/chunk-4b76d1c4.js";
2
+ export { Err, ExtractErrTypes, ExtractOkTypes, InferErrType, InferOkType, Ok, Result, ResultAll, ResultError, err, ok, safeTry };
package/dist/result.js CHANGED
@@ -1,4 +1,3 @@
1
- import "./libs/remeda-16106be4.js";
2
- import { Err, Ok, Result, err, ok, safeTry } from "./libs/result-a10bbd74.js";
1
+ import { A as Result, M as ok, N as safeTry, P as ResultError, j as err } from "./chunks/chunk-72aa7743.js";
3
2
 
4
- export { Err, Ok, Result, err, ok, safeTry };
3
+ export { Result, ResultError, err, ok, safeTry };
package/dist/types.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { AbstractClass, AbstractConstructor, AllUnionFields, And, ArrayIndices, ArraySlice, ArraySplice, ArrayTail, ArrayValues, Arrayable, AsyncFn, AsyncFnWithThis, AsyncReturnType, Asyncify, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, Class, ConditionalExcept, ConditionalKeys, ConditionalPick, ConditionalPickDeep, ConditionalPickDeepOptions, Constructor, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, DistributedOmit, DistributedPick, EmptyObject, Entries, Entry, Exact, Except, FindGlobalInstanceType, FindGlobalType, Finite, FixedLengthArray, Float, Fn, FnWithThis, Get, GetTagMetadata, GlobalThis, GreaterThan, GreaterThanOrEqual, HasOptionalKeys, HasReadonlyKeys, HasRequiredKeys, HasWritableKeys, IfAny, IfEmptyObject, IfNever, IfNull, IfUnknown, Includes, IntClosedRange, IntRange, Integer, InvariantOf, IsAny, IsBooleanLiteral, IsEmptyObject, IsEqual, IsFloat, IsInteger, IsLiteral, IsNegative, IsNever, IsNull, IsNumericLiteral, IsStringLiteral, IsSymbolLiteral, IsTuple, IsUnknown, IterableElement, Join, JsonArray, JsonObject, JsonPrimitive, JsonValue, Jsonifiable, Jsonify, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, KeysOfUnion, LastArrayElement, LessThan, LessThanOrEqual, LiteralToPrimitive, LiteralToPrimitiveDeep, LiteralUnion, Merge, MergeDeep, MergeDeepOptions, MergeExclusive, MultidimensionalArray, MultidimensionalReadonlyArray, Negative, NegativeFloat, NegativeInfinity, NegativeInteger, NonEmptyObject, NonEmptyString, NonEmptyTuple, NonNegative, NonNegativeInteger, Nullable, OmitByKey, OmitDeep, OmitIndexSignature, Opaque, OptionalKeysOf, Or, OverrideProperties, PackageJson, PartialDeep, PartialDeepOptions, PartialOnUndefinedDeep, PartialOnUndefinedDeepOptions, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, Paths, PickDeep, PickIndexSignature, PositiveInfinity, Primitive, Promisable, ReadonlyDeep, ReadonlyKeysOf, ReadonlyTuple, Replace, RequireAllOrNone, RequireAtLeastOne, RequireExactlyOne, RequireOneOrNone, RequiredDeep, RequiredKeysOf, Schema, SchemaOptions, ScreamingSnakeCase, SetFieldType, SetNonNullable, SetOptional, SetParameterType, SetReadonly, SetRequired, SetRequiredDeep, SetReturnType, SharedUnionFields, SharedUnionFieldsDeep, Simplify, SimplifyDeep, SingleKeyObject, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, Split, Spread, StringKeyOf, StringRepeat, StringSlice, Stringified, StructuredCloneable, Subtract, Sum, SyncFn, SyncFnWithThis, Tagged, TaggedUnion, Trim, TsConfigJson, TupleToObject, TupleToUnion, TypedArray, UndefinedOnPartialDeep, UnionToIntersection, UnionToTuple, UnknownArray, UnknownMap, UnknownRecord, UnknownSet, UnwrapOpaque, UnwrapTagged, ValueOf, Words, Writable, WritableDeep, WritableKeysOf, YieldType } from "./libs/types-92e74e19.js";
2
- export { AbstractClass, AbstractConstructor, AllUnionFields, And, ArrayIndices, ArraySlice, ArraySplice, ArrayTail, ArrayValues, Arrayable, AsyncFn, AsyncFnWithThis, AsyncReturnType, Asyncify, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, Class, ConditionalExcept, ConditionalKeys, ConditionalPick, ConditionalPickDeep, ConditionalPickDeepOptions, Constructor, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, DistributedOmit, DistributedPick, EmptyObject, Entries, Entry, Exact, Except, FindGlobalInstanceType, FindGlobalType, Finite, FixedLengthArray, Float, Fn, FnWithThis, Get, GetTagMetadata, GlobalThis, GreaterThan, GreaterThanOrEqual, HasOptionalKeys, HasReadonlyKeys, HasRequiredKeys, HasWritableKeys, IfAny, IfEmptyObject, IfNever, IfNull, IfUnknown, Includes, IntClosedRange, IntRange, Integer, InvariantOf, IsAny, IsBooleanLiteral, IsEmptyObject, IsEqual, IsFloat, IsInteger, IsLiteral, IsNegative, IsNever, IsNull, IsNumericLiteral, IsStringLiteral, IsSymbolLiteral, IsTuple, IsUnknown, IterableElement, Join, JsonArray, JsonObject, JsonPrimitive, JsonValue, Jsonifiable, Jsonify, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, KeysOfUnion, LastArrayElement, LessThan, LessThanOrEqual, LiteralToPrimitive, LiteralToPrimitiveDeep, LiteralUnion, Merge, MergeDeep, MergeDeepOptions, MergeExclusive, MultidimensionalArray, MultidimensionalReadonlyArray, Negative, NegativeFloat, NegativeInfinity, NegativeInteger, NonEmptyObject, NonEmptyString, NonEmptyTuple, NonNegative, NonNegativeInteger, Nullable, OmitByKey, OmitDeep, OmitIndexSignature, Opaque, OptionalKeysOf, Or, OverrideProperties as Override, OverrideProperties, PackageJson, SetOptional as PartialByKey, PartialDeep, PartialDeepOptions, PartialOnUndefinedDeep, PartialOnUndefinedDeepOptions, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, Paths, PickDeep, PickIndexSignature, PositiveInfinity, Primitive, Promisable, ReadonlyDeep, ReadonlyKeysOf, ReadonlyTuple, Replace, RequireAllOrNone, RequireAtLeastOne, RequireExactlyOne, RequireOneOrNone, SetRequired as RequiredByKey, RequiredDeep, RequiredKeysOf, Schema, SchemaOptions, ScreamingSnakeCase, SetFieldType, SetNonNullable, SetOptional, SetParameterType, SetReadonly, SetRequired, SetRequiredDeep, SetReturnType, SharedUnionFields, SharedUnionFieldsDeep, Simplify, SimplifyDeep, SingleKeyObject, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, Split, Spread, StringKeyOf, StringRepeat, StringSlice, Stringified, StructuredCloneable, Subtract, Sum, SyncFn, SyncFnWithThis, Tagged, TaggedUnion, Trim, TsConfigJson, TupleToObject, TupleToUnion, TypedArray, UndefinedOnPartialDeep, UnionToIntersection, UnionToTuple, UnknownArray, UnknownMap, UnknownRecord, UnknownSet, UnwrapOpaque, UnwrapTagged, ValueOf, Words, Writable, WritableDeep, WritableKeysOf, YieldType };
1
+ import { $ as IntRange, $n as Simplify, $r as Constructor, $t as SetNonNullable, A as RemovePrefix, An as ArrayTail, Ar as HasRequiredKeys, At as Entries, B as Xor, Bn as NonEmptyObject, Br as KeysOfUnion, Bt as Join, C as PascalCase, Cn as RequireOneOrNone, Cr as NonNegativeInteger, Ct as FindGlobalInstanceType, D as DelimiterCasedProperties, Dn as MergeDeep, Dr as UnknownArray, Dt as Asyncify, E as KebabCasedProperties, En as MergeExclusive, Er as IsFloat, Et as Jsonify, F as ExclusifyUnion, Fn as TaggedUnion, Fr as IfEmptyObject, Ft as FixedLengthArray, G as SharedUnionFields, Gn as GreaterThan, Gr as UppercaseLetter, Gt as ConditionalExcept, H as IfNull, Hn as Except, Hr as Alphanumeric, Ht as ConditionalPickDeep, I as IsNullable, In as UnknownMap, Ir as EmptyObject, It as StringSlice, J as ArrayIndices, Jn as Or, Jr as JsonPrimitive, Jt as IsTuple, K as SetFieldType, Kn as And, Kr as JsonArray, Kt as ConditionalKeys, L as IsOptional, Ln as UnknownSet, Lr as IsEmptyObject, Lt as ArraySlice, M as CamelCasedProperties, Mn as ConditionalSimplifyDeep, Mr as OptionalKeysOf, Mt as IterableElement, N as CamelCase, Nn as WritableDeep, Nr as IsOptionalKeyOf, Nt as MultidimensionalReadonlyArray, O as KebabCase, On as MergeDeepOptions, Or as If, Ot as SetParameterType, P as Words, Pn as Writable, Pr as IsAny, Pt as MultidimensionalArray, Q as IntClosedRange, Qn as IsEqual, Qr as Class, Qt as SetNonNullableDeep, R as IsUppercase, Rn as UnknownRecord, Rr as DistributedPick, Rt as LessThanOrEqual, S as PascalCasedProperties, Sn as IsUnion, Sr as NonNegative, St as StructuredCloneable, T as DelimiterCasedPropertiesDeep, Tn as RequireExactlyOne, Tr as IsInteger, Tt as Jsonifiable, U as SharedUnionFieldsDeep, Un as LessThan, Ur as DigitCharacter, Ut as ConditionalPickDeepOptions, V as IsUndefined, Vn as RequireAtLeastOne, Vr as UnionToIntersection, Vt as Stringified, W as AllUnionFields, Wn as GreaterThanOrEqual, Wr as LowercaseLetter, Wt as ConditionalPick, X as IfNever, Xn as PickIndexSignature, Xr as AbstractClass, Xt as AsyncReturnType, Y as IfUnknown, Yn as Merge, Yr as JsonValue, Yt as ExtendsStrict, Z as IfAny, Zn as OmitIndexSignature, Zr as AbstractConstructor, Zt as ValueOf, _ as ScreamingSnakeCase, _n as Subtract, _r as IsNegative, _t as KeyAsString, a as ExcludeStrict, ai as Fn, an as Arrayable, ar as IsLiteral, at as HasWritableKeys, b as SnakeCase, bn as PartialDeepOptions, br as NegativeInfinity, bt as Schema, c as PackageJson, ci as SyncFnWithThis, cn as UndefinedOnPartialDeep, cr as IsSymbolLiteral, ct as HasReadonlyKeys, d as LastArrayElement, dn as OmitDeep, dr as Tagged, dt as IsRequiredKeyOf, ei as TypedArray, en as SetRequiredDeep, er as Trim, et as TupleToUnion, f as Get, fn as UnionToTuple, fr as UnwrapOpaque, ft as HasOptionalKeys, g as Split, gn as Paths, gr as Integer, gt as ArrayElement, h as Replace, hn as PickDeep, hr as Float, ht as Exact, i as OmitByKey, ii as AsyncFnWithThis, in as InvariantOf, ir as IsBooleanLiteral, it as Spread, j as CamelCasedPropertiesDeep, jn as NonEmptyTuple, jr as RequiredKeysOf, jt as Entry, k as DelimiterCase, kn as SimplifyDeep, kr as IsNever, kt as SetReturnType, l as GlobalThis, ln as PartialOnUndefinedDeep, lr as GetTagMetadata, lt as ReadonlyKeysOf, m as StringRepeat, mn as ArraySplice, mr as Finite, mt as ReadonlyTuple, n as SetNullable, ni as Nullable, nn as SetReadonly, nr as IsUnknown, nt as ExtractRestElement, o as ExtractStrict, oi as FnWithThis, on as Promisable, or as IsNumericLiteral, ot as IsWritableKeyOf, p as Includes, pn as LiteralUnion, pr as UnwrapTagged, pt as OverrideProperties, q as ArrayValues, qn as AllExtend, qr as JsonObject, qt as TupleToObject, r as Optional, ri as AsyncFn, rn as SetOptional, rr as IsNull, rt as SplitOnRestElement, s as TsConfigJson, si as SyncFn, sn as ReadonlyDeep, sr as IsStringLiteral, st as WritableKeysOf, t as YieldType, ti as Primitive, tn as SetRequired, tr as TupleOf, tt as ExcludeRestElement, u as ConditionalSimplify, un as PartialOnUndefinedDeepOptions, ur as Opaque, ut as IsReadonlyKeyOf, v as SnakeCasedPropertiesDeep, vn as RequiredDeep, vr as Negative, vt as LiteralToPrimitiveDeep, w as KebabCasedPropertiesDeep, wn as RequireAllOrNone, wr as PositiveInfinity, wt as FindGlobalType, x as PascalCasedPropertiesDeep, xn as SingleKeyObject, xr as NegativeInteger, xt as SchemaOptions, y as SnakeCasedProperties, yn as PartialDeep, yr as NegativeFloat, yt as LiteralToPrimitive, z as IsLowercase, zn as NonEmptyString, zr as DistributedOmit, zt as Sum } from "./chunks/chunk-a07ed28f.js";
2
+ export { AbstractClass, AbstractConstructor, AllExtend, AllUnionFields, Alphanumeric, And, ArrayElement, ArrayIndices, ArraySlice, ArraySplice, ArrayTail, ArrayValues, Arrayable, AsyncFn, AsyncFnWithThis, AsyncReturnType, Asyncify, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, Class, ConditionalExcept, ConditionalKeys, ConditionalPick, ConditionalPickDeep, ConditionalPickDeepOptions, ConditionalSimplify, ConditionalSimplifyDeep, Constructor, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, DigitCharacter, DistributedOmit, DistributedPick, EmptyObject, Entries, Entry, Exact, Except, ExcludeRestElement, ExcludeStrict, ExclusifyUnion, ExtendsStrict, ExtractRestElement, ExtractStrict, FindGlobalInstanceType, FindGlobalType, Finite, FixedLengthArray, Float, Fn, FnWithThis, Get, GetTagMetadata, GlobalThis, GreaterThan, GreaterThanOrEqual, HasOptionalKeys, HasReadonlyKeys, HasRequiredKeys, HasWritableKeys, If, IfAny, IfEmptyObject, IfNever, IfNull, IfUnknown, Includes, IntClosedRange, IntRange, Integer, InvariantOf, IsAny, IsBooleanLiteral, IsEmptyObject, IsEqual, IsFloat, IsInteger, IsLiteral, IsLowercase, IsNegative, IsNever, IsNull, IsNullable, IsNumericLiteral, IsOptional, IsOptionalKeyOf, IsReadonlyKeyOf, IsRequiredKeyOf, IsStringLiteral, IsSymbolLiteral, IsTuple, IsUndefined, IsUnion, IsUnknown, IsUppercase, IsWritableKeyOf, IterableElement, Join, JsonArray, JsonObject, JsonPrimitive, JsonValue, Jsonifiable, Jsonify, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, KeyAsString, KeysOfUnion, LastArrayElement, LessThan, LessThanOrEqual, LiteralToPrimitive, LiteralToPrimitiveDeep, LiteralUnion, LowercaseLetter, Merge, MergeDeep, MergeDeepOptions, MergeExclusive, MultidimensionalArray, MultidimensionalReadonlyArray, Negative, NegativeFloat, NegativeInfinity, NegativeInteger, NonEmptyObject, NonEmptyString, NonEmptyTuple, NonNegative, NonNegativeInteger, Nullable, OmitByKey, OmitDeep, OmitIndexSignature, Opaque, Optional, OptionalKeysOf, Or, OverrideProperties, PackageJson, PartialDeep, PartialDeepOptions, PartialOnUndefinedDeep, PartialOnUndefinedDeepOptions, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, Paths, PickDeep, PickIndexSignature, PositiveInfinity, Primitive, Promisable, ReadonlyDeep, ReadonlyKeysOf, ReadonlyTuple, RemovePrefix, Replace, RequireAllOrNone, RequireAtLeastOne, RequireExactlyOne, RequireOneOrNone, RequiredDeep, RequiredKeysOf, Schema, SchemaOptions, ScreamingSnakeCase, SetFieldType, SetNonNullable, SetNonNullableDeep, SetNullable, SetOptional, SetParameterType, SetReadonly, SetRequired, SetRequiredDeep, SetReturnType, SharedUnionFields, SharedUnionFieldsDeep, Simplify, SimplifyDeep, SingleKeyObject, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, Split, SplitOnRestElement, Spread, StringRepeat, StringSlice, Stringified, StructuredCloneable, Subtract, Sum, SyncFn, SyncFnWithThis, Tagged, TaggedUnion, Trim, TsConfigJson, TupleOf, TupleToObject, TupleToUnion, TypedArray, UndefinedOnPartialDeep, UnionToIntersection, UnionToTuple, UnknownArray, UnknownMap, UnknownRecord, UnknownSet, UnwrapOpaque, UnwrapTagged, UppercaseLetter, ValueOf, Words, Writable, WritableDeep, WritableKeysOf, Xor, YieldType };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export { };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodbyenjn/utils",
3
- "version": "1.3.1",
3
+ "version": "26.1.0",
4
4
  "description": "GoodbyeNJN's utils for typescript and javascript",
5
5
  "keywords": [
6
6
  "utils",
@@ -20,8 +20,8 @@
20
20
  "type": "module",
21
21
  "exports": {
22
22
  ".": {
23
- "types": "./dist/index.d.ts",
24
- "import": "./dist/index.js"
23
+ "types": "./dist/common.d.ts",
24
+ "import": "./dist/common.js"
25
25
  },
26
26
  "./fs": {
27
27
  "types": "./dist/fs.d.ts",
@@ -46,23 +46,31 @@
46
46
  "dist"
47
47
  ],
48
48
  "scripts": {
49
- "build": "pnpm run clean && pnpm run bundle",
50
- "bundle": "rolldown -c rolldown.config.ts",
51
- "clean": "rm -rf dist"
49
+ "dev": "rolldown -c rolldown.config.ts -w",
50
+ "build": "rolldown -c rolldown.config.ts",
51
+ "check": "tsc && eslint && prettier --check .",
52
+ "typecheck": "tsc",
53
+ "lint": "eslint",
54
+ "lint:fix": "eslint --fix",
55
+ "format": "prettier --write .",
56
+ "test": "vitest",
57
+ "release": "bumpp"
52
58
  },
53
59
  "devDependencies": {
54
- "@goodbyenjn/configs": "^6.0.0",
60
+ "@goodbyenjn/configs": "^6.1.4",
55
61
  "@goodbyenjn/utils": "file:",
56
- "@types/node": "^24.1.0",
57
- "eslint": "^9.32.0",
58
- "prettier": "^3.6.2",
59
- "remeda": "^2.26.1",
60
- "rolldown": "1.0.0-beta.29",
61
- "rolldown-plugin-dts": "^0.14.1",
62
+ "@types/node": "^25.0.3",
63
+ "eslint": "^9.39.2",
64
+ "prettier": "^3.7.4",
65
+ "remeda": "^2.33.1",
66
+ "rolldown": "1.0.0-beta.58",
67
+ "rolldown-plugin-dts": "^0.20.0",
62
68
  "rotery": "^0.7.0",
63
- "type-fest": "^4.41.0",
64
- "typescript": "^5.8.3",
65
- "vitest": "^3.2.4"
69
+ "safe-stable-stringify": "^2.5.0",
70
+ "tinyglobby": "^0.2.15",
71
+ "type-fest": "^5.3.1",
72
+ "typescript": "^5.9.3",
73
+ "vitest": "^4.0.16"
66
74
  },
67
75
  "publishConfig": {
68
76
  "registry": "https://registry.npmjs.org",
package/dist/index.js DELETED
@@ -1,5 +0,0 @@
1
- import { $, PromiseWithResolvers, addPrefix, addSuffix, createLock, createSingleton, debounce, errorToMessage, getErrorMessage, join, joinWithSlash, linear, normalizeError, parseKeyValuePairs, parseValueToBoolean, quoteShellArg, removePrefix, removeSuffix, scale, sleep, split, splitWithSlash, template, throttle, toForwardSlash, unindent } from "./libs/common-7c67f2df.js";
2
- import "./libs/remeda-16106be4.js";
3
- import "./libs/result-a10bbd74.js";
4
-
5
- export { $, PromiseWithResolvers, addPrefix, addSuffix, createLock, createSingleton, debounce, errorToMessage, getErrorMessage, join, joinWithSlash, linear, normalizeError, parseKeyValuePairs, parseValueToBoolean, quoteShellArg, removePrefix, removeSuffix, scale, sleep, split, splitWithSlash, template, throttle, toForwardSlash, unindent };
@@ -1,334 +0,0 @@
1
- import { l$1 as l, r$4 as r, t$4 as t, t$6 as t$1, u } from "./remeda-16106be4.js";
2
- import { Result } from "./result-a10bbd74.js";
3
-
4
- //#region src/common/error.ts
5
- const normalizeError = (error) => {
6
- if (error instanceof Error) return error;
7
- try {
8
- return new Error(JSON.stringify(error));
9
- } catch {
10
- return new Error(String(error));
11
- }
12
- };
13
- const getErrorMessage = (error, message = "Unknown error") => error instanceof Error ? error.message : message;
14
- const errorToMessage = (message = "Unknown error") => (error) => getErrorMessage(error, message);
15
-
16
- //#endregion
17
- //#region src/common/math.ts
18
- /**
19
- * @example
20
- * ```
21
- * const value = linear(0.5, [0, 2]) // value: 1
22
- * ```
23
- */
24
- const linear = (value, range) => {
25
- const [min, max] = range;
26
- const interpolation = u(value, {
27
- min: 0,
28
- max: 1
29
- });
30
- return min + (max - min) * interpolation;
31
- };
32
- /**
33
- * @example
34
- * ```
35
- * const value = scale(0.5, [0, 1], [200, 400]) // value: 300
36
- * ```
37
- */
38
- const scale = (value, inRange, outRange) => {
39
- const [inMin, inMax] = inRange;
40
- const [outMin, outMax] = outRange;
41
- const interpolation = (value - inMin) / (inMax - inMin);
42
- return linear(interpolation, [outMin, outMax]);
43
- };
44
-
45
- //#endregion
46
- //#region src/common/parse.ts
47
- const parseKeyValuePairs = (input) => {
48
- const parseKey = (input$1, raw = input$1) => {
49
- if (input$1.length === 0) return {
50
- value: "",
51
- end: 0
52
- };
53
- else if (/^\s/.test(input$1)) {
54
- const { value: value$1, end: end$1 } = parseKey(input$1.slice(1), raw);
55
- return {
56
- value: value$1,
57
- end: end$1 + 1
58
- };
59
- }
60
- let value = "";
61
- let end = 0;
62
- if (input$1[0] === "'" || input$1[0] === "\"") {
63
- const slice = input$1.slice(1);
64
- const index = slice.indexOf(input$1[0]);
65
- if (index === -1 || !slice.slice(index + 1).startsWith("=")) throw new Error(`Failed to parse key from input: ${raw}`);
66
- value = slice.slice(0, index);
67
- end = 1 + index + 2;
68
- } else {
69
- for (const char of input$1) {
70
- if (char === "=") break;
71
- end += 1;
72
- }
73
- value = input$1.slice(0, end);
74
- end += 1;
75
- }
76
- return {
77
- value,
78
- end
79
- };
80
- };
81
- const parseValue = (input$1, raw = input$1) => {
82
- if (input$1.length === 0) return {
83
- value: "",
84
- end: 0
85
- };
86
- let value = "";
87
- let end = 0;
88
- if (input$1[0] === "'" || input$1[0] === "\"") {
89
- const slice = input$1.slice(1);
90
- const index = slice.indexOf(input$1[0]);
91
- if (index === -1 || slice.slice(index + 1).length !== 0 && !/^\s/.test(slice.slice(index + 1))) throw new Error(`Failed to parse value from input: ${raw}`);
92
- value = slice.slice(0, index);
93
- end = 1 + index + 1;
94
- } else {
95
- for (const char of input$1) {
96
- if (/\s/.test(char)) break;
97
- end += 1;
98
- }
99
- value = input$1.slice(0, end);
100
- end += 1;
101
- }
102
- return {
103
- value,
104
- end
105
- };
106
- };
107
- const pairs = {};
108
- let offset = 0;
109
- while (offset < input.length) {
110
- const key = parseKey(input.slice(offset), input);
111
- offset += key.end;
112
- const value = parseValue(input.slice(offset), input);
113
- offset += value.end;
114
- pairs[key.value] = value.value;
115
- if (/^\s*$/.test(input.slice(offset))) break;
116
- }
117
- return pairs;
118
- };
119
- const parseValueToBoolean = (value, defaultValue) => {
120
- const str = String(value).trim().toLowerCase();
121
- if (/^(?:y|yes|true|1|on)$/.test(str)) return true;
122
- if (/^(?:n|no|false|0|off)$/.test(str)) return false;
123
- return defaultValue;
124
- };
125
-
126
- //#endregion
127
- //#region src/common/promise.ts
128
- const sleep = (ms, callback) => new Promise((resolve) => {
129
- setTimeout(async () => {
130
- await callback?.();
131
- resolve();
132
- }, ms);
133
- });
134
- const createSingleton = (fn) => {
135
- let p;
136
- const wrapper = () => {
137
- if (!p) p = fn();
138
- return p;
139
- };
140
- wrapper.reset = async () => {
141
- const prev = p;
142
- p = void 0;
143
- if (prev) await prev;
144
- };
145
- return wrapper;
146
- };
147
- /**
148
- * @example
149
- * ```
150
- * const lock = createLock()
151
- *
152
- * lock.run(async () => {
153
- * await doSomething()
154
- * })
155
- *
156
- * // in anther context:
157
- * await lock.wait() // it will wait all tasking finished
158
- * ```
159
- */
160
- const createLock = () => {
161
- const locks = [];
162
- return {
163
- async run(fn) {
164
- const p = fn();
165
- locks.push(p);
166
- try {
167
- return await p;
168
- } finally {
169
- const index = locks.indexOf(p);
170
- if (index >= 0) locks.splice(index, 1);
171
- }
172
- },
173
- async wait() {
174
- await Promise.allSettled(locks);
175
- },
176
- isWaiting() {
177
- return locks.length > 0;
178
- },
179
- clear() {
180
- locks.length = 0;
181
- }
182
- };
183
- };
184
- const PromiseWithResolvers = () => {
185
- if (t(Promise.withResolvers)) return Promise.withResolvers();
186
- let resolve;
187
- let reject;
188
- const promise = new Promise((_resolve, _reject) => {
189
- resolve = _resolve;
190
- reject = _reject;
191
- });
192
- return {
193
- promise,
194
- resolve,
195
- reject
196
- };
197
- };
198
-
199
- //#endregion
200
- //#region src/common/shell.ts
201
- const REGEXP_NULL_CHAR = /\x00+/g;
202
- const REGEXP_SAFE_CHARS = /^[A-Za-z0-9,:=_./-]+$/;
203
- const REGEXP_SINGLE_QUOTES = /'+/g;
204
- async function $(cmd, ...values) {
205
- const { exec } = await import("node:child_process");
206
- const command = t$1(cmd) ? cmd : cmd.reduce((acc, part, index) => acc + part + (values[index] ?? ""), "");
207
- const fn = async () => {
208
- const { promise, reject, resolve } = PromiseWithResolvers();
209
- exec(command, (error, stdout, stderr) => {
210
- if (error) reject(error);
211
- else resolve({
212
- stdout: stdout.trim(),
213
- stderr: stderr.trim()
214
- });
215
- });
216
- return await promise;
217
- };
218
- const onThrow = errorToMessage(`Failed to execute command: ${cmd}`);
219
- const result = Result.try(fn, onThrow);
220
- return result;
221
- }
222
- const quoteShellArg = (arg) => {
223
- if (!arg) return "''";
224
- const cleaned = String(arg).replace(REGEXP_NULL_CHAR, "");
225
- const matches = REGEXP_SAFE_CHARS.exec(cleaned);
226
- if (matches?.[0].length === cleaned.length) return cleaned;
227
- const quoted = cleaned.replace(REGEXP_SINGLE_QUOTES, (matched) => matched.length === 1 ? `'\\''` : `'"${matched}"'`);
228
- const trimmed = `'${quoted}'`.replace(/^''/, "").replace(/''$/, "");
229
- return trimmed;
230
- };
231
-
232
- //#endregion
233
- //#region src/common/string.ts
234
- const REGEXP_WHITESPACE = /^\s*$/;
235
- const addPrefix = (prefix, str) => {
236
- if (str.startsWith(prefix)) return str;
237
- return prefix + str;
238
- };
239
- const addSuffix = (suffix, str) => {
240
- if (str.endsWith(suffix)) return str;
241
- return str + suffix;
242
- };
243
- const removePrefix = (prefix, str) => {
244
- if (!str.startsWith(prefix)) return str;
245
- return str.slice(prefix.length);
246
- };
247
- const removeSuffix = (suffix, str) => {
248
- if (!str.endsWith(suffix)) return str;
249
- return str.slice(0, -suffix.length);
250
- };
251
- const join = (separator, ...paths) => {
252
- let pathname = "";
253
- for (const path of paths) {
254
- const part = removeSuffix(separator, removePrefix(separator, path));
255
- if (part) pathname += pathname ? separator + part : part;
256
- }
257
- return pathname;
258
- };
259
- const split = (separator, path) => {
260
- const paths = [];
261
- let part = "";
262
- for (const char of path) if (char === separator) {
263
- part && paths.push(part);
264
- part = "";
265
- } else part += char;
266
- part && paths.push(part);
267
- return paths;
268
- };
269
- const toForwardSlash = (str) => str.replace(/\\/g, "/");
270
- const joinWithSlash = (...paths) => join("/", ...paths);
271
- const splitWithSlash = (path) => split("/", path);
272
- function unindent(template$1, ...values) {
273
- const string = t$1(template$1) ? template$1 : template$1.reduce((acc, part, index) => acc + part + (values[index] ?? ""), "");
274
- const lines = string.split("\n");
275
- const whitespaceLines = lines.map((line) => REGEXP_WHITESPACE.test(line));
276
- const commonIndent = lines.reduce((min, line, idx) => {
277
- if (whitespaceLines[idx]) return min;
278
- const indent = line.match(/^\s*/)?.[0].length;
279
- return indent === void 0 ? min : Math.min(min, indent);
280
- }, Number.POSITIVE_INFINITY);
281
- let emptyLinesHead = 0;
282
- while (emptyLinesHead < lines.length && whitespaceLines[emptyLinesHead]) emptyLinesHead += 1;
283
- let emptyLinesTail = 0;
284
- while (emptyLinesTail < lines.length && whitespaceLines[lines.length - emptyLinesTail - 1]) emptyLinesTail += 1;
285
- return lines.slice(emptyLinesHead, lines.length - emptyLinesTail).map((line) => line.slice(commonIndent)).join("\n");
286
- }
287
- function template(str, ...args) {
288
- const [firstArg, fallback] = args;
289
- if (r(firstArg)) {
290
- const mapping = firstArg;
291
- return str.replace(/\{(\w+)\}/g, (_, key) => mapping[key] || ((t(fallback) ? fallback(key) : fallback) ?? key));
292
- } else return str.replace(/\{(\d+)\}/g, (_, key) => {
293
- const index = Number(key);
294
- if (Number.isNaN(index)) return key;
295
- return args[index];
296
- });
297
- }
298
-
299
- //#endregion
300
- //#region src/common/throttle.ts
301
- const wrap = (fn, wait, options) => {
302
- const { leading, trailing } = options;
303
- let timerId;
304
- const wrapped = (...args) => {
305
- if (l(timerId)) return;
306
- timerId = globalThis.setTimeout(() => {
307
- timerId = void 0;
308
- trailing && fn(...args);
309
- }, wait);
310
- leading && fn(...args);
311
- };
312
- wrapped.cancel = () => {
313
- if (l(timerId)) globalThis.clearTimeout(timerId);
314
- timerId = void 0;
315
- };
316
- return wrapped;
317
- };
318
- const debounce = (fn, wait = 0, options = {}) => {
319
- const { leading = false, trailing = true } = options;
320
- return wrap(fn, wait, {
321
- leading,
322
- trailing
323
- });
324
- };
325
- const throttle = (fn, wait = 0, options = {}) => {
326
- const { leading = true, trailing = true } = options;
327
- return wrap(fn, wait, {
328
- leading,
329
- trailing
330
- });
331
- };
332
-
333
- //#endregion
334
- export { $, PromiseWithResolvers, addPrefix, addSuffix, createLock, createSingleton, debounce, errorToMessage, getErrorMessage, join, joinWithSlash, linear, normalizeError, parseKeyValuePairs, parseValueToBoolean, quoteShellArg, removePrefix, removeSuffix, scale, sleep, split, splitWithSlash, template, throttle, toForwardSlash, unindent };