fnts 2.1.1 → 3.0.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 (95) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/apply.js +6 -17
  4. package/compose.js +3 -16
  5. package/curry.js +6 -20
  6. package/either/either-sync.d.ts +1 -1
  7. package/either/either-sync.js +5 -8
  8. package/either/either.d.ts +2 -2
  9. package/either/either.js +5 -8
  10. package/either/index.d.ts +4 -4
  11. package/either/index.js +4 -11
  12. package/either/left.js +8 -13
  13. package/either/operators/bifold/bifold.d.ts +3 -3
  14. package/either/operators/bifold/bifold.js +7 -10
  15. package/either/operators/bifold/bifoldl.d.ts +2 -2
  16. package/either/operators/bifold/bifoldl.js +5 -8
  17. package/either/operators/bifold/bifoldr.d.ts +2 -2
  18. package/either/operators/bifold/bifoldr.js +5 -8
  19. package/either/operators/bifold/index.d.ts +3 -3
  20. package/either/operators/bifold/index.js +3 -9
  21. package/either/operators/bifold-map/bifold-map.d.ts +1 -1
  22. package/either/operators/bifold-map/bifold-map.js +16 -23
  23. package/either/operators/bifold-map/bifoldl-map.d.ts +3 -3
  24. package/either/operators/bifold-map/bifoldl-map.js +9 -16
  25. package/either/operators/bifold-map/bifoldr-map.d.ts +3 -3
  26. package/either/operators/bifold-map/bifoldr-map.js +9 -16
  27. package/either/operators/bifold-map/index.d.ts +3 -3
  28. package/either/operators/bifold-map/index.js +3 -9
  29. package/either/operators/bimap/bimap.d.ts +1 -1
  30. package/either/operators/bimap/bimap.js +10 -17
  31. package/either/operators/bimap/first.d.ts +2 -2
  32. package/either/operators/bimap/first.js +12 -19
  33. package/either/operators/bimap/index.d.ts +3 -3
  34. package/either/operators/bimap/index.js +3 -9
  35. package/either/operators/bimap/second.d.ts +2 -2
  36. package/either/operators/bimap/second.js +12 -19
  37. package/either/operators/bindr.d.ts +1 -1
  38. package/either/operators/bindr.js +11 -18
  39. package/either/operators/guards.d.ts +3 -3
  40. package/either/operators/guards.js +7 -13
  41. package/either/operators/index.d.ts +5 -5
  42. package/either/operators/index.js +5 -30
  43. package/either/right.js +8 -13
  44. package/guard.d.ts +3 -3
  45. package/guard.js +8 -19
  46. package/identity.js +1 -4
  47. package/index.d.ts +9 -10
  48. package/index.js +9 -23
  49. package/inject.js +7 -18
  50. package/lens/get.d.ts +24 -0
  51. package/lens/get.js +29 -0
  52. package/lens/index.d.ts +3 -0
  53. package/lens/index.js +3 -0
  54. package/lens/lens.d.ts +19 -0
  55. package/lens/lens.js +17 -0
  56. package/lens/set.d.ts +30 -0
  57. package/lens/set.js +44 -0
  58. package/maybe/index.d.ts +3 -3
  59. package/maybe/index.js +3 -9
  60. package/maybe/just.js +8 -13
  61. package/maybe/maybe.d.ts +2 -2
  62. package/maybe/maybe.js +5 -8
  63. package/maybe/nothing.js +7 -12
  64. package/maybe/operators/bind.d.ts +1 -1
  65. package/maybe/operators/bind.js +11 -18
  66. package/maybe/operators/fmap.d.ts +1 -1
  67. package/maybe/operators/fmap.js +12 -19
  68. package/maybe/operators/fold-map.d.ts +3 -3
  69. package/maybe/operators/fold-map.js +9 -16
  70. package/maybe/operators/fold.d.ts +3 -3
  71. package/maybe/operators/fold.js +7 -10
  72. package/maybe/operators/guards.d.ts +3 -3
  73. package/maybe/operators/guards.js +7 -13
  74. package/maybe/operators/index.d.ts +5 -5
  75. package/maybe/operators/index.js +5 -26
  76. package/package.json +11 -4
  77. package/permutation/index.d.ts +2 -2
  78. package/permutation/index.js +2 -7
  79. package/permutation/permutation-2.js +5 -12
  80. package/permutation/permutation-3.d.ts +1 -1
  81. package/permutation/permutation-3.js +5 -12
  82. package/pipe.js +4 -16
  83. package/rethrow.js +3 -6
  84. package/set.d.ts +24 -0
  85. package/set.js +35 -0
  86. package/tap.d.ts +1 -1
  87. package/tap.js +4 -7
  88. package/tsconfig.json +3 -3
  89. package/types/flatten.d.ts +34 -0
  90. package/types/index.d.ts +10 -7
  91. package/types/slice.d.ts +1 -1
  92. package/types/trim.d.ts +19 -0
  93. package/types/unshift.d.ts +16 -0
  94. package/get.d.ts +0 -25
  95. package/get.js +0 -26
