@solana/functional 2.0.0-experimental.fc4e943 → 2.0.0-experimental.fe07532
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 +26 -1
- package/dist/index.node.js +0 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -21,4 +21,29 @@ is also exported as part of the Solana JavaScript SDK
|
|
|
21
21
|
|
|
22
22
|
## Functions
|
|
23
23
|
|
|
24
|
-
`pipe
|
|
24
|
+
### `pipe()`
|
|
25
|
+
|
|
26
|
+
Until the [pipe operator](https://github.com/tc39/proposal-pipeline-operator) becomes part of JavaScript you can use this utility to create pipelines.
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
const add = (a, b) => a + b;
|
|
30
|
+
const add10 = x => add(x, 10);
|
|
31
|
+
const add100 = x => add(x, 100);
|
|
32
|
+
const sum = pipe(1, add10, add100);
|
|
33
|
+
sum === 111; // true
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
A pipeline is one solution to performing consecutive operations on a value using functions, such as you would when building a transaction.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const transferTransaction = pipe(
|
|
40
|
+
// The result of the first expression...
|
|
41
|
+
createTransaction({ version: 0 }),
|
|
42
|
+
// ...gets passed as the sole argument to the next function in the pipeline.
|
|
43
|
+
tx => setTransactionFeePayer(myAddress, tx),
|
|
44
|
+
// The return value of that function gets passed to the next...
|
|
45
|
+
tx => setTransactionLifetimeUsingBlockhash(latestBlockhash, tx),
|
|
46
|
+
// ...and so on.
|
|
47
|
+
tx => appendTransactionInstruction(createTransferInstruction(myAddress, toAddress, amountInLamports), tx)
|
|
48
|
+
);
|
|
49
|
+
```
|
package/dist/index.node.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/functional",
|
|
3
|
-
"version": "2.0.0-experimental.
|
|
3
|
+
"version": "2.0.0-experimental.fe07532",
|
|
4
4
|
"description": "Functional JavaScript helpers",
|
|
5
5
|
"exports": {
|
|
6
6
|
"browser": {
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
],
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@solana/eslint-config-solana": "^1.0.2",
|
|
50
|
-
"@swc/jest": "^0.2.
|
|
51
|
-
"@types/jest": "^29.5.
|
|
50
|
+
"@swc/jest": "^0.2.29",
|
|
51
|
+
"@types/jest": "^29.5.6",
|
|
52
52
|
"@typescript-eslint/eslint-plugin": "^6.3.0",
|
|
53
53
|
"@typescript-eslint/parser": "^6.3.0",
|
|
54
54
|
"agadoo": "^3.0.0",
|
|
55
55
|
"eslint": "^8.45.0",
|
|
56
56
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
57
57
|
"jest": "^29.7.0",
|
|
58
|
-
"jest-runner-eslint": "^2.1.
|
|
58
|
+
"jest-runner-eslint": "^2.1.2",
|
|
59
59
|
"jest-runner-prettier": "^1.0.0",
|
|
60
60
|
"prettier": "^2.8",
|
|
61
61
|
"tsup": "7.2.0",
|