fnts 3.0.0 → 3.0.2

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/README.md CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  <p align="center">
7
7
  <a href="https://github.com/drizzer14/fnts/blob/main/LICENSE">
8
- <img src="https://img.shields.io/github/license/drizzer14/fnts" />
8
+ <img src="https://img.shields.io/github/license/drizzer14/fnts?color=blue&style=for-the-badge" />
9
9
  </a>
10
- <a href="https://travis-ci.com/github/drizzer14/fnts">
11
- <img src="https://img.shields.io/travis/com/drizzer14/fnts" />
10
+ <a href="https://github.com/drizzer14/fnts/actions/workflows/workflow.yml">
11
+ <img src="https://img.shields.io/github/actions/workflow/status/drizzer14/fnts/workflow.yml?color=blue&style=for-the-badge" />
12
12
  </a>
13
13
  <a href="https://www.npmjs.com/package/fnts">
14
- <img src="https://img.shields.io/npm/v/fnts" />
14
+ <img src="https://img.shields.io/npm/v/fnts?color=blue&style=for-the-badge" />
15
15
  </a>
16
16
  </p>
17
17
 
package/either/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './operators/index.js';
1
2
  export { default, Either } from './either.js';
2
3
  export { default as left, Left } from './left.js';
3
4
  export { default as right, Right } from './right.js';
package/either/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './operators/index.js';
1
2
  export { default } from './either.js';
2
3
  export { default as left } from './left.js';
3
4
  export { default as right } from './right.js';
package/lens/lens.js CHANGED
@@ -12,6 +12,7 @@ export default function lens(source) {
12
12
  const setter = set(source);
13
13
  // @ts-ignore
14
14
  return (...args) => {
15
+ // @ts-ignore
15
16
  return args.length === 1 ? getter(args[0]) : setter(args[0], args[1]);
16
17
  };
17
18
  }
package/lens/set.js CHANGED
@@ -9,18 +9,19 @@ export default function set(...args) {
9
9
  switch (args.length) {
10
10
  case 1: {
11
11
  // @ts-ignore
12
- return (path, value) => _set(args[0], path, value);
12
+ return (path, value) => setter(args[0], path, value);
13
13
  }
14
14
  case 2: {
15
15
  // @ts-ignore
16
- return (source) => _set(source, args[1], args[2]);
16
+ return (source) => setter(source, args[0], args[1]);
17
17
  }
18
18
  case 3: {
19
- return _set;
19
+ // @ts-ignore
20
+ return setter(...args);
20
21
  }
21
22
  }
22
23
  }
