mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-01-30 05:27:30 +00:00
Merge pull request #32075 from Zlatkovsky/CustomFunctionsAssociateOverload
Add dictionary-based overload for `CustomFunctions.associate`
This commit is contained in:
commit
c747eccf6d
@ -5,6 +5,11 @@ function add10(n: number) {
|
||||
|
||||
CustomFunctions.associate('ADD10', add10);
|
||||
|
||||
CustomFunctions.associate({
|
||||
ADD10: add10,
|
||||
RANDOM: (n: number) => n * Math.random()
|
||||
});
|
||||
|
||||
async function getStockValues(ticker: string): Promise<number> {
|
||||
const response = await fetch(`myService.com/prices/${ticker}`);
|
||||
return (await response.json())["price"];
|
||||
|
||||
9
types/custom-functions-runtime/index.d.ts
vendored
9
types/custom-functions-runtime/index.d.ts
vendored
@ -16,9 +16,14 @@ Copyright (c) Microsoft Corporation
|
||||
declare namespace CustomFunctions {
|
||||
/**
|
||||
* @beta
|
||||
* Ties together the function's JavaScript name with the JSON id property
|
||||
* Associates the JavaScript function to the name given by the "id" property in the metadata JSON file.
|
||||
*/
|
||||
function associate(id: string, functionObject: Function): void;
|
||||
/**
|
||||
* @beta
|
||||
* Associates the JavaScript functions to the names given by the "id" properties in the metadata JSON file.
|
||||
*/
|
||||
function associate(mappings: { [key: string]: Function }): void;
|
||||
|
||||
/**
|
||||
* A handler passed automatically as the last parameter
|
||||
@ -28,7 +33,6 @@ declare namespace CustomFunctions {
|
||||
* to handle what happens when the function stops streaming.
|
||||
* @beta
|
||||
*/
|
||||
|
||||
interface StreamingHandler<T> extends CancelableHandler {
|
||||
/**
|
||||
* Sets the returned result for a streaming custom function.
|
||||
@ -36,6 +40,7 @@ declare namespace CustomFunctions {
|
||||
*/
|
||||
setResult: (value: T | Error) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* CancelableHandler interface
|
||||
|
||||
Loading…
Reference in New Issue
Block a user