@kaumlaut/pure 0.4.0 → 0.5.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.
Files changed (44) hide show
  1. package/README.md +1 -3
  2. package/dist/clone/index.d.ts +10 -0
  3. package/dist/clone/index.d.ts.map +1 -1
  4. package/dist/clone/index.js +7 -0
  5. package/dist/fetch-state/index.d.ts +48 -0
  6. package/dist/fetch-state/index.d.ts.map +1 -1
  7. package/dist/fetch-state/index.js +29 -0
  8. package/dist/guard/index.d.ts +79 -0
  9. package/dist/guard/index.d.ts.map +1 -1
  10. package/dist/guard/index.js +86 -0
  11. package/dist/maybe/index.d.ts +53 -1
  12. package/dist/maybe/index.d.ts.map +1 -1
  13. package/dist/maybe/index.js +71 -0
  14. package/dist/parse/index.d.ts +6 -0
  15. package/dist/parse/index.d.ts.map +1 -1
  16. package/dist/parse/index.js +6 -0
  17. package/dist/pipe/index.d.ts +15 -2
  18. package/dist/pipe/index.d.ts.map +1 -1
  19. package/dist/pipe/index.js +11 -0
  20. package/dist/result/index.d.ts +40 -1
  21. package/dist/result/index.d.ts.map +1 -1
  22. package/dist/result/index.js +30 -0
  23. package/dist/runtime/effect/fetch/index.d.ts +3 -4
  24. package/dist/runtime/effect/fetch/index.d.ts.map +1 -1
  25. package/dist/util/index.d.ts +3 -0
  26. package/dist/util/index.d.ts.map +1 -1
  27. package/dist/util/index.js +3 -0
  28. package/docs/README.md +23 -0
  29. package/docs/clone.md +45 -0
  30. package/docs/fetch-state.md +345 -0
  31. package/docs/guard.md +729 -0
  32. package/docs/maybe.md +481 -0
  33. package/docs/parse.md +47 -0
  34. package/docs/pipe.md +95 -0
  35. package/docs/result.md +363 -0
  36. package/docs/runtime/effect/fetch.md +169 -0
  37. package/docs/runtime/effect/none.md +19 -0
  38. package/docs/runtime/effect.md +179 -0
  39. package/docs/runtime/persistence/none.md +29 -0
  40. package/docs/runtime/persistence/storage.md +39 -0
  41. package/docs/runtime/persistence.md +63 -0
  42. package/docs/runtime.md +167 -0
  43. package/docs/util.md +33 -0
  44. package/package.json +9 -7
@@ -1,25 +1,47 @@
1
+ /**
2
+ * Provides types representing the Maybe concept as well as functions to work with it.
3
+ * @module maybe
4
+ */
1
5
  import { err, ok } from "@kaumlaut/pure/result";
6
+ /**
7
+ * Creates a maybe not containing a value. (Nothing)
8
+ */
2
9
  export function nothing() {
3
10
  return {
4
11
  type: "maybe-nothing",
5
12
  };
6
13
  }
14
+ /**
15
+ * Creates a maybe containing a value. (Just)
16
+ */
7
17
  export function just(value) {
8
18
  return {
9
19
  type: "maybe-just",
10
20
  value,
11
21
  };
12
22
  }
23
+ /**
24
+ * A Guard confirming that the given maybe value is a Nothing.
25
+ */
13
26
  export function isNothing(maybe) {
14
27
  return maybe.type === "maybe-nothing";
15
28
  }
29
+ /**
30
+ * A Guard confirming that the given maybe value is a Just.
31
+ */
16
32
  export function isJust(maybe) {
17
33
  return maybe.type === "maybe-just";
18
34
  }
35
+ /**
36
+ * A Guard confirming that the given value is a Maybe.
37
+ */
19
38
  export function isMaybe(value) {
20
39
  //@ts-expect-error is validated
21
40
  return value.type === "maybe-just" || value.type === "maybe-nothing";
22
41
  }
