-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve organization of context object
Remove backwards compat sys data Rename bindingMetadata to triggerMetadata Remove executionContext and move functionName/retryContext up a level Remove bindingDefinitions because users will define it in code Related to Azure/azure-functions-nodejs-worker#204
- Loading branch information
Showing
11 changed files
with
448 additions
and
717 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { fromTypedData } from './RpcConverters'; | ||
|
||
// Recursively convert keys of objects to camel case | ||
export function convertKeysToCamelCase(obj: any): { [key: string]: any } { | ||
const output = {}; | ||
for (const key in obj) { | ||
// Only "undefined" will be replaced with original object property. For example: | ||
//{ string : "0" } -> 0 | ||
//{ string : "false" } -> false | ||
//"test" -> "test" (undefined returned from fromTypedData) | ||
const valueFromDataType = fromTypedData(obj[key]); | ||
const value = valueFromDataType === undefined ? obj[key] : valueFromDataType; | ||
const camelCasedKey = key.charAt(0).toLocaleLowerCase() + key.slice(1); | ||
// If the value is a JSON object (and not array and not http, which is already cased), convert keys to camel case | ||
if (!Array.isArray(value) && typeof value === 'object' && value && value.http == undefined) { | ||
output[camelCasedKey] = convertKeysToCamelCase(value); | ||
} else { | ||
output[camelCasedKey] = value; | ||
} | ||
} | ||
return output; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.