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 +4 -4
- package/either/index.d.ts +1 -0
- package/either/index.js +1 -0
- package/lens/lens.js +1 -0
- package/lens/set.js +5 -4
- package/maybe/index.d.ts +1 -0
- package/maybe/index.js +1 -0
- package/package.json +21 -9
- package/permutation/permutation-2.js +1 -1
- package/permutation/permutation-3.js +1 -1
- package/tsconfig.json +2 -1
- package/set.d.ts +0 -24
- package/set.js +0 -35
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://
|
|
11
|
-
<img src="https://img.shields.io/
|
|
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
package/either/index.js
CHANGED
package/lens/lens.js
CHANGED
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) =>
|
|
12
|
+
return (path, value) => setter(args[0], path, value);
|
|
13
13
|
}
|
|
14
14
|
case 2: {
|
|
15
15
|
// @ts-ignore
|
|
16
|
-
return (source) =>
|
|
16
|
+
return (source) => setter(source, args[0], args[1]);
|
|
17
17
|
}
|
|
18
18
|
case 3: {
|
|
19
|
-
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
return setter(...args);
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
+
function setter(source, path, value
|
|
24
25
|
// @ts-ignore
|
|
25
26
|
) {
|
|
26
27
|
// @ts-ignore
|
package/maybe/index.d.ts
CHANGED
package/maybe/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fnts",
|
|
3
|
-
"version": "3.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)
|
|
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)
|
|
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
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
|
-
}
|