@dynamic-labs/utils 1.2.0-alpha.0 → 2.0.0-alpha.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.
- package/CHANGELOG.md +21 -0
- package/package.json +3 -3
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +1 -0
- package/src/pipe/index.d.ts +1 -0
- package/src/pipe/pipe.cjs +39 -0
- package/src/pipe/pipe.d.ts +27 -0
- package/src/pipe/pipe.js +35 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.0.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.2.0-alpha.1...v2.0.0-alpha.0) (2024-02-12)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* use recommended wallets when using wallet list tabs ([#4662](https://github.com/dynamic-labs/DynamicAuth/issues/4662)) ([eae0318](https://github.com/dynamic-labs/DynamicAuth/commit/eae0318b30fa61d0b30f733ff0d632dfde132181))
|
|
8
|
+
|
|
9
|
+
## [1.2.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.2.0-alpha.0...v1.2.0-alpha.1) (2024-02-09)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add FilterChain helper function ([#4632](https://github.com/dynamic-labs/DynamicAuth/issues/4632)) ([56d474b](https://github.com/dynamic-labs/DynamicAuth/commit/56d474bf50a566774179ae929c4587ef841809bc))
|
|
15
|
+
* add recommendedWallets prop to DynamicContext ([10c79d2](https://github.com/dynamic-labs/DynamicAuth/commit/10c79d2d7d79b3acee52f2feac0ddb6ccb5d9465))
|
|
16
|
+
* allow exporting embedded wallets key/seed using email auth session ([#4580](https://github.com/dynamic-labs/DynamicAuth/issues/4580)) ([7b7a826](https://github.com/dynamic-labs/DynamicAuth/commit/7b7a8265ff16057284a50046f2310e1abdca5e50))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* fix the wallet list height ([#4651](https://github.com/dynamic-labs/DynamicAuth/issues/4651)) ([445be11](https://github.com/dynamic-labs/DynamicAuth/commit/445be110044aff2641cb2c8309c7b784d5498645))
|
|
22
|
+
|
|
2
23
|
## [1.2.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.26...v1.2.0-alpha.0) (2024-02-09)
|
|
3
24
|
|
|
4
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"tldts": "^6.0.16",
|
|
30
|
-
"@dynamic-labs/logger": "
|
|
31
|
-
"@dynamic-labs/types": "
|
|
30
|
+
"@dynamic-labs/logger": "2.0.0-alpha.0",
|
|
31
|
+
"@dynamic-labs/types": "2.0.0-alpha.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"viem": "^1.19.13 || ^2.2.0"
|
package/src/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ var DeferredPromise = require('./DeferredPromise/DeferredPromise.cjs');
|
|
|
38
38
|
var handleMobileWalletRedirect = require('./handleMobileWalletRedirect/handleMobileWalletRedirect.cjs');
|
|
39
39
|
var uniq = require('./uniq/uniq.cjs');
|
|
40
40
|
var getTLD = require('./getTLD/getTLD.cjs');
|
|
41
|
+
var pipe = require('./pipe/pipe.cjs');
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
|
|
@@ -91,3 +92,4 @@ exports.DeferredPromise = DeferredPromise.DeferredPromise;
|
|
|
91
92
|
exports.handleMobileWalletRedirect = handleMobileWalletRedirect.handleMobileWalletRedirect;
|
|
92
93
|
exports.uniq = uniq.uniq;
|
|
93
94
|
exports.getTLD = getTLD.getTLD;
|
|
95
|
+
exports.pipe = pipe.pipe;
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -34,3 +34,4 @@ export { DeferredPromise } from './DeferredPromise/DeferredPromise.js';
|
|
|
34
34
|
export { handleMobileWalletRedirect } from './handleMobileWalletRedirect/handleMobileWalletRedirect.js';
|
|
35
35
|
export { uniq } from './uniq/uniq.js';
|
|
36
36
|
export { getTLD } from './getTLD/getTLD.js';
|
|
37
|
+
export { pipe } from './pipe/pipe.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { pipe } from './pipe';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates a chainable function that allows adding additional transformations
|
|
7
|
+
* or operations via the `pipe` method, where each function in the chain
|
|
8
|
+
* can operate on the output type of the previous function.
|
|
9
|
+
* @param initialFunc The initial function to start the chain.
|
|
10
|
+
* @returns An object representing the chain of functions. The returned object
|
|
11
|
+
* has a `pipe` method to add more functions to the chain and can be invoked
|
|
12
|
+
* directly to execute the chain of functions with an input.
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* // Define a function that increments its input
|
|
16
|
+
* const increment = (x: number) => x + 1;
|
|
17
|
+
* // Create a function chain starting with the increment function
|
|
18
|
+
* const chain = createFnPipe(increment)
|
|
19
|
+
* .pipe(x => x * 2) // After incrementing, multiply the result by 2
|
|
20
|
+
* .pipe(x => `Result: ${x}`); // Then, convert the number to a string with a prefix
|
|
21
|
+
*
|
|
22
|
+
* console.log(chain(3)); // Output: "Result: 8"
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const pipe = (initialFunc) => {
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
const funcs = [initialFunc];
|
|
28
|
+
const executeFn = (input) => funcs.reduce((acc, func) => func(acc), input);
|
|
29
|
+
const pipe = (newFunc) => {
|
|
30
|
+
funcs.push(newFunc);
|
|
31
|
+
// The type assertion to Func<T, V> is necessary to align with the evolving return type.
|
|
32
|
+
return Object.assign((input) => executeFn(input), {
|
|
33
|
+
pipe,
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
return Object.assign(executeFn, { pipe });
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.pipe = pipe;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
type Func<T, U> = (input: T) => U;
|
|
2
|
+
/**
|
|
3
|
+
* Creates a chainable function that allows adding additional transformations
|
|
4
|
+
* or operations via the `pipe` method, where each function in the chain
|
|
5
|
+
* can operate on the output type of the previous function.
|
|
6
|
+
* @param initialFunc The initial function to start the chain.
|
|
7
|
+
* @returns An object representing the chain of functions. The returned object
|
|
8
|
+
* has a `pipe` method to add more functions to the chain and can be invoked
|
|
9
|
+
* directly to execute the chain of functions with an input.
|
|
10
|
+
* @example
|
|
11
|
+
* ```
|
|
12
|
+
* // Define a function that increments its input
|
|
13
|
+
* const increment = (x: number) => x + 1;
|
|
14
|
+
* // Create a function chain starting with the increment function
|
|
15
|
+
* const chain = createFnPipe(increment)
|
|
16
|
+
* .pipe(x => x * 2) // After incrementing, multiply the result by 2
|
|
17
|
+
* .pipe(x => `Result: ${x}`); // Then, convert the number to a string with a prefix
|
|
18
|
+
*
|
|
19
|
+
* console.log(chain(3)); // Output: "Result: 8"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare const pipe: <T, U>(initialFunc: Func<T, U>) => Func<T, U> & {
|
|
23
|
+
pipe: <V>(newFunc: Func<U, V>) => Func<T, V> & {
|
|
24
|
+
pipe: any;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export {};
|
package/src/pipe/pipe.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a chainable function that allows adding additional transformations
|
|
3
|
+
* or operations via the `pipe` method, where each function in the chain
|
|
4
|
+
* can operate on the output type of the previous function.
|
|
5
|
+
* @param initialFunc The initial function to start the chain.
|
|
6
|
+
* @returns An object representing the chain of functions. The returned object
|
|
7
|
+
* has a `pipe` method to add more functions to the chain and can be invoked
|
|
8
|
+
* directly to execute the chain of functions with an input.
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* // Define a function that increments its input
|
|
12
|
+
* const increment = (x: number) => x + 1;
|
|
13
|
+
* // Create a function chain starting with the increment function
|
|
14
|
+
* const chain = createFnPipe(increment)
|
|
15
|
+
* .pipe(x => x * 2) // After incrementing, multiply the result by 2
|
|
16
|
+
* .pipe(x => `Result: ${x}`); // Then, convert the number to a string with a prefix
|
|
17
|
+
*
|
|
18
|
+
* console.log(chain(3)); // Output: "Result: 8"
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
const pipe = (initialFunc) => {
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
const funcs = [initialFunc];
|
|
24
|
+
const executeFn = (input) => funcs.reduce((acc, func) => func(acc), input);
|
|
25
|
+
const pipe = (newFunc) => {
|
|
26
|
+
funcs.push(newFunc);
|
|
27
|
+
// The type assertion to Func<T, V> is necessary to align with the evolving return type.
|
|
28
|
+
return Object.assign((input) => executeFn(input), {
|
|
29
|
+
pipe,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
return Object.assign(executeFn, { pipe });
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { pipe };
|