@oscarpalmer/atoms 0.184.0 → 0.184.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/dist/index.d.mts
CHANGED
|
@@ -3392,8 +3392,8 @@ type Frozen<Value extends ArrayOrPlainObject> = { readonly [Key in keyof Value]:
|
|
|
3392
3392
|
*/
|
|
3393
3393
|
declare function freeze<Item>(array: Item[]): Frozen<Item[]>;
|
|
3394
3394
|
/**
|
|
3395
|
-
* Freeze a
|
|
3396
|
-
* @param
|
|
3395
|
+
* Freeze a function
|
|
3396
|
+
* @param fn Function to freeze
|
|
3397
3397
|
* @returns Frozen function
|
|
3398
3398
|
*/
|
|
3399
3399
|
declare function freeze<Fn extends GenericCallback>(fn: Fn): Readonly<Fn>;
|
|
@@ -4577,13 +4577,13 @@ declare function resultPromises<Value>(items: Promise<Value>[], signal?: AbortSi
|
|
|
4577
4577
|
* @param result Result to check
|
|
4578
4578
|
* @returns `true` if the result is an extended error, `false` otherwise
|
|
4579
4579
|
*/
|
|
4580
|
-
declare function isError<Value, E = Error>(
|
|
4580
|
+
declare function isError<Value, E = Error>(result: ExtendedErr<E> | Result<Value, E>, extended: true): result is ExtendedErr<E>;
|
|
4581
4581
|
/**
|
|
4582
4582
|
* Is the result an error?
|
|
4583
4583
|
* @param result Result to check
|
|
4584
4584
|
* @returns `true` if the result is an error, `false` otherwise
|
|
4585
4585
|
*/
|
|
4586
|
-
declare function isError<Value, E = Error>(
|
|
4586
|
+
declare function isError<Value, E = Error>(result: Result<Value, E>): result is Err<E>;
|
|
4587
4587
|
/**
|
|
4588
4588
|
* Is the value an error?
|
|
4589
4589
|
* @param value Value to check
|
|
@@ -6,13 +6,13 @@ import { Err, ExtendedErr, Ok, Result } from "../result/models.mjs";
|
|
|
6
6
|
* @param result Result to check
|
|
7
7
|
* @returns `true` if the result is an extended error, `false` otherwise
|
|
8
8
|
*/
|
|
9
|
-
declare function isError<Value, E = Error>(
|
|
9
|
+
declare function isError<Value, E = Error>(result: ExtendedErr<E> | Result<Value, E>, extended: true): result is ExtendedErr<E>;
|
|
10
10
|
/**
|
|
11
11
|
* Is the result an error?
|
|
12
12
|
* @param result Result to check
|
|
13
13
|
* @returns `true` if the result is an error, `false` otherwise
|
|
14
14
|
*/
|
|
15
|
-
declare function isError<Value, E = Error>(
|
|
15
|
+
declare function isError<Value, E = Error>(result: Result<Value, E>): result is Err<E>;
|
|
16
16
|
/**
|
|
17
17
|
* Is the value an error?
|
|
18
18
|
* @param value Value to check
|
package/dist/value/freeze.d.mts
CHANGED
|
@@ -12,8 +12,8 @@ type Frozen<Value extends ArrayOrPlainObject> = { readonly [Key in keyof Value]:
|
|
|
12
12
|
*/
|
|
13
13
|
declare function freeze<Item>(array: Item[]): Frozen<Item[]>;
|
|
14
14
|
/**
|
|
15
|
-
* Freeze a
|
|
16
|
-
* @param
|
|
15
|
+
* Freeze a function
|
|
16
|
+
* @param fn Function to freeze
|
|
17
17
|
* @returns Frozen function
|
|
18
18
|
*/
|
|
19
19
|
declare function freeze<Fn extends GenericCallback>(fn: Fn): Readonly<Fn>;
|
package/package.json
CHANGED
package/src/internal/result.ts
CHANGED
|
@@ -20,16 +20,16 @@ function _isResult(value: unknown, okValue: boolean): value is Result<unknown, u
|
|
|
20
20
|
* @returns `true` if the result is an extended error, `false` otherwise
|
|
21
21
|
*/
|
|
22
22
|
export function isError<Value, E = Error>(
|
|
23
|
-
|
|
23
|
+
result: ExtendedErr<E> | Result<Value, E>,
|
|
24
24
|
extended: true,
|
|
25
|
-
):
|
|
25
|
+
): result is ExtendedErr<E>;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Is the result an error?
|
|
29
29
|
* @param result Result to check
|
|
30
30
|
* @returns `true` if the result is an error, `false` otherwise
|
|
31
31
|
*/
|
|
32
|
-
export function isError<Value, E = Error>(
|
|
32
|
+
export function isError<Value, E = Error>(result: Result<Value, E>): result is Err<E>;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Is the value an error?
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {NestedKeys, NestedValue, PlainObject, ToString} from '../../models';
|
|
2
|
+
import type {Ok} from '../../result/models';
|
|
2
3
|
import {getNestedValue} from './misc';
|
|
3
4
|
|
|
4
5
|
// #region Functions
|
|
@@ -28,7 +29,7 @@ export function getValue<Data extends PlainObject>(
|
|
|
28
29
|
): unknown;
|
|
29
30
|
|
|
30
31
|
export function getValue(data: PlainObject, path: string, ignoreCase?: boolean): unknown {
|
|
31
|
-
return getNestedValue(data, path, ignoreCase === true).value;
|
|
32
|
+
return (getNestedValue(data, path, ignoreCase === true) as Ok<unknown>).value;
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
// #endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {NestedKeys, NestedValue, PlainObject} from '../../models';
|
|
2
|
+
import type {Ok} from '../../result/models';
|
|
2
3
|
import {getPaths, handleValue} from './misc';
|
|
3
4
|
|
|
4
5
|
// #region Functions
|
|
@@ -77,7 +78,8 @@ export function setValue(data: object, path: string, value: unknown, ignoreCase?
|
|
|
77
78
|
break;
|
|
78
79
|
}
|
|
79
80
|
|
|
80
|
-
let next = handleValue(target, currentPath, null, true, shouldIgnoreCase)
|
|
81
|
+
let next = (handleValue(target, currentPath, null, true, shouldIgnoreCase) as Ok<unknown>)
|
|
82
|
+
.value;
|
|
81
83
|
|
|
82
84
|
if (typeof next !== 'object' || next === null) {
|
|
83
85
|
const nextPath = paths[index + 1];
|
package/src/value/freeze.ts
CHANGED
|
@@ -24,8 +24,8 @@ export type Frozen<Value extends ArrayOrPlainObject> = {
|
|
|
24
24
|
export function freeze<Item>(array: Item[]): Frozen<Item[]>;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
* Freeze a
|
|
28
|
-
* @param
|
|
27
|
+
* Freeze a function
|
|
28
|
+
* @param fn Function to freeze
|
|
29
29
|
* @returns Frozen function
|
|
30
30
|
*/
|
|
31
31
|
export function freeze<Fn extends GenericCallback>(fn: Fn): Readonly<Fn>;
|