@vinicunca/perkakas 0.0.5 → 0.0.9

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.cts CHANGED
@@ -302,7 +302,6 @@ declare namespace difference {
302
302
  declare function dropLast<T>(array: ReadonlyArray<T>, n: number): Array<T>;
303
303
  /**
304
304
  * Removes last `n` elements from the `array`.
305
- * @param array the target array
306
305
  * @param n the number of elements to skip
307
306
  * @signature
308
307
  * P.dropLast(n)(array)
@@ -328,7 +327,6 @@ declare function dropLast<T>(n: number): (array: ReadonlyArray<T>) => Array<T>;
328
327
  declare function drop<T>(array: ReadonlyArray<T>, n: number): Array<T>;
329
328
  /**
330
329
  * Removes first `n` elements from the `array`.
331
- * @param array the target array
332
330
  * @param n the number of elements to skip
333
331
  * @signature
334
332
  * P.drop(n)(array)
@@ -405,10 +403,9 @@ declare namespace filter {
405
403
  * @pipeable
406
404
  * @category Array
407
405
  */
408
- declare function findIndex<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): number;
406
+ declare function findIndex<T>(items: ReadonlyArray<T>, fn: Pred<T, boolean>): number;
409
407
  /**
410
408
  * Returns the index of the first element in the array where predicate is true, and -1 otherwise.
411
- * @param items the array
412
409
  * @param fn the predicate
413
410
  * @signature
414
411
  * P.findIndex(fn)(items)
@@ -427,7 +424,7 @@ declare function findIndex<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): nu
427
424
  * @pipeable
428
425
  * @category Array
429
426
  */