package/tap.js CHANGED
@@ -1,15 +1,12 @@
1
- "use strict";
2
1
  /**
3
2
  * @module Side Effects
4
3
  */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var inject_1 = require("./inject");
7
- var identity_1 = require("./identity");
4
+ import inject from './inject.js';
5
+ import identity from './identity.js';
8
6
  /**
9
7
  * Performs a side effect
10
8
  * passing the received argument through itself.
11
9
  */
12
- function tap(effect) {
13
- return (0, inject_1.default)(identity_1.default, effect);
10
+ export default function tap(effect) {
11
+ return inject(identity, effect);
14
12
  }
15
- exports.default = tap;
package/tsconfig.json CHANGED
@@ -5,21 +5,21 @@
5
5
  "moduleResolution": "node",
6
6
  "lib": [
7
7
  "es2015.iterable",
8
- "es2019"
8
+ "esnext",
9
+ "dom"
9
10
  ],
11
+ "esModuleInterop": true,
10
12
  "strict": true,
11
13
  "alwaysStrict": true,
12
14
  "skipLibCheck": true,
13
15
  "noImplicitAny": true,
14
16
  "noUnusedLocals": false,
15
- "keyofStringsOnly": true,
16
17
  "strictNullChecks": true,
17
18
  "noImplicitReturns": true,
18
19
  "noErrorTruncation": true,
19
20
  "noUnusedParameters": false,
20
21
  "strictFunctionTypes": true,
21
22
  "strictBindCallApply": true,
22
- "noStrictGenericChecks": true,
23
23
  "allowUnreachableCode": false,
24
24
  "forceConsistentCasingInFileNames": true
25
25
  }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @module Types
3
+ */
4
+
5
+ /**
6
+ * Type subjective to flattening.
7
+ */
8
+ export type Flattenable = Record<string, unknown> | any[]
9
+
10
+ /**
11
+ * Recursively flattens object type to a union of its keys
12
+ * combined through dot-notation.
13
+ */
14
+ export type Flatten<
15
+ Source extends Record<string, unknown> | any[],
16
+ > = keyof Source extends keyof any[]
17
+ ? `${number}`
18
+ : (
19
+ | keyof Source
20
+ | keyof {
21
+ [
22
+ Key in keyof Source as
23
+ Key extends string
24
+ ? Source[Key] extends Record<string, unknown>
25
+ ? `${Key}.${Flatten<Source[Key]>}`
26
+ : Source[Key] extends any[]
27
+ ? Source[Key] extends Array<any[]> | Record<string, unknown>[]
28
+ ? `${Key}.${number}` | `${Key}.${number}.${Flatten<Source[Key][number]>}`
29
+ : `${Key}.${number}`
30
+ : Key
31
+ : never
32
+ ] : never
33
+ }
34
+ )
package/types/index.d.ts CHANGED
@@ -1,7 +1,10 @@
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 * from './map'
2
+ export type * from './last'
3
+ export type * from './trim'
4
+ export type * from './slice'
5
+ export type * from './tuple'
6
+ export type * from './effect'
7
+ export type * from './gradual'
8
+ export type * from './unshift'
9
+ export type * from './flatten'
10
+ export type * from './function'
package/types/slice.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  import type { Tuple } from './tuple'
6
6
 