23
- function _set(source, path, value
24
+ function setter(source, path, value
24
25
  // @ts-ignore
25
26
  ) {
26
27
  // @ts-ignore
package/maybe/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './operators/index.js';
1
2
  export { default, Maybe } from './maybe.js';
2
3
  export { default as just, Just } from './just.js';
3
4
  export { default as nothing, Nothing } from './nothing.js';
package/maybe/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './operators/index.js';
1
2
  export { default } from './maybe.js';
2
3
  export { default as just } from './just.js';
3
4
  export { default as nothing } from './nothing.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fnts",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "license": "MIT",
5
5
  "author": "Dmytro Vasylkivskyi",
6
6
  "description": "TypeScript / JavaScript FP utilities",
@@ -15,19 +15,31 @@
15
15
  "homepage": "https://drizzer14.github.io/fnts",
16
16
  "repository": "https://github.com/drizzer14/fnts",
17
17
  "type": "module",
18
- "module": "index.js",
19
- "types": "index.d.ts",
20
- "sideEffects": false,
21
- "engines": {
22
- "node": ">=20.13.1",
23
- "npm": ">=10.5.2"
24
- },
25
18
  "peerDependencies": {
26
- "typescript": ">=5.0"
19
+ "typescript": ">=5.0 <=5.3.3"
27
20
  },
28
21
  "peerDependenciesMeta": {
29
22
  "typescript": {
30
23
  "optional": true
31
24
  }
25
+ },
26
+ "module": "index.js",
27
+ "types": "index.d.ts",
28
+ "sideEffects": false,
29
+ "exports": {
30
+ ".": "./index.js",
31
+ "./apply": "./apply.js",
32
+ "./compose": "./compose.js",
33
+ "./curry": "./curry.js",
34
+ "./guard": "./guard.js",
35
+ "./identity": "./identity.js",
36
+ "./inject": "./inject.js",
37
+ "./pipe": "./pipe.js",
38
+ "./rethrow": "./rethrow.js",
39
+ "./tap": "./tap.js",
40
+ "./either": "./either/index.js",
41
+ "./lens": "./lens/index.js",
42
+ "./maybe": "./maybe/index.js",
43
+ "./permutation": "./permutation/index.js"
32
44
  }
33
45
  }
@@ -4,7 +4,7 @@
4
4
  export default function permutation2(fn, shouldCurry) {
5
5
  return (...args) => {
6
6
  const [a1, b] = args;
7
- return shouldCurry?.(a1, b) || args.length < fn.length
7
+ return (shouldCurry ? shouldCurry?.(a1, b) : args.length < fn.length)
8
8
  ? (a2) => fn(a2, a1)
9
9
  : fn(a1, b);
10
10
  };
@@ -4,7 +4,7 @@
4
4
  export default function permutation3(fn, shouldCurry) {
5
5
  return (...args) => {
6
6
  const [a1, b, c] = args;
7
- return shouldCurry?.(a1, b, c) || args.length < fn.length
7
+ return (shouldCurry ? shouldCurry?.(a1, b, c) : args.length < fn.length)
8
8
  ? (a2) => fn(a2, a1, b)
9
9
  : fn(a1, b, c);
10
10
  };
package/tsconfig.json CHANGED
@@ -21,6 +21,7 @@
21
21
  "strictFunctionTypes": true,
22
22
  "strictBindCallApply": true,
23
23
  "allowUnreachableCode": false,
24
- "forceConsistentCasingInFileNames": true
24
+ "forceConsistentCasingInFileNames": true,
25
+ "ignoreDeprecations": "5.0"
25
26
  }
26
27
  }
package/set.d.ts DELETED
@@ -1,24 +0,0 @@
1
- /**
2
- * @module Set
3
- */
4
- import type { Unshift } from './types/unshift';
5
- import type { Flatten, Flattenable } from './types/flatten';
6
- /**
7
- * Sets the `Value` type inside a nested object type `Source` by provided `Path`
8
- * written in dot-notation.
9
- */
10
- export type Set<Source extends Flattenable, Path extends string, Value> = Source extends Record<string, unknown> ? Path extends `${number}.${infer Right}` ? Set<Source, Right, Value> : Path extends `${infer Left extends keyof Source}.${infer Right}` ? {
11
- [Key in keyof Source]: Key extends Exclude<keyof Source, Left> ? Source[Key] : Set<Exclude<Source[Left], undefined>, Right, Value>;
12
- } : Path extends keyof Source ? {
13
- [Key in keyof Source]: Key extends Exclude<keyof Source, Path> ? Source[Key] : Value;
14
- } : never : Source extends any[] ? Path extends `${infer Index extends number}.${infer Right}` ? Unshift<Source, Index, Set<Exclude<Source[Index], undefined>, Right, Value>> : Path extends `${infer Index extends number}` ? Unshift<Source, Index, Value> : never : never;
15
- /**
16
- * Sets the `value` inside a nested `source` object by provided `path`
17
- * written in dot-notation.
18
- */
19
- export default function set<Source extends Flattenable, Path extends Flatten<Source>, Value>(path: Path, value: Value): (source: Source) => Set<Source, Path, Value>;
20
- /**
21
- * Sets the `value` inside a nested `source` object by provided `path`
22
- * written in dot-notation.
23
- */
24
- export default function set<Source extends Flattenable, Path extends Flatten<Source>, Value>(source: Source, path: Path, value: Value): Set<Source, Path, Value>;
package/set.js DELETED
@@ -1,35 +0,0 @@
1
- /**
2
- * @module Set
3
- */
4
- import permutation3 from './permutation/permutation-3.js';
5
- /**
6
- * Sets the `value` inside a nested `source` object by provided `path`
7
- * written in dot-notation.
8
- */
9
- export default function set(...args) {
10
- // @ts-ignore
11
- return permutation3(
12
- // @ts-ignore
13
- (source, path, value
14
- // @ts-ignore
15
- ) => {
16
- // @ts-ignore
17
- const keys = path.split('.');
18
- const length = keys.length;
19
- let result = structuredClone(source);
20
- if (length === 0) {
21
- result[path] = value;
22
- }
23
- let scope = result[keys[0]];
24
- for (let index = 1; index < length; index += 1) {
25
- if (index === length - 1) {
26
- scope[keys?.[index]] = value;
27
- }
28
- else {
29
- scope = scope?.[keys?.[index]];
30
- }
31
- }
32
- // @ts-ignore
33
- return result;
34
- })(...args);
35
- }