@superutils/core 1.1.6 → 1.2.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/index.d.ts CHANGED
@@ -354,7 +354,7 @@ declare function curry<TData, TArgs extends unknown[], TArgsIsFinite extends boo
354
354
  * console.log({ value }) // undefined
355
355
  * ```
356
356
  */
357
- declare const fallbackIfFails: <T, TArgs extends unknown[] = unknown[]>(target: T | ((...args: TArgs) => T), args: TArgs | (() => TArgs), fallback: IfPromiseAddValue<T> | ((reason: unknown) => IfPromiseAddValue<T>)) => T;
357
+ declare const fallbackIfFails: <T, TArgs extends unknown[] = unknown[], TFB = T, TFBVal = TFB extends (...args: unknown[]) => infer V ? V : TFB, Result = (T extends Promise<unknown> ? true : never) extends never ? T | TFBVal : Promise<Awaited<T | TFBVal>>>(target: T | ((...args: TArgs) => T), args: TArgs | (() => TArgs), fallback: IfPromiseAddValue<TFB> | ((reason: unknown) => IfPromiseAddValue<TFB>)) => Result;
358
358
 
359
359
  /** Check if value is an array */
360
360
  declare const isArr: <Item = unknown>(x: unknown) => x is Item[];
@@ -1291,7 +1291,7 @@ declare const reverse: <K, V, T extends IterableList<K, V>>(data: T, reverse?: b
1291
1291
  */
1292
1292
  declare const search: {
1293
1293
  <K, V, MatchExact extends boolean = false, AsMap extends boolean = true, Result = AsMap extends true ? Map<K, V> : V[]>(data: IterableList<K, V>, options: SearchOptions<K, V, MatchExact, AsMap>): Result;
1294
- defaultOptions: Pick<Required<SearchOptions<unknown, unknown, false, true>>, "matchAll" | "limit" | "asMap" | "ignoreCase" | "ranked" | "transform">;
1294
+ defaults: Pick<Required<SearchOptions<unknown, unknown, false, true>>, "matchAll" | "limit" | "asMap" | "ignoreCase" | "ranked" | "transform">;
1295
1295
  };
1296
1296
  /**
1297
1297
  * Utility for use with {@link search} function
@@ -1422,7 +1422,7 @@ declare function sort<V>(set: Set<V>, comparator: ArrayComparator<V>, options?:
1422
1422
  /** Sort Array/Map/Set with `string | boolean | number` values */
1423
1423
  declare function sort<K, V extends string | boolean | number, T extends IterableList<K, V>>(data: T, options?: SortOptions): T;
1424
1424
  declare namespace sort {
1425
- var defaultOptions: {
1425
+ var defaults: {
1426
1426
  ignoreCase: true;
1427
1427
  newInstance: false;
1428
1428
  reverse: false;
package/dist/index.js CHANGED
@@ -252,13 +252,16 @@ var objClean = (obj, keys, ignoreIfNotExist = true) => {
252
252
  };
253
253
 
254
254
  // src/obj/objKeys.ts
255
- var objKeys = (obj, sorted = true, includeSymbols = true) => fallbackIfFails_default(
256
- () => [
257
- ...includeSymbols && Object.getOwnPropertySymbols(obj) || [],
258
- ...sorted ? Object.keys(obj).sort() : Object.keys(obj)
259
- ],
260
- [],
261
- []
255
+ var objKeys = (obj, sorted = true, includeSymbols = true) => (
256
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
257
+ fallbackIfFails_default(
258
+ () => [
259
+ ...includeSymbols && Object.getOwnPropertySymbols(obj) || [],
260
+ ...sorted ? Object.keys(obj).sort() : Object.keys(obj)
261
+ ],
262
+ [],
263
+ []
264
+ )
262
265
  );
263
266
  var objKeys_default = objKeys;
264
267
 
@@ -582,10 +585,10 @@ var search = (data, options) => {
582
585
  var _a;
583
586
  const ignore = !getSize_default(data) || isEmpty(options == null ? void 0 : options.query);
584
587
  const result = isMap(options == null ? void 0 : options.result) ? options.result : /* @__PURE__ */ new Map();
585
- const asMap = (_a = options == null ? void 0 : options.asMap) != null ? _a : search.defaultOptions.asMap;
588
+ const asMap = (_a = options == null ? void 0 : options.asMap) != null ? _a : search.defaults.asMap;
586
589
  if (ignore) return asMap ? result : getValues_default(result);
587
590
  options = objCopy(
588
- search.defaultOptions,
591
+ search.defaults,
589
592
  options,
590
593
  [],
591
594
  "empty"
@@ -653,7 +656,7 @@ var search = (data, options) => {
653
656
  }
654
657
  return asMap ? result : getValues_default(result);
655
658
  };
656
- search.defaultOptions = {
659
+ search.defaults = {
657
660
  asMap: true,
658
661
  ignoreCase: true,
659
662
  limit: Infinity,
@@ -767,7 +770,7 @@ function sort(data, keyOrFn, options) {
767
770
  const dataType = isArr(data) ? 1 : isMap(data) ? 2 : isSet(data) ? 3 : 0;
768
771
  if (!dataType) return data;
769
772
  const { ignoreCase, newInstance, reverse: reverse2, undefinedFirst } = {
770
- ...sort.defaultOptions,
773
+ ...sort.defaults,
771
774
  ...isObj(options) ? options : isObj(keyOrFn) ? keyOrFn : {}
772
775
  };
773
776
  if (dataType === 1 && isFn(keyOrFn)) {
@@ -811,7 +814,7 @@ function sort(data, keyOrFn, options) {
811
814
  dataType === 2 ? data.set(...entry) : data.add(entry);
812
815
  return data;
813
816
  }
814
- sort.defaultOptions = {
817
+ sort.defaults = {
815
818
  ignoreCase: true,
816
819
  newInstance: false,
817
820
  reverse: false,
@@ -891,7 +894,7 @@ var getUrlParamRegex = (name, url, asArray = []) => {
891
894
  if (isUrl(url)) url = url.toString();
892
895
  const params = {};
893
896
  const regex = /[?&]+([^=&]+)=([^&]*)/gi;
894
- url.replace(regex, (_, name2, value) => {
897
+ url == null ? void 0 : url.replace(regex, (_, name2, value) => {
895
898
  value = decodeURIComponent(value);
896
899
  if (asArray.includes(name2) || params[name2] !== void 0) {
897
900
  params[name2] = isArr(params[name2]) ? params[name2] : [params[name2]];
package/package.json CHANGED
@@ -42,5 +42,5 @@
42
42
  "sideEffects": false,
43
43
  "type": "module",
44
44
  "types": "dist/index.d.ts",
45
- "version": "1.1.6"
45
+ "version": "1.2.0"
46
46
  }