7
7
  /**
8
- * Slices the tuple by `C` amount of entries from the **end**.
8
+ * Removes `C` amount of `T` elements from the **start**.
9
9
  */
10
10
  export type Slice<
11
11
  T extends any[] | readonly any[],
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module Types
3
+ */
4
+
5
+ import { Tuple } from './tuple'
6
+
7
+ /**
8
+ * Removes `C` amount of `T` elements from the **end**.
9
+ */
10
+ export type Trim<
11
+ T extends any[] | readonly any[],
12
+ C extends number
13
+ > = T['length'] extends C
14
+ ? T
15
+ : T extends readonly [...infer S, ...Tuple<C>]
16
+ ? S
17
+ : T extends [...infer S, ...Tuple<C>]
18
+ ? S
19
+ : T
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @module Types
3
+ */
4
+
5
+ import { Trim } from './trim'
6
+ import { Slice } from './slice'
7
+
8
+ /**
9
+ * Replaces `T` element on specified index `I` with `E`.
10
+ */
11
+ export type Unshift<T extends any[] | readonly any[], I extends number, E> =
12
+ I extends 0
13
+ ? [E, ...Slice<T, 1>]
14
+ : I extends Trim<T, 1>['length']
15
+ ? [...Trim<T, 1>, E]
16
+ : [...Trim<T, Slice<T, I>['length']>, E, ...Slice<Slice<T, I>, 1>]
package/get.d.ts DELETED
@@ -1,25 +0,0 @@
1
- /**
2
- * @module Get
3
- */
4
- /**
5
- * Recursively flattens object type to a union of its keys
6
- * combined through dot-notation.
7
- */
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 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
- });
11
- /**
12
- * Gets the value type inside a nested object type `Source` by provided `Path`
13
- * written in dot-notation.
14
- */
15
- export type Get<Source, Path extends string> = Source extends Record<string, unknown> ? Path extends `${infer Index extends number}.${infer Right}` ? Get<Source, Right> : Path extends `${infer Left extends keyof Source}.${infer Right}` ? Get<Exclude<Source[Left], undefined>, Right> | Extract<Source[Left], undefined> : Path extends keyof Source ? Source[Path] : never : Source extends any[] ? Path extends `${infer Left extends number}.${infer Right}` ? Get<Exclude<Source[Left], undefined>, Right> | Extract<Source[Left], undefined> : Path extends `${infer Index extends number}` ? Source[Index] : never : never;
16
- /**
17
- * Gets the value inside a nested `source` object by provided `path`
18
- * written in dot-notation.
19
- */
20
- export default function get<Source extends Record<string, unknown> | any[], Path extends Flatten<Source>>(path: Path): (source: Source) => Get<Source, Path>;
21
- /**
22
- * Gets the value inside a nested `source` object by provided `path`
23
- * written in dot-notation.
24
- */
25
- export default function get<Source extends Record<string, unknown> | any[], Path extends Flatten<Source>>(source: Source, path: Path): Get<Source, Path>;
package/get.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- /**
3
- * @module Get
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var permutation_2_1 = require("./permutation/permutation-2");
7
- /**
8
- * Gets the value inside a nested `source` object by provided `path`
9
- * written in dot-notation.
10
- */
11
- function get() {
12
- var args = [];
13
- for (var _i = 0; _i < arguments.length; _i++) {
14
- args[_i] = arguments[_i];
15
- }
16
- return (0, permutation_2_1.default)(function (source, path) {
17
- var keys = path.split('.');
18
- var length = keys.length;
19
- var result = source;
20
- for (var index = 0; index < length; index += 1) {
21
- result = result === null || result === void 0 ? void 0 : result[keys === null || keys === void 0 ? void 0 : keys[index]];
22
- }
23
- return result;
24
- }).apply(void 0, args);
25
- }
26
- exports.default = get;