42
+ /**
43
+ * Applies the func function to the value if the given Maybe is a Just and returns it wrapped in a Just. Otherwise returns the given Maybe.
44
+ */
23
45
  export function map(func) {
24
46
  return (maybe) => {
25
47
  if (isJust(maybe)) {
@@ -28,6 +50,9 @@ export function map(func) {
28
50
  return maybe;
29
51
  };
30
52
  }
53
+ /**
54
+ * Converts the given Maybe into a Nothing if it is Just but does not pass the given function.
55
+ */
31
56
  export function filter(func) {
32
57
  return (maybe) => {
33
58
  if (!isJust(maybe)) {
@@ -39,6 +64,9 @@ export function filter(func) {
39
64
  return nothing();
40
65
  };
41
66
  }
67
+ /**
68
+ * Unwraps a Maybe, returning the value if it is a Just or the default value if it is a Nothing.
69
+ */
42
70
  export function withDefault(defaultValue) {
43
71
  return (maybe) => {
44
72
  if (isJust(maybe)) {
@@ -47,6 +75,49 @@ export function withDefault(defaultValue) {
47
75
  return defaultValue;
48
76
  };
49
77
  }
78
+ /**
79
+ * Converts the given Maybe to a Result.
80
+ * A Nothing becomes an Err with the given error.
81
+ * A Just becomes an Ok with the contained value.
82
+ */
50
83
  export function toResult(error) {
51
84
  return (maybe) => (isJust(maybe) ? ok(maybe.value) : err(error));
52
85
  }
86
+ /**
87
+ * Creates a Just if the Guard passes for the given value. Otherwise Creates a Nothing.
88
+ */
89
+ export function maybeByGuard(guard) {
90
+ return (value) => {
91
+ return guard(value) ? just(value) : nothing();
92
+ };
93
+ }
94
+ /**
95
+ * Maps the a value contained within a Just using the given function without wrapping it in another Just.
96
+ * Returns the given Maybe if it is a Nothing.
97
+ */
98
+ export function mapToMaybe(func) {
99
+ return (maybe) => {
100
+ if (isJust(maybe)) {
101
+ return func(maybe.value);
102
+ }
103
+ return maybe;
104
+ };
105
+ }
106
+ /**
107
+ * Maps the a value contained within a Just using the given function without wrapping it in another Just.
108
+ * Returns the given Maybe if it is a Nothing.
109
+ */
110
+ export function tryMap(func) {
111
+ return (maybe) => {
112
+ if (isJust(maybe)) {
113
+ try {
114
+ return just(func(maybe.value));
115
+ }
116
+ catch (e) {
117
+ console.error(e);
118
+ return nothing();
119
+ }
120
+ }
121
+ return maybe;
122
+ };
123
+ }
@@ -1,4 +1,10 @@
1
1
  import { type Result } from "@kaumlaut/pure/result";
2
+ /**
3
+ * Attempts to parse a string as an interger. Returning ok if successful or err if not.
4
+ */
2
5
  export declare function asInt(value: string): Result<number, string>;
6
+ /**
7
+ * Attempts to parse a string as an float. Returning ok if successful or err if not.
8
+ */
3
9
  export declare function asFloat(value: string): Result<number, string>;
4
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE7D,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ3D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ7D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ3D;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ7D"}
@@ -1,4 +1,7 @@
1
1
  import { err, ok } from "@kaumlaut/pure/result";
2
+ /**
3
+ * Attempts to parse a string as an interger. Returning ok if successful or err if not.
4
+ */
2
5
  export function asInt(value) {
3
6
  const parsed = parseInt(value, 10);
4
7
  if (Number.isNaN(parsed)) {
@@ -6,6 +9,9 @@ export function asInt(value) {
6
9
  }
7
10
  return ok(parsed);
8
11
  }
12
+ /**
13
+ * Attempts to parse a string as an float. Returning ok if successful or err if not.
14
+ */
9
15
  export function asFloat(value) {
10
16
  const parsed = parseFloat(value);
11
17
  if (Number.isNaN(parsed)) {
@@ -1,7 +1,20 @@
1
- type Pipe<IT> = {
1
+ /**
2
+ * Represents a function pipeline
3
+ */
4
+ export type Pipe<IT> = {
2
5
  into: <RT>(func: (input: IT) => RT) => Pipe<RT>;
3
6
  out: () => IT;
4
7
  };
8
+ /**
9
+ * Creates a Pipe that allows you to chain multiple functions using into.
10
+ * Is meant to make larger functions more readable.
11
+ * @example
12
+ * const output = put("3")
13
+ .into(asInt)
14
+ .into(toMaybe)
15
+ .into(withDefault(0))
16
+ .into((input) => input * 3.14)
17
+ .into((input) => input.toPrecision());
18
+ */
5
19
  export declare function put<IT>(data: IT): Pipe<IT>;
6
- export {};
7
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipe/index.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,CAAC,EAAE,IAAI;IACd,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;IAChD,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF,wBAAgB,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAO1C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipe/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,IAAI,CAAC,EAAE,IAAI;IACrB,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC;IAChD,GAAG,EAAE,MAAM,EAAE,CAAC;CACf,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAO1C"}
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Creates a Pipe that allows you to chain multiple functions using into.
3
+ * Is meant to make larger functions more readable.
4
+ * @example
5
+ * const output = put("3")
6
+ .into(asInt)
7
+ .into(toMaybe)
8
+ .into(withDefault(0))
9
+ .into((input) => input * 3.14)
10
+ .into((input) => input.toPrecision());
11
+ */
1
12
  export function put(data) {
2
13
  return {
3
14
  into: (func) => {
@@ -1,19 +1,58 @@
1
1
  import { Maybe } from "@kaumlaut/pure/maybe";
2
+ /**
3
+ * Represents the Result of an action that succeeded and contains a corresponding value.
4
+ */
2
5
  export type Ok<T> = {
3
6
  type: "ok-result";
4
7
  value: T;
5
8
  };
9
+ /**
10
+ * Represents the Result of an action that failed and contains a corresponding error.
11
+ */
6
12
  export type Err<T> = {
7
13
  type: "error-result";
8
14
  error: T;
9
15
  };
16
+ /**
17
+ * Represents the Result of an action that can fail.
18
+ */
19
+ export type Result<T, E> = Ok<T> | Err<E>;
20
+ /**
21
+ * A Guard conforming that the given Result is of type Ok.
22
+ */
10
23
  export declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
24
+ /**
25
+ * A Guard conforming that the given Result is of type Err.
26
+ */
11
27
  export declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
28
+ /**
29
+ * Creates a Result of type Ok containg the given value.
30
+ */
12
31
  export declare function ok<T>(value: T): Ok<T>;
32
+ /**
33
+ * Creates a Result of type Err containg the given error.
34
+ */
13
35
  export declare function err<E>(error: E): Err<E>;
14
- export type Result<T, E> = Ok<T> | Err<E>;
36
+ /**
37
+ * When Result is Ok: Applies the func function to the contained value and wraps it in Ok again.
38
+ * When Result is Err: Returns the given Result.
39
+ */
15
40
  export declare function map<T, E, R>(func: (value: T) => R): (result: Result<T, E>) => Result<R, E>;
41
+ /**
42
+ * When Result is Ok: Returns the given Result.
43
+ * When Result is Err: Applies the func function to the contained error and wraps it in Err again.
44
+ */
16
45
  export declare function mapErr<T, E, R>(func: (value: E) => R): (result: Result<T, E>) => Result<T, R>;
46
+ /**
47
+ * Unwrap a result to either its contained value or the default value.
48
+ * When Result is Ok: Returns the nested value.
49
+ * When Result is Err: Returns the given default value.
50
+ */
17
51
  export declare function withDefault<T, E>(defaultValue: T): (result: Result<T, E>) => T;
52
+ /**
53
+ * Converts the given Result to a Maybe
54
+ * When Result is Ok: Returns a Just containing the value.
55
+ * When Result is Err: Returns a Nothing.
56
+ */
18
57
  export declare function toMaybe<T, E>(result: Result<T, E>): Maybe<T>;
19
58
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index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;AAED;;GAEG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAKrC;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAKvC;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACzB,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GACpB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAQxC;AAGD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC5B,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GACpB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAQxC;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,YAAY,EAAE,CAAC,GACd,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAQ7B;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAE5D"}
@@ -1,22 +1,38 @@
1
1
  import { just, nothing } from "@kaumlaut/pure/maybe";
2
+ /**
3
+ * A Guard conforming that the given Result is of type Ok.
4
+ */
2
5
  export function isOk(result) {
3
6
  return result.type === "ok-result";
4
7
  }
8
+ /**
9
+ * A Guard conforming that the given Result is of type Err.
10
+ */
5
11
  export function isErr(result) {
6
12
  return result.type === "error-result";
7
13
  }
14
+ /**
15
+ * Creates a Result of type Ok containg the given value.
16
+ */
8
17
  export function ok(value) {
9
18
  return {
10
19
  type: "ok-result",
11
20
  value,
12
21
  };
13
22
  }
23
+ /**
24
+ * Creates a Result of type Err containg the given error.
25
+ */
14
26
  export function err(error) {
15
27
  return {
16
28
  type: "error-result",
17
29
  error,
18
30
  };
19
31
  }
32
+ /**
33
+ * When Result is Ok: Applies the func function to the contained value and wraps it in Ok again.
34
+ * When Result is Err: Returns the given Result.
35
+ */
20
36
  export function map(func) {
21
37
  return (result) => {
22
38
  if (isOk(result)) {
@@ -25,6 +41,10 @@ export function map(func) {
25
41
  return result;
26
42
  };
27
43
  }
44
+ /**
45
+ * When Result is Ok: Returns the given Result.
46
+ * When Result is Err: Applies the func function to the contained error and wraps it in Err again.
47
+ */
28
48
  export function mapErr(func) {
29
49
  return (result) => {
30
50
  if (isErr(result)) {
@@ -33,6 +53,11 @@ export function mapErr(func) {
33
53
  return result;
34
54
  };
35
55
  }
56
+ /**
57
+ * Unwrap a result to either its contained value or the default value.
58
+ * When Result is Ok: Returns the nested value.
59
+ * When Result is Err: Returns the given default value.
60
+ */
36
61
  export function withDefault(defaultValue) {
37
62
  return (result) => {
38
63
  if (isErr(result)) {
@@ -41,6 +66,11 @@ export function withDefault(defaultValue) {
41
66
  return result.value;
42
67
  };
43
68
  }
69
+ /**
70
+ * Converts the given Result to a Maybe
71
+ * When Result is Ok: Returns a Just containing the value.
72
+ * When Result is Err: Returns a Nothing.
73
+ */
44
74
  export function toMaybe(result) {
45
75
  return isOk(result) ? just(result.value) : nothing();
46
76
  }
@@ -1,18 +1,17 @@
1
1
  import { Guard } from "@kaumlaut/pure/guard";
2
2
  import { ReceiveEffectResult, Effect } from "@kaumlaut/pure/runtime/effect";
3
3
  import { Message } from "@kaumlaut/pure/runtime";
4
- type HttpError = {
4
+ export type HttpError = {
5
5
  code: number;
6
6
  message: string;
7
7
  };
8
- type MalformedPayloadError = {
8
+ export type MalformedPayloadError = {
9
9
  message: string;
10
10
  };
11
- type FetchError = HttpError | MalformedPayloadError;
11
+ export type FetchError = HttpError | MalformedPayloadError;
12
12
  export declare function isNotFound(error: FetchError): boolean;
13
13
  export declare function isHttp(error: FetchError): error is HttpError;
14
14
  export declare function isClient(error: FetchError): boolean;
15
15
  export declare function isServer(error: FetchError): boolean;
16
16
  export declare function fetchJson<T, M extends Message>(url: string, headers: [string, string][], method: string, guard: Guard<T>, receiver: ReceiveEffectResult<T, FetchError, M>): Effect<M>;
17
- export {};
18
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/runtime/effect/fetch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EACL,mBAAmB,EACnB,MAAM,EAEP,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,UAAU,GAAG,SAAS,GAAG,qBAAqB,CAAC;AAEpD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAErD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,IAAI,SAAS,CAK5D;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEnD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEnD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,SAAS,OAAO,EAC5C,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,EAC3B,MAAM,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5 @@
1
+ /**
2
+ * Returns the given value.
3
+ */
1
4
  export declare function id<T>(value: T): T;
2
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEjC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEjC"}
@@ -1,3 +1,6 @@
1
+ /**
2
+ * Returns the given value.
3
+ */
1
4
  export function id(value) {
2
5
  return value;
3
6
  }
package/docs/README.md ADDED
@@ -0,0 +1,23 @@
1
+ **@kaumlaut/pure v0.5.1**
2
+
3
+ ***
4
+
5
+ # @kaumlaut/pure v0.5.1
6
+
7
+ ## Modules
8
+
9
+ - [clone](clone.md)
10
+ - [fetch-state](fetch-state.md)
11
+ - [guard](guard.md)
12
+ - [maybe](maybe.md)
13
+ - [parse](parse.md)
14
+ - [pipe](pipe.md)
15
+ - [result](result.md)
16
+ - [runtime](runtime.md)
17
+ - [runtime/effect](runtime/effect.md)
18
+ - [runtime/effect/fetch](runtime/effect/fetch.md)
19
+ - [runtime/effect/none](runtime/effect/none.md)
20
+ - [runtime/persistence](runtime/persistence.md)
21
+ - [runtime/persistence/none](runtime/persistence/none.md)
22
+ - [runtime/persistence/storage](runtime/persistence/storage.md)
23
+ - [util](util.md)
package/docs/clone.md ADDED
@@ -0,0 +1,45 @@
1
+ [**@kaumlaut/pure v0.5.1**](README.md)
2
+
3
+ ***
4
+
5
+ [@kaumlaut/pure](README.md) / clone
6
+
7
+ # clone
8
+
9
+ Provides value cloning capabilities
10
+
11
+ ## Type Aliases
12
+
13
+ ### Cloneable
14
+
15
+ > **Cloneable** = `string` \| `number` \| `boolean` \| `null` \| [`Cloneable`](#cloneable)[] \| \{\[`key`: `string`\]: [`Cloneable`](#cloneable); \}
16
+
17
+ Defined in: [clone/index.ts:9](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/clone/index.ts#L9)
18
+
19
+ Defines the Cloneable type
20
+
21
+ ## Functions
22
+
23
+ ### clone()
24
+
25
+ > **clone**\<`T`\>(`value`): `T`
26
+
27
+ Defined in: [clone/index.ts:20](https://github.com/maxkaemmerer/pure-vue-poc/blob/af231e8df53d90d5cfaa5229a0611bf6aa308ef2/pure/src/clone/index.ts#L20)
28
+
29
+ Recursively clones values to prevent changing of the original value.
30
+
31
+ #### Type Parameters
32
+
33
+ ##### T
34
+
35
+ `T` *extends* [`Cloneable`](#cloneable)
36
+
37
+ #### Parameters
38
+
39
+ ##### value
40
+
41
+ `T`
42
+
43
+ #### Returns
44
+
45
+ `T`