extra-utils 5.16.0 → 5.18.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.
Files changed (57) hide show
  1. package/README.md +17 -7
  2. package/lib/fp/index.d.ts +4 -0
  3. package/lib/fp/index.js +5 -0
  4. package/lib/fp/index.js.map +1 -0
  5. package/lib/fp/not.d.ts +1 -0
  6. package/lib/fp/not.js +4 -0
  7. package/lib/fp/not.js.map +1 -0
  8. package/lib/fp/pipe-async.js.map +1 -0
  9. package/lib/fp/pipe.js.map +1 -0
  10. package/lib/fp/reducers/index.js.map +1 -0
  11. package/lib/fp/reducers/max.js.map +1 -0
  12. package/lib/fp/reducers/min.js.map +1 -0
  13. package/lib/fp/reducers/product.js.map +1 -0
  14. package/lib/fp/reducers/sum.js.map +1 -0
  15. package/lib/index.d.ts +1 -3
  16. package/lib/index.js +1 -3
  17. package/lib/index.js.map +1 -1
  18. package/lib/number/index.d.ts +1 -0
  19. package/lib/number/index.js +1 -0
  20. package/lib/number/index.js.map +1 -1
  21. package/lib/number/modf.d.ts +1 -0
  22. package/lib/number/modf.js +6 -0
  23. package/lib/number/modf.js.map +1 -0
  24. package/package.json +1 -1
  25. package/src/fp/index.ts +4 -0
  26. package/src/fp/not.ts +5 -0
  27. package/src/index.ts +1 -3
  28. package/src/number/index.ts +1 -0
  29. package/src/number/modf.ts +5 -0
  30. package/lib/pipe-async.js.map +0 -1
  31. package/lib/pipe.js.map +0 -1
  32. package/lib/reducers/index.js.map +0 -1
  33. package/lib/reducers/max.js.map +0 -1
  34. package/lib/reducers/min.js.map +0 -1
  35. package/lib/reducers/product.js.map +0 -1
  36. package/lib/reducers/sum.js.map +0 -1
  37. /package/lib/{pipe-async.d.ts → fp/pipe-async.d.ts} +0 -0
  38. /package/lib/{pipe-async.js → fp/pipe-async.js} +0 -0
  39. /package/lib/{pipe.d.ts → fp/pipe.d.ts} +0 -0
  40. /package/lib/{pipe.js → fp/pipe.js} +0 -0
  41. /package/lib/{reducers → fp/reducers}/index.d.ts +0 -0
  42. /package/lib/{reducers → fp/reducers}/index.js +0 -0
  43. /package/lib/{reducers → fp/reducers}/max.d.ts +0 -0
  44. /package/lib/{reducers → fp/reducers}/max.js +0 -0
  45. /package/lib/{reducers → fp/reducers}/min.d.ts +0 -0
  46. /package/lib/{reducers → fp/reducers}/min.js +0 -0
  47. /package/lib/{reducers → fp/reducers}/product.d.ts +0 -0
  48. /package/lib/{reducers → fp/reducers}/product.js +0 -0
  49. /package/lib/{reducers → fp/reducers}/sum.d.ts +0 -0
  50. /package/lib/{reducers → fp/reducers}/sum.js +0 -0
  51. /package/src/{pipe-async.ts → fp/pipe-async.ts} +0 -0
  52. /package/src/{pipe.ts → fp/pipe.ts} +0 -0
  53. /package/src/{reducers → fp/reducers}/index.ts +0 -0
  54. /package/src/{reducers → fp/reducers}/max.ts +0 -0
  55. /package/src/{reducers → fp/reducers}/min.ts +0 -0
  56. /package/src/{reducers → fp/reducers}/product.ts +0 -0
  57. /package/src/{reducers → fp/reducers}/sum.ts +0 -0
package/README.md CHANGED
@@ -125,6 +125,8 @@ function lerp(
125
125
  alpha: number
126
126
  , [from, to]: readonly [from: number, to: number]
127
127
  ): number
128
+
129
+ function modf(value: number): [integralPart: number, fractionalPart: number]
128
130
  ```
129
131
 
130
132
  ### Object
@@ -299,15 +301,15 @@ function isSymbol(val: unknown): val is symbol
299
301
  function isntSymbol<T>(val: T): val is Exclude<T, symbol>
300
302
  ```
301
303
 
302
- ### Reducers
304
+ ### Functional programming
305
+ #### not
303
306
  ```ts
304
- function max(result: number, current: number): number
305
- function min(result: number, current: number): number
306
- function sum(result: number, current: number): number
307
- function product(result: number, current: number): number
307
+ function not<Args extends unknown[]>(
308
+ predicate: (...args: Args) => boolean
309
+ ): (...args: Args) => boolean
308
310
  ```
309
311
 
310
- ### pipe
312
+ #### pipe
311
313
  ```ts
312
314
  function pipe<A, B, C, D, E, F, G, H>(
313
315
  value: A
@@ -378,7 +380,7 @@ function pipe<T, U>(
378
380
  ): U
379
381
  ```
380
382
 
381
- ### pipeAsync
383
+ #### pipeAsync
382
384
  ```ts
383
385
  function pipeAsync<A, B, C, D, E, F, G, H>(
384
386
  value: Awaitable<A>
@@ -448,3 +450,11 @@ function pipeAsync<T, U>(
448
450
  , ...operators: Array<(value: any) => Awaitable<unknown>>
449
451
  ): Promise<U>
450
452
  ```
453
+
454
+ #### Reducers
455
+ ```ts
456
+ function max(result: number, current: number): number
457
+ function min(result: number, current: number): number
458
+ function sum(result: number, current: number): number
459
+ function product(result: number, current: number): number
460
+ ```
@@ -0,0 +1,4 @@
1
+ export * from './reducers/index.js';
2
+ export * from './not.js';
3
+ export * from './pipe.js';
4
+ export * from './pipe-async.js';
@@ -0,0 +1,5 @@
1
+ export * from './reducers/index.js';
2
+ export * from './not.js';
3
+ export * from './pipe.js';
4
+ export * from './pipe-async.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/fp/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function not<Args extends unknown[]>(predicate: (...args: Args) => boolean): (...args: Args) => boolean;
package/lib/fp/not.js ADDED
@@ -0,0 +1,4 @@
1
+ export function not(predicate) {
2
+ return (...args) => !predicate(...args);
3
+ }
4
+ //# sourceMappingURL=not.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not.js","sourceRoot":"","sources":["../../src/fp/not.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CACjB,SAAqC;IAErC,OAAO,CAAC,GAAG,IAAU,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAA;AAC/C,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe-async.js","sourceRoot":"","sources":["../../src/fp/pipe-async.ts"],"names":[],"mappings":"AAqEA,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAAmB,EACnB,GAAG,SAAyC;IAE5C,IAAI,MAAM,GAAU,MAAM,KAAK,CAAA;IAC/B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAA;KAChC;IACD,OAAO,MAAW,CAAA;AACpB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../../src/fp/pipe.ts"],"names":[],"mappings":"AAmEA,MAAM,UAAU,IAAI,CAClB,KAAQ,EACR,GAAG,SAAyC;IAE5C,IAAI,MAAM,GAAU,KAAK,CAAA;IACzB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;KAC1B;IACD,OAAO,MAAW,CAAA;AACpB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fp/reducers/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"max.js","sourceRoot":"","sources":["../../../src/fp/reducers/max.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAe;IACjD,OAAO,OAAO,GAAG,MAAM;QAClB,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"min.js","sourceRoot":"","sources":["../../../src/fp/reducers/min.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAe;IACjD,OAAO,OAAO,GAAG,MAAM;QAClB,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../../../src/fp/reducers/product.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,OAAe;IACrD,OAAO,MAAM,GAAG,OAAO,CAAA;AACzB,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sum.js","sourceRoot":"","sources":["../../../src/fp/reducers/sum.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAe;IACjD,OAAO,MAAM,GAAG,OAAO,CAAA;AACzB,CAAC"}
package/lib/index.d.ts CHANGED
@@ -11,6 +11,4 @@ export * from './is-regexp.js';
11
11
  export * from './is-symbol.js';
12
12
  export * from './is-date.js';
13
13
  export * from './is-function.js';
14
- export * from './reducers/index.js';
15
- export * from './pipe.js';
16
- export * from './pipe-async.js';
14
+ export * from './fp/index.js';
package/lib/index.js CHANGED
@@ -11,7 +11,5 @@ export * from './is-regexp.js';
11
11
  export * from './is-symbol.js';
12
12
  export * from './is-date.js';
13
13
  export * from './is-function.js';
14
- export * from './reducers/index.js';
15
- export * from './pipe.js';
16
- export * from './pipe-async.js';
14
+ export * from './fp/index.js';
17
15
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA"}
@@ -10,3 +10,4 @@ export * from './remap-to-weighted-item.js';
10
10
  export * from './remap-to-index.js';
11
11
  export * from './remap-to-weighted-index.js';
12
12
  export * from './lerp.js';
13
+ export * from './modf.js';
@@ -10,4 +10,5 @@ export * from './remap-to-weighted-item.js';
10
10
  export * from './remap-to-index.js';
11
11
  export * from './remap-to-weighted-index.js';
12
12
  export * from './lerp.js';
13
+ export * from './modf.js';
13
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,WAAW,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/number/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,WAAW,CAAA;AACzB,cAAc,WAAW,CAAA"}
@@ -0,0 +1 @@
1
+ export declare function modf(value: number): [integralPart: number, fractionalPart: number];
@@ -0,0 +1,6 @@
1
+ export function modf(value) {
2
+ const fractionalPart = value % 1;
3
+ const integralPart = Math.round(value - fractionalPart);
4
+ return [integralPart, fractionalPart];
5
+ }
6
+ //# sourceMappingURL=modf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modf.js","sourceRoot":"","sources":["../../src/number/modf.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,IAAI,CAAC,KAAa;IAChC,MAAM,cAAc,GAAG,KAAK,GAAG,CAAC,CAAA;IAChC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,cAAc,CAAC,CAAA;IACvD,OAAO,CAAC,YAAY,EAAE,cAAc,CAAC,CAAA;AACvC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "extra-utils",
3
- "version": "5.16.0",
3
+ "version": "5.18.0",
4
4
  "description": "Utilities for JavaScript and Typescript",
5
5
  "files": [
6
6
  "src",
@@ -0,0 +1,4 @@
1
+ export * from './reducers/index.js'
2
+ export * from './not.js'
3
+ export * from './pipe.js'
4
+ export * from './pipe-async.js'
package/src/fp/not.ts ADDED
@@ -0,0 +1,5 @@
1
+ export function not<Args extends unknown[]>(
2
+ predicate: (...args: Args) => boolean
3
+ ): (...args: Args) => boolean {
4
+ return (...args: Args) => !predicate(...args)
5
+ }
package/src/index.ts CHANGED
@@ -11,6 +11,4 @@ export * from './is-regexp.js'
11
11
  export * from './is-symbol.js'
12
12
  export * from './is-date.js'
13
13
  export * from './is-function.js'
14
- export * from './reducers/index.js'
15
- export * from './pipe.js'
16
- export * from './pipe-async.js'
14
+ export * from './fp/index.js'
@@ -10,3 +10,4 @@ export * from './remap-to-weighted-item.js'
10
10
  export * from './remap-to-index.js'
11
11
  export * from './remap-to-weighted-index.js'
12
12
  export * from './lerp.js'
13
+ export * from './modf.js'
@@ -0,0 +1,5 @@
1
+ export function modf(value: number): [integralPart: number, fractionalPart: number] {
2
+ const fractionalPart = value % 1
3
+ const integralPart = Math.round(value - fractionalPart)
4
+ return [integralPart, fractionalPart]
5
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipe-async.js","sourceRoot":"","sources":["../src/pipe-async.ts"],"names":[],"mappings":"AAqEA,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAAmB,EACnB,GAAG,SAAyC;IAE5C,IAAI,MAAM,GAAU,MAAM,KAAK,CAAA;IAC/B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,CAAA;KAChC;IACD,OAAO,MAAW,CAAA;AACpB,CAAC"}
package/lib/pipe.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"pipe.js","sourceRoot":"","sources":["../src/pipe.ts"],"names":[],"mappings":"AAmEA,MAAM,UAAU,IAAI,CAClB,KAAQ,EACR,GAAG,SAAyC;IAE5C,IAAI,MAAM,GAAU,KAAK,CAAA;IACzB,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;QAChC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAA;KAC1B;IACD,OAAO,MAAW,CAAA;AACpB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/reducers/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,cAAc,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"max.js","sourceRoot":"","sources":["../../src/reducers/max.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAe;IACjD,OAAO,OAAO,GAAG,MAAM;QAClB,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAA;AACf,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"min.js","sourceRoot":"","sources":["../../src/reducers/min.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAe;IACjD,OAAO,OAAO,GAAG,MAAM;QAClB,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,MAAM,CAAA;AACf,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"product.js","sourceRoot":"","sources":["../../src/reducers/product.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,OAAe;IACrD,OAAO,MAAM,GAAG,OAAO,CAAA;AACzB,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sum.js","sourceRoot":"","sources":["../../src/reducers/sum.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAe;IACjD,OAAO,MAAM,GAAG,OAAO,CAAA;AACzB,CAAC"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes