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.
|
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`
|
||||||
`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
|
One operation, no arguments
|
||||||
```javascript
|
```javascript
|
||||||
chef.bake("I'll have the cod.", chef.toBase64);
|
await(chef.bake("I'll have the cod.", chef.toBase64));
|
||||||
// => SSdsbCBoYXZlIHRoZSBjb2Qu
|
// => SSdsbCBoYXZlIHRoZSBjb2Qu
|
||||||
```
|
```
|
||||||
One operation by name
|
One operation by name
|
||||||
```javascript
|
```javascript
|
||||||
chef.bake("I'll have the cod.", "to base 64");
|
await(chef.bake("I'll have the cod.", "to base 64"));
|
||||||
// => SSdsbCBoYXZlIHRoZSBjb2Qu
|
// => SSdsbCBoYXZlIHRoZSBjb2Qu
|
||||||
```
|
```
|
||||||
Multiple operations, by name or by function (default arguments)
|
Multiple operations, by name or by function (default arguments)
|
||||||
```javascript
|
```javascript
|
||||||
chef.bake("I'll have the cod", [chef.toBase64, "sha1"]);
|
await(chef.bake("I'll have the cod", [chef.toBase64, "sha1"]));
|
||||||
// => f20135964d60f5fb66f971f5ee33d8395d1f90bf
|
// => f20135964d60f5fb66f971f5ee33d8395d1f90bf
|
||||||
```
|
```
|
||||||
|
|
||||||
One operation, with custom arguments
|
One operation, with custom arguments
|
||||||
```javascript
|
```javascript
|
||||||
chef.bake("I'll have the salmon.", {
|
await(chef.bake("I'll have the salmon.", {
|
||||||
op: chef.toBase64,
|
op: chef.toBase64,
|
||||||
args: {
|
args: {
|
||||||
alphabet: "A-Z",
|
alphabet: "A-Z",
|
||||||
},
|
},
|
||||||
});
|
}));
|
||||||
// => SSCBYXZIHRZSBYW
|
// => SSCBYXZIHRZSBYW
|
||||||
```
|
```
|
||||||
|
|
||||||
Multiple operations with custom arguments
|
Multiple operations with custom arguments
|
||||||
```javascript
|
```javascript
|
||||||
chef.bake("I'll have the salmon.", [
|
await(chef.bake("I'll have the salmon.", [
|
||||||
{
|
{
|
||||||
op: chef.toBase64,
|
op: chef.toBase64,
|
||||||
args: {
|
args: {
|
||||||
@ -391,7 +391,7 @@ chef.bake("I'll have the salmon.", [
|
|||||||
reverse: true,
|
reverse: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]));
|
||||||
// => ZZYYXWSSSRIHCBB
|
// => ZZYYXWSSSRIHCBB
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ const recipe = [
|
|||||||
"args": ["Nothing (separate chars)", true, "Alphabetical (case sensitive)"] }
|
"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
|
// => ZZYYXWSSSRIHCBB
|
||||||
|
|
||||||
```
|
```
|
||||||
@ -576,24 +576,24 @@ Useful for consuming recipes saved from the web version of CyberChef.
|
|||||||
#### Examples:
|
#### Examples:
|
||||||
```javascript
|
```javascript
|
||||||
// Single operation input
|
// Single operation input
|
||||||
chef.bake("Apple pie", chef.toBase32).toString();
|
await(chef.bake("Apple pie", chef.toBase32)).toString();
|
||||||
// => IFYHA3DFEBYGSZI=
|
// => IFYHA3DFEBYGSZI=
|
||||||
|
|
||||||
// Single operation name
|
// Single operation name
|
||||||
chef.bake("Apple pie", "to base 32").toString();
|
await(chef.bake("Apple pie", "to base 32")).toString();
|
||||||
// => IFYHA3DFEBYGSZI=
|
// => IFYHA3DFEBYGSZI=
|
||||||
|
|
||||||
// Single operation object with args
|
// Single operation object with args
|
||||||
chef.bake("Apple pie", {
|
await(chef.bake("Apple pie", {
|
||||||
op: chef.toBase32, // string would work here too
|
op: chef.toBase32, // string would work here too
|
||||||
args: {
|
args: {
|
||||||
alphabet: "A-Z"
|
alphabet: "A-Z"
|
||||||
}
|
}
|
||||||
}).toString();
|
})).toString();
|
||||||
// => IFYHADFEBYGSZI
|
// => IFYHADFEBYGSZI
|
||||||
|
|
||||||
// Multiple operations
|
// Multiple operations
|
||||||
chef.bake("Apple pie", [
|
await(chef.bake("Apple pie", [
|
||||||
chef.toBase32,
|
chef.toBase32,
|
||||||
{
|
{
|
||||||
op: "from base 32",
|
op: "from base 32",
|
||||||
@ -601,7 +601,7 @@ chef.bake("Apple pie", [
|
|||||||
alphabet: "A-Z2-7=",
|
alphabet: "A-Z2-7=",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
]).toString();
|
])).toString();
|
||||||
// => Apple pie
|
// => Apple pie
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user