430
- declare function findIndex<T>(fn: Pred<T, boolean>): (array: ReadonlyArray<T>) => number;
427
+ declare function findIndex<T>(fn: Pred<T, boolean>): (items: ReadonlyArray<T>) => number;
431
428
  declare namespace findIndex {
432
429
  function indexed<T>(array: ReadonlyArray<T>, fn: PredIndexed<T, boolean>): number;
433
430
  function indexed<T>(fn: PredIndexed<T, boolean>): (array: ReadonlyArray<T>) => number;
@@ -475,7 +472,6 @@ declare namespace findIndex {
475
472
  declare function findLastIndex<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): number;
476
473
  /**
477
474
  * Returns the index of the last element in the array where predicate is true, and -1 otherwise.
478
- * @param array the array
479
475
  * @param fn the predicate
480
476
  * @signature
481
477
  * P.findLastIndex(fn)(items)
@@ -559,7 +555,7 @@ declare namespace findLast {
559
555
  * @pipeable
560
556
  * @category Array
561
557
  */
562
- declare function find<T>(array: ReadonlyArray<T>, fn: Pred<T, boolean>): T | undefined;
558
+ declare function find<T>(items: ReadonlyArray<T>, fn: Pred<T, boolean>): T | undefined;
563
559
  /**
564
560
  * Returns the value of the first element in the array where predicate is true, and undefined otherwise.
565
561
  * @param fn the predicate
@@ -619,7 +615,7 @@ type FirstOut<T extends IterableContainer> = T extends [] ? undefined : T extend
619
615
  * x => x + 1
620
616
  * ); // => 5
621
617
  *
622
- * @category array
618
+ * @category Array
623
619
  * @pipeable
624
620
  */
625
621
  declare function first<T extends IterableContainer>(array: Readonly<T>): FirstOut<T>;
@@ -700,7 +696,6 @@ declare namespace flatMapToObj {
700
696
  declare function flatMap<T, K>(array: ReadonlyArray<T>, fn: (input: T) => K | Array<K>): Array<K>;
701
697
  /**
702
698
  * Map each element of an array using a defined callback function and flatten the mapped result.
703
- * @param array The array to map.
704
699
  * @param fn The function mapper.
705
700
  * @signature
706
701
  * P.flatMap(fn)(array)
@@ -753,7 +748,6 @@ type Flatten<T> = T extends ReadonlyArray<infer K> ? K : T;
753
748
  /**
754
749
  * Flattens `array` a single level deep.
755
750
  * Note: In `pipe`, use `flatten()` form instead of `flatten`. Otherwise, the inferred type is lost.
756
-
757
751
  * @param items the target array
758
752
  * @signature P.flatten(array)
759
753
  * @example
@@ -875,7 +869,6 @@ declare namespace groupBy {
875
869
  declare function indexBy<T>(array: ReadonlyArray<T>, fn: (item: T) => any): Record<string, T>;
876
870
  /**
877
871
  * Converts a list of objects into an object indexing the objects by the given key.
878
- * @param array the array
879
872
  * @param fn the indexing function
880
873
  * @signature
881
874
  * P.indexBy(fn)(array)
@@ -906,10 +899,9 @@ declare namespace indexBy {
906
899
  * @category Array
907
900
  * @pipeable
908
901
  */
909
- declare function intersection<T>(source: ReadonlyArray<T>, other: ReadonlyArray<T>): Array<T>;
902
+ declare function intersection<T>(array: ReadonlyArray<T>, other: ReadonlyArray<T>): Array<T>;
910
903
  /**
911
904
  * Returns a list of elements that exist in both array.
912
- * @param array the source array
913
905
  * @param other the second array
914
906
  * @signature
915
907
  * P.intersection(other)(array)
@@ -1007,7 +999,6 @@ declare function join<T extends ReadonlyArray<Joinable> | [], Glue extends strin
1007
999
  * When called on a tuple and with stricter item types (union of literal values,
1008
1000
  * the result is strictly typed to the tuples shape and it's item types).
1009
1001
  *
1010
- * @param data The array to join
1011
1002
  * @param glue The string to put in between every two elements
1012
1003
  * @signature
1013
1004
  * P.join(glue)(data)
@@ -1370,7 +1361,7 @@ declare function range(end: number): (start: number) => Array<number>;
1370
1361
 
1371
1362
  /**
1372
1363
  * Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
1373
- * @param array the array to reduce
1364
+ * @param items the array to reduce
1374
1365
  * @param fn the callback function
1375
1366
  * @param initialValue the initial value to use as an accumulator value in the callback function
1376
1367
  * @signature
@@ -1421,7 +1412,6 @@ declare namespace reduce {
1421
1412
  declare function reject<T>(items: ReadonlyArray<T>, fn: Pred<T, boolean>): Array<T>;
1422
1413
  /**
1423
1414
  * Reject the elements of an array that meet the condition specified in a callback function.
1424
- * @param items The array to reject.
1425
1415
  * @param fn the callback function.
1426
1416
  * @signature
1427
1417
  * P.reject(array, fn)
@@ -1459,7 +1449,6 @@ type IsNoTuple<T> = T extends readonly [unknown, ...Array<unknown>] ? never : T;
1459
1449
  declare function reverse<T extends ReadonlyArray<unknown>>(array: T): Reverse<T>;
1460
1450
  /**
1461
1451
  * Reverses array.
1462
- * @param array the array
1463
1452
  * @signature
1464
1453
  * P.reverse()(array);
1465
1454
  * @example
@@ -1486,7 +1475,7 @@ type SampledLiteral<T extends IterableContainer, N extends number, Iteration ext
1486
1475
  * If you need to get a shuffled response you can pipe the shuffle function
1487
1476
  * after this one.
1488
1477
  *
1489
- * @param array the array
1478
+ * @param data the array
1490
1479
  * @param sampleSize the number of elements to take
1491
1480
  * @signature
1492
1481
  * P.sample(array, sampleSize)
@@ -1509,7 +1498,6 @@ declare function sample<T extends IterableContainer, N extends number = number>(
1509
1498
  * If you need to get a shuffled response you can pipe the shuffle function
1510
1499
  * after this one.
1511
1500
  *
1512
- * @param array the array
1513
1501
  * @param sampleSize the number of elements to take
1514
1502
  * @signature
1515
1503
  * P.sample(sampleSize)(array)
@@ -1622,8 +1610,7 @@ type SortedBy<T extends IterableContainer> = {
1622
1610
  * If the input array is more complex (non-empty array, tuple, etc...) use the
1623
1611
  * strict mode to maintain it's shape.
1624
1612
  *
1625
- * @param sortRule main sort rule
1626
- * @param additionalSortRules subsequent sort rules (these are only relevant when two items are equal based on the previous sort rule)
1613
+ * @param sortRules main sort rule
1627
1614
  * @signature
1628
1615
  * P.sortBy(sortRule, ...additionalSortRules)(array)
1629
1616
  * P.sortBy.strict(sortRule, ...additionalSortRules)(array)
@@ -1651,8 +1638,7 @@ declare function sortBy<T>(...sortRules: Readonly<NonEmptyArray<SortRule<T>>>):
1651
1638
  * strict mode to maintain it's shape.
1652
1639
  *
1653
1640
  * @param array the array to sort
1654
- * @param sortRule main sort rule
1655
- * @param additionalSortRules subsequent sort rules (these are only relevant when two items are equal based on the previous sort rule)
1641
+ * @param sortRules main sort rule
1656
1642
  * @signature
1657
1643
  * P.sortBy(array, sortRule, ...additionalSortRules)
1658
1644
  * P.sortBy.strict(array, sortRule, ...additionalSortRules)
@@ -1708,7 +1694,6 @@ declare namespace sortBy {
1708
1694
  declare function splitAt<T>(array: ReadonlyArray<T>, index: number): [Array<T>, Array<T>];
1709
1695
  /**
1710
1696
  * Splits a given array at a given index.
1711
- * @param array the array to split
1712
1697
  * @param index the index to split at
1713
1698
  * @signature
1714
1699
  * P.splitAt(index)(array)
@@ -2134,7 +2119,7 @@ declare function once<T>(fn: () => T): () => T;
2134
2119
  /**
2135
2120
  * Perform left-to-right function composition.
2136
2121
  * @param value The initial value.
2137
- * @param operations the list of operations to apply.
2122
+ * @param arguments the list of operations to apply.
2138
2123
  * @signature P.pipe(data, op1, op2, op3)
2139
2124
  * @example
2140
2125
  * P.pipe(
@@ -2195,6 +2180,18 @@ declare function pipe<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(value: A,
2195
2180
  */
2196
2181
  declare function purry(fn: any, args: IArguments | ReadonlyArray<any>, lazy?: any): any;
2197
2182
 
2183
+ /**
2184
+ * Delay execution for a given number of milliseconds.
2185
+ *
2186
+ * @param timeout the number of milliseconds to wait
2187
+ * @signature
2188
+ * P.sleep(timeout)
2189
+ * @example
2190
+ * P.sleep(1000) // => Promise<void>
2191
+ * @category Function
2192
+ */
2193
+ declare function sleep(timeout: number): Promise<void>;
2194
+
2198
2195
  type DefinitelyArray<T> = Extract<T, Array<any> | ReadonlyArray<any>> extends never ? ReadonlyArray<unknown> : Extract<T, Array<any> | ReadonlyArray<any>>;
2199
2196
  /**
2200
2197
  * A function that checks if the passed parameter is an Array and narrows its type accordingly
@@ -2427,22 +2424,12 @@ declare function isString<T>(data: T | string): data is DefinitelyString<T>;
2427
2424
  */
2428
2425
  declare function isTruthy<T>(data: T): data is Exclude<T, null | undefined | false | '' | 0>;
2429
2426
 
2430
- declare function convertToUnit(str: string | number | null | undefined, unit?: string): string | undefined;
2431
- /**
2432
- * Increase string a value with unit
2433
- *
2434
- */
2435
- declare function increaseWithUnit({ target, delta }: {
2436
- target: string | number;
2437
- delta: number;
2438
- }): string | number;
2439
- declare function humanReadableFileSize(bytes: number, base?: 1000 | 1024): string;
2440
- declare function sleep(timeout: number): Promise<void>;
2441
-
2442
2427
  /**
2443
2428
  * Clamp the given value within the inclusive min and max bounds.
2444
2429
  * @param value the number
2445
2430
  * @param limits the bounds limits
2431
+ * @param limits.min the minimal bounds limits
2432
+ * @param limits.max the maximal bounds limits
2446
2433
  * @signature
2447
2434
  * P.clamp(value, { min, max });
2448
2435
  * @example
@@ -2458,8 +2445,9 @@ declare function clamp(value: number, limits: {
2458
2445
  }): number;
2459
2446
  /**
2460
2447
  * Clamp the given value within the inclusive min and max bounds.
2461
- * @param value the number
2462
2448
  * @param limits the bounds limits
2449
+ * @param limits.min the minimal bounds limits
2450
+ * @param limits.max the maximal bounds limits
2463
2451
  * @signature
2464
2452
  * P.clamp({ min, max })(value);
2465
2453
  * @example
@@ -2532,7 +2520,6 @@ declare function equals(a: any, b: any): boolean;
2532
2520
  * Returns true if its arguments are equivalent, false otherwise.
2533
2521
  * NOTE: Doesn't handle cyclical data structures.
2534
2522
  * @param a the first object to compare
2535
- * @param b the second object to compare
2536
2523
  * @signature
2537
2524
  * P.equals(b)(a)
2538
2525
  * @example
@@ -2633,20 +2620,19 @@ type Inverted<T extends object> = T[keyof T] extends PropertyKey ? Record<T[keyo
2633
2620
  * @example
2634
2621
  * P.invert({ a: "d", b: "e", c: "f" }) // => { d: "a", e: "b", f: "c" }
2635
2622
  * @dataFirst
2636
- * @category object
2623
+ * @category Object
2637
2624
  * @pipeable
2638
2625
  */
2639
2626
  declare function invert<T extends object>(object: T): Inverted<T>;
2640
2627
  /**
2641
2628
  * Returns an object whose keys are values are swapped. If the object contains duplicate values,
2642
2629
  * subsequent values will overwrite previous values.
2643
- * @param object the object
2644
2630
  * @signature
2645
2631
  * P.invert()(object)
2646
2632
  * @example
2647
2633
  * P.pipe({ a: "d", b: "e", c: "f" }, P.invert()); // => { d: "a", e: "b", f: "c" }
2648
2634
  * @dataLast
2649
- * @category object
2635
+ * @category Object
2650
2636
  * @pipeable
2651
2637
  */
2652
2638
  declare function invert<T extends object>(): (object: T) => Inverted<T>;
@@ -2771,10 +2757,9 @@ declare function merge<A, B>(b: B): (a: A) => A & B;
2771
2757
  declare function omit<T extends object, K extends keyof T>(data: T, propNames: ReadonlyArray<K>): Omit<T, K>;
2772
2758
  /**
2773
2759
  * Returns a partial copy of an object omitting the keys specified.
2774
- * @param data the object
2775
2760
  * @param propNames the property names
2776
2761
  * @signature
2777
- * P.omit(names)(obj);
2762
+ * P.omit(propNames)(obj);
2778
2763
  * @example
2779
2764
  * P.pipe({ a: 1, b: 2, c: 3, d: 4 }, P.omit(['a', 'd'])) // => { b: 2, c: 3 }
2780
2765
  * @dataLast
@@ -2866,7 +2851,6 @@ declare function pathOr<T, A extends keyof Pathable<T>, B extends keyof Pathable
2866
2851
  declare function pathOr<T, A extends keyof Pathable<T>, B extends keyof Pathable1<T, A>, C extends keyof Pathable2<T, A, B>>(object: T, path: readonly [A, B, C], defaultValue: PathValue3<T, A, B, C>): PathValue3<T, A, B, C>;
2867
2852
  /**
2868
2853
  * Gets the value at `path` of `object`. If the resolved value is `undefined`, the `defaultValue` is returned in its place.
2869
- * @param object the target object
2870
2854
  * @param path the path of the property to get
2871
2855
  * @param defaultValue the default value
2872
2856
  * @signature P.pathOr(array, defaultValue)(object)
@@ -3035,11 +3019,10 @@ type Narrow<A> = Try<A, [], NarrowRaw<A>>;
3035
3019
  declare function setPath<T, TPath extends Array<PropertyKey> & Path<T>>(object: T, path: Narrow<TPath>, value: ValueAtPath<T, TPath>): T;
3036
3020
  /**
3037
3021
  * Sets the value at `path` of `object`. `path` can be an array or a path string.
3038
- * @param obj the target method
3039
3022
  * @param path the property name
3040
3023
  * @param value the value to set
3041
3024
  * @signature
3042
- * P.setPath(obj, path, value)
3025
+ * P.setPath(path, value)
3043
3026
  * @example
3044
3027
  * P.pipe({ a: { b: 1 } }, P.setPath(['a', 'b'], 2)) // { a: { b: 2 } }
3045
3028
  * @dataFirst
@@ -3131,7 +3114,8 @@ declare namespace toPairs {
3131
3114
  * @pipeable
3132
3115
  * @category Object
3133
3116
  */
3134
- declare function values<T>(source: Record<PropertyKey, T> | ArrayLike<T>): Array<T>;
3117
+ type Values<T extends object> = T extends ReadonlyArray<unknown> | [] ? Array<T[number]> : Array<T[keyof T]>;
3118
+ declare function values<T extends object>(source: T): Values<T>;
3135
3119
 
3136
3120
  type Splitter = '-' | '_' | '/' | '.';
3137
3121
  type LastOfArray<T extends any[]> = T extends [...any, infer R] ? R : never;
@@ -3176,6 +3160,19 @@ declare function toKebabCase<T extends string | readonly string[], Joiner extend
3176
3160
  declare function toSnakeCase(): '';
3177
3161
  declare function toSnakeCase<T extends string | readonly string[]>(string_?: T): JoinByCase<T, '_'>;
3178
3162
 
3163
+ /**
3164
+ * Returns human readable file size.
3165
+ * @param bytes the file size in bytes
3166
+ * @param base the base (1000 or 1024)
3167
+ * @signature
3168
+ * P.humanReadableFileSize(bytes, base)
3169
+ * @example
3170
+ * P.humanReadableFileSize(1000) // => '1.0 kB'
3171
+ * P.humanReadableFileSize(2097152, 1024) // => '2.0 Mib'
3172
+ * @category String
3173
+ */
3174
+ declare function humanReadableFileSize(bytes: number, base?: 1000 | 1024): string;
3175
+
3179
3176
  /**
3180
3177
  * Random a non-cryptographic random string from characters a-zA-Z0-9.
3181
3178
  * @param length the length of the random string
@@ -3186,6 +3183,18 @@ declare function toSnakeCase<T extends string | readonly string[]>(string_?: T):
3186
3183
  */
3187
3184
  declare function randomString(length: number): string;
3188
3185
 
3186
+ /**
3187
+ * Turn any string into a URL/DOM safe string.
3188
+ * @param str the string to slugify
3189
+ * @signature
3190
+ * P.slugify(str)
3191
+ * @example
3192
+ * P.slugify('FooBar') // => 'foobar'
3193
+ * P.slugify('This!-is*&%#@^up!') // => 'this-is-up'
3194
+ * @category String
3195
+ */
3196
+ declare function slugify(str: string): string;
3197
+
3189
3198
  /**
3190
3199
  * Converts a path string to an array of keys.
3191
3200
  * @param path a string path
@@ -3218,4 +3227,4 @@ declare function type(val: any): string;
3218
3227
 
3219
3228
  declare const isBrowser: boolean;
3220
3229
 
3221
- export { Joined, KEY_CODES, StringToPath, _setPath, addProp, allPass, anyPass, chunk, clamp, clone, compact, concat, convertToUnit, countBy, createPipe, difference, differenceWith, drop, dropLast, equals, filter, find, findIndex, findLast, findLastIndex, first, flatMap, flatMapToObj, flatten, flattenDeep, forEach, forEachObj, fromPairs, groupBy, humanReadableFileSize, identity, increaseWithUnit, indexBy, intersection, intersectionWith, invert, isArray, isBoolean, isBrowser, isDate, isDefined, isEmpty, isError, isFunction, isNil, isNonNull, isNot, isNumber, isObject, isPromise, isString, isTruthy, isUppercase, join, keys, last, length, map, mapKeys, mapToObj, mapValues, maxBy, meanBy, merge, mergeAll, minBy, noop, omit, omitBy, once, partition, pathOr, pick, pickBy, pipe, prop, purry, randomString, range, reduce, reject, reverse, sample, set, setPath, shuffle, sleep, sort, sortBy, splitAt, splitByCase, splitWhen, stringToPath, sumBy, swapIndices, swapProps, take, takeWhile, toCamelCase, toKebabCase, toLowerFirst, toPairs, toPascalCase, toSnakeCase, toUpperFirst, type, uniq, uniqBy, uniqWith, values, zip, zipObj, zipWith };
3230
+ export { Joined, KEY_CODES, StringToPath, _setPath, addProp, allPass, anyPass, chunk, clamp, clone, compact, concat, countBy, createPipe, difference, differenceWith, drop, dropLast, equals, filter, find, findIndex, findLast, findLastIndex, first, flatMap, flatMapToObj, flatten, flattenDeep, forEach, forEachObj, fromPairs, groupBy, humanReadableFileSize, identity, indexBy, intersection, intersectionWith, invert, isArray, isBoolean, isBrowser, isDate, isDefined, isEmpty, isError, isFunction, isNil, isNonNull, isNot, isNumber, isObject, isPromise, isString, isTruthy, isUppercase, join, keys, last, length, map, mapKeys, mapToObj, mapValues, maxBy, meanBy, merge, mergeAll, minBy, noop, omit, omitBy, once, partition, pathOr, pick, pickBy, pipe, prop, purry, randomString, range, reduce, reject, reverse, sample, set, setPath, shuffle, sleep, slugify, sort, sortBy, splitAt, splitByCase, splitWhen, stringToPath, sumBy, swapIndices, swapProps, take, takeWhile, toCamelCase, toKebabCase, toLowerFirst, toPairs, toPascalCase, toSnakeCase, toUpperFirst, type, uniq, uniqBy, uniqWith, values, zip, zipObj, zipWith };