Update for v12
parent
f39520fdf0
commit
ae7f998392
30
Node-API.md
30
Node-API.md
@ -346,38 +346,38 @@ chef.help("toBase32") // OK
|
||||
If there is more than one match for the given search term, `help` will return multiple matches. It searches in the operation name and the description field, prioritising matches in the operation name.
|
||||
|
||||
#### `bake`
|
||||
`bake` is useful for building "recipes" - chains of operations to apply to some input, in order. `bake` accepts operations in multiple ways. It always returns a `Dish` object.
|
||||
`bake` is useful for building "recipes" - chains of operations to apply to some input, in order. `bake` accepts operations in multiple ways. It always returns a `Dish` object. `bake` is async, so should normally be called inside an `await` call.
|
||||
|
||||
One operation, no arguments
|
||||
```javascript
|
||||
chef.bake("I'll have the cod.", chef.toBase64);
|
||||
await(chef.bake("I'll have the cod.", chef.toBase64));
|
||||
// => SSdsbCBoYXZlIHRoZSBjb2Qu
|
||||
```
|
||||
One operation by name
|
||||
```javascript
|
||||
chef.bake("I'll have the cod.", "to base 64");
|
||||
await(chef.bake("I'll have the cod.", "to base 64"));
|
||||
// => SSdsbCBoYXZlIHRoZSBjb2Qu
|
||||
```
|
||||
Multiple operations, by name or by function (default arguments)
|
||||
```javascript
|
||||
chef.bake("I'll have the cod", [chef.toBase64, "sha1"]);
|
||||
await(chef.bake("I'll have the cod", [chef.toBase64, "sha1"]));
|
||||
// => f20135964d60f5fb66f971f5ee33d8395d1f90bf
|
||||
```
|
||||
|
||||
One operation, with custom arguments
|
||||
```javascript
|
||||
chef.bake("I'll have the salmon.", {
|
||||
await(chef.bake("I'll have the salmon.", {
|
||||
op: chef.toBase64,
|
||||
args: {
|
||||
alphabet: "A-Z",
|
||||
},
|
||||
});
|
||||
}));
|
||||
// => SSCBYXZIHRZSBYW
|
||||
```
|
||||
|
||||
Multiple operations with custom arguments
|
||||
```javascript
|
||||
chef.bake("I'll have the salmon.", [
|
||||
await(chef.bake("I'll have the salmon.", [
|
||||
{
|
||||
op: chef.toBase64,
|
||||
args: {
|
||||
@ -391,7 +391,7 @@ chef.bake("I'll have the salmon.", [
|
||||
reverse: true,
|
||||
}
|
||||
}
|
||||
]);
|
||||
]));
|
||||
// => ZZYYXWSSSRIHCBB
|
||||
```
|
||||
|
||||
@ -407,7 +407,7 @@ const recipe = [
|
||||
"args": ["Nothing (separate chars)", true, "Alphabetical (case sensitive)"] }
|
||||
];
|
||||
|
||||
chef.bake("I'll have the salmon.", recipe);
|
||||
await(chef.bake("I'll have the salmon.", recipe));
|
||||
// => ZZYYXWSSSRIHCBB
|
||||
|
||||
```
|
||||
@ -576,24 +576,24 @@ Useful for consuming recipes saved from the web version of CyberChef.
|
||||
#### Examples:
|
||||
```javascript
|
||||
// Single operation input
|
||||
chef.bake("Apple pie", chef.toBase32).toString();
|
||||
await(chef.bake("Apple pie", chef.toBase32)).toString();
|
||||
// => IFYHA3DFEBYGSZI=
|
||||
|
||||
// Single operation name
|
||||
chef.bake("Apple pie", "to base 32").toString();
|
||||
await(chef.bake("Apple pie", "to base 32")).toString();
|
||||
// => IFYHA3DFEBYGSZI=
|
||||
|
||||
// Single operation object with args
|
||||
chef.bake("Apple pie", {
|
||||
await(chef.bake("Apple pie", {
|
||||
op: chef.toBase32, // string would work here too
|
||||
args: {
|
||||
alphabet: "A-Z"
|
||||
}
|
||||
}).toString();
|
||||
})).toString();
|
||||
// => IFYHADFEBYGSZI
|
||||
|
||||
// Multiple operations
|
||||
chef.bake("Apple pie", [
|
||||
await(chef.bake("Apple pie", [
|
||||
chef.toBase32,
|
||||
{
|
||||
op: "from base 32",
|
||||
@ -601,7 +601,7 @@ chef.bake("Apple pie", [
|
||||
alphabet: "A-Z2-7=",
|
||||
},
|
||||
}
|
||||
]).toString();
|
||||
])).toString();
|
||||
// => Apple pie
|
||||
```
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user