@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/README.md +625 -87
- package/dist/chunks/chunk-267b337b.js +2782 -0
- package/dist/{libs/result-c7c586dd.d.ts → chunks/chunk-4b76d1c4.d.ts} +69 -84
- package/dist/chunks/chunk-72aa7743.js +1082 -0
- package/dist/{libs/types-92e74e19.d.ts → chunks/chunk-a07ed28f.d.ts} +4113 -2427
- package/dist/{index.d.ts → common.d.ts} +50 -20
- package/dist/common.js +3 -0
- package/dist/fs.d.ts +187 -32
- package/dist/fs.js +2640 -174
- package/dist/global-types.d.ts +59 -84
- package/dist/remeda.d.ts +6305 -1228
- package/dist/remeda.js +2 -2
- package/dist/result.d.ts +2 -3
- package/dist/result.js +2 -3
- package/dist/types.d.ts +2 -2
- package/dist/types.js +1 -0
- package/package.json +24 -16
- package/dist/index.js +0 -5
- package/dist/libs/common-7c67f2df.js +0 -334
- package/dist/libs/remeda-16106be4.js +0 -2726
- package/dist/libs/result-a10bbd74.js +0 -243
package/dist/remeda.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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 "./
|
|
2
|
-
|
|
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 "./
|
|
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 {
|
|
3
|
+
export { Result, ResultError, err, ok, safeTry };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
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
|
|
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
|
+
"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/
|
|
24
|
-
"import": "./dist/
|
|
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
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
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.
|
|
60
|
+
"@goodbyenjn/configs": "^6.1.4",
|
|
55
61
|
"@goodbyenjn/utils": "file:",
|
|
56
|
-
"@types/node": "^
|
|
57
|
-
"eslint": "^9.
|
|
58
|
-
"prettier": "^3.
|
|
59
|
-
"remeda": "^2.
|
|
60
|
-
"rolldown": "1.0.0-beta.
|
|
61
|
-
"rolldown-plugin-dts": "^0.
|
|
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
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
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 };
|