@solana/functional
Advanced tools
Comparing version 2.0.0-experimental.73d8f64 to 2.0.0-experimental.745437f
{ | ||
"name": "@solana/functional", | ||
"version": "2.0.0-experimental.73d8f64", | ||
"version": "2.0.0-experimental.745437f", | ||
"description": "Functional JavaScript helpers", | ||
@@ -50,4 +50,4 @@ "exports": { | ||
"@solana/eslint-config-solana": "^1.0.2", | ||
"@swc/jest": "^0.2.28", | ||
"@types/jest": "^29.5.5", | ||
"@swc/jest": "^0.2.29", | ||
"@types/jest": "^29.5.6", | ||
"@typescript-eslint/eslint-plugin": "^6.3.0", | ||
@@ -59,6 +59,6 @@ "@typescript-eslint/parser": "^6.3.0", | ||
"jest": "^29.7.0", | ||
"jest-runner-eslint": "^2.1.0", | ||
"jest-runner-eslint": "^2.1.2", | ||
"jest-runner-prettier": "^1.0.0", | ||
"prettier": "^2.8", | ||
"tsup": "7.2.0", | ||
"prettier": "^3.1", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.2.2", | ||
@@ -84,8 +84,8 @@ "version-from-git": "^1.1.1", | ||
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/*", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json", | ||
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent", | ||
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent", | ||
"test:treeshakability:browser": "agadoo dist/index.browser.js", | ||
"test:treeshakability:native": "agadoo dist/index.node.js", | ||
"test:treeshakability:node": "agadoo dist/index.native.js", | ||
"test:treeshakability:native": "agadoo dist/index.native.js", | ||
"test:treeshakability:node": "agadoo dist/index.node.js", | ||
"test:typecheck": "tsc --noEmit", | ||
@@ -92,0 +92,0 @@ "test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent", |
@@ -24,2 +24,27 @@ [![npm][npm-image]][npm-url] | ||
`pipe`: A functional utility function for piping a value through various functions | ||
### `pipe()` | ||
Until the [pipe operator](https://github.com/tc39/proposal-pipeline-operator) becomes part of JavaScript you can use this utility to create pipelines. | ||
```ts | ||
const add = (a, b) => a + b; | ||
const add10 = x => add(x, 10); | ||
const add100 = x => add(x, 100); | ||
const sum = pipe(1, add10, add100); | ||
sum === 111; // true | ||
``` | ||
A pipeline is one solution to performing consecutive operations on a value using functions, such as you would when building a transaction. | ||
```ts | ||
const transferTransaction = pipe( | ||
// The result of the first expression... | ||
createTransaction({ version: 0 }), | ||
// ...gets passed as the sole argument to the next function in the pipeline. | ||
tx => setTransactionFeePayer(myAddress, tx), | ||
// The return value of that function gets passed to the next... | ||
tx => setTransactionLifetimeUsingBlockhash(latestBlockhash, tx), | ||
// ...and so on. | ||
tx => appendTransactionInstruction(createTransferInstruction(myAddress, toAddress, amountInLamports), tx) | ||
); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37327
50