fnts 2.0.1 → 2.1.1

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/apply.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module Application
3
+ */
4
+ import type { VariadicFunction } from './types/function';
5
+ /**
6
+ * `ReturnType` utility for multiple functions.
7
+ */
8
+ export type ReturnTypes<Functions extends VariadicFunction[], Returns extends any[] = []> = Functions['length'] extends 0 ? Returns : Functions extends [infer Function extends VariadicFunction, ...infer Rest extends VariadicFunction[]] ? ReturnTypes<Rest, [...Returns, ReturnType<Function>]> : never;
9
+ /**
10
+ * Applies all functions on curried arguments and returns an array of results.
11
+ */
12
+ export default function apply<Functions extends VariadicFunction[]>(...functions: Functions): (...args: Parameters<Functions[0]>) => ReturnTypes<Functions>;
package/apply.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ /**
3
+ * @module Application
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ /**
7
+ * Applies all functions on curried arguments and returns an array of results.
8
+ */
9
+ function apply() {
10
+ var functions = [];
11
+ for (var _i = 0; _i < arguments.length; _i++) {
12
+ functions[_i] = arguments[_i];
13
+ }
14
+ return function () {
15
+ var args = [];
16
+ for (var _i = 0; _i < arguments.length; _i++) {
17
+ args[_i] = arguments[_i];
18
+ }
19
+ var length = functions.length;
20
+ var result = new Array(length);
21
+ for (var index = 0; index < length; index += 1) {
22
+ result[index] = functions[index].apply(functions, args);
23
+ }
24
+ return result;
25
+ };
26
+ }
27
+ exports.default = apply;
package/get.d.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * combined through dot-notation.
7
7
  */
8
8
  export type Flatten<Source extends Record<string, unknown> | any[]> = keyof Source extends keyof any[] ? `${number}` : (keyof Source | keyof {
9
- [Key in keyof Source as Source[Key] extends Record<string, unknown> ? `${Key}.${Flatten<Source[Key]>}` : Source[Key] extends any[] ? Source[Key] extends Array<any[]> | Record<string, unknown>[] ? `${Key}.${number}` | `${Key}.${number}.${Flatten<Source[Key][number]>}` : `${Key}.${number}` : Key]: never;
9
+ [Key in keyof Source as Key extends string ? Source[Key] extends Record<string, unknown> ? `${Key}.${Flatten<Source[Key]>}` : Source[Key] extends any[] ? Source[Key] extends Array<any[]> | Record<string, unknown>[] ? `${Key}.${number}` | `${Key}.${number}.${Flatten<Source[Key][number]>}` : `${Key}.${number}` : Key : never]: never;
10
10
  });
11
11
  /**
12
12
  * Gets the value type inside a nested object type `Source` by provided `Path`
package/get.js CHANGED
@@ -18,7 +18,7 @@ function get() {
18
18
  var length = keys.length;
19
19
  var result = source;
20
20
  for (var index = 0; index < length; index += 1) {
21
- result = result[keys[index]];
21
+ result = result === null || result === void 0 ? void 0 : result[keys === null || keys === void 0 ? void 0 : keys[index]];
22
22
  }
23
23
  return result;
24
24
  }).apply(void 0, args);
package/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  export { default as get } from './get';
2
2
  export { default as tap } from './tap';
3
3
  export { default as pipe } from './pipe';
4
+ export { default as apply } from './apply';
4
5
  export { default as curry } from './curry';
5
- export { default as match } from './guard';
6
+ export { default as guard } from './guard';
6
7
  export { default as inject } from './inject';
7
8
  export { default as compose } from './compose';
8
9
  export { default as rethrow } from './rethrow';
package/index.js CHANGED
@@ -1,16 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.identity = exports.rethrow = exports.compose = exports.inject = exports.match = exports.curry = exports.pipe = exports.tap = exports.get = void 0;
3
+ exports.identity = exports.rethrow = exports.compose = exports.inject = exports.guard = exports.curry = exports.apply = exports.pipe = exports.tap = exports.get = void 0;
4
4
  var get_1 = require("./get");
5
5
  Object.defineProperty(exports, "get", { enumerable: true, get: function () { return get_1.default; } });
6
6
  var tap_1 = require("./tap");
7
7
  Object.defineProperty(exports, "tap", { enumerable: true, get: function () { return tap_1.default; } });
8
8
  var pipe_1 = require("./pipe");
9
9
  Object.defineProperty(exports, "pipe", { enumerable: true, get: function () { return pipe_1.default; } });
10
+ var apply_1 = require("./apply");
11
+ Object.defineProperty(exports, "apply", { enumerable: true, get: function () { return apply_1.default; } });
10
12
  var curry_1 = require("./curry");
11
13
  Object.defineProperty(exports, "curry", { enumerable: true, get: function () { return curry_1.default; } });
12
14
  var guard_1 = require("./guard");
13
- Object.defineProperty(exports, "match", { enumerable: true, get: function () { return guard_1.default; } });
15
+ Object.defineProperty(exports, "guard", { enumerable: true, get: function () { return guard_1.default; } });
14
16
  var inject_1 = require("./inject");
15
17
  Object.defineProperty(exports, "inject", { enumerable: true, get: function () { return inject_1.default; } });
16
18
  var compose_1 = require("./compose");
@@ -5,8 +5,8 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var compose_1 = require("../../compose");
7
7
  var permutation_2_1 = require("../../permutation/permutation-2");
8
- var guards_1 = require("./guards");
9
8
  var fold_1 = require("./fold");
9
+ var guards_1 = require("./guards");
10
10
  function foldMap() {
11
11
  var args = [];
12
12
  for (var _i = 0; _i < arguments.length; _i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnts",
3
- "version": "2.0.1",
3
+ "version": "2.1.1",
4
4
  "license": "MIT",
5
5
  "author": "Dmytro Vasylkivskyi",
6
6
  "description": "TypeScript / JavaScript FP utilities",
package/pipe.d.ts CHANGED
@@ -13,12 +13,12 @@ export type Depipe<Functions extends UnaryFunction[], Arguments extends any[] =
13
13
  /**
14
14
  * (A -> B) . (B -> C) = A -> C
15
15
  */
16
- export default function pipe<A extends any[], B, C>(first: (...args: A) => B, second: (arg: B) => C): (...args: A) => C;
16
+ export default function pipe<A extends any[], B, C>(f: (...args: A) => B, g: (arg: B) => C): (...args: A) => C;
17
17
  /**
18
18
  * (A -> B) . (B -> C) = A -> C
19
19
  */
20
20
  export default function pipe<A extends any[], B, C>(...args: [
21
21
  ...args: A,
22
- first: (...args: A) => B,
23
- second: (arg: B) => C
22
+ f: (...args: A) => B,
23
+ g: (arg: B) => C
24
24
  ]): C;
package/types/effect.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  * @module Types
3
3
  */
4
4
 
5
- import type { VariadicFunction } from './function';
5
+ import type { VariadicFunction } from './function'
6
6
 
7
7
  /**
8
8
  * A simple side effect function descriptor.
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export type { Map } from './map';
2
- export type { Last } from './last';
3
- export type { Slice } from './slice';
4
- export type { Tuple } from './tuple';
5
- export type { Effect } from './effect';
6
- export type { Gradual } from './gradual';
7
- export type { UnaryFunction, VariadicFunction } from './function';
1
+ export type { Map } from './map'
2
+ export type { Last } from './last'
3
+ export type { Slice } from './slice'
4
+ export type { Tuple } from './tuple'
5
+ export type { Effect } from './effect'
6
+ export type { Gradual } from './gradual'
7
+ export type { UnaryFunction, VariadicFunction } from './function'