Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

common Update docstring #417

Open
mtuchi opened this issue Feb 19, 2024 · 0 comments
Open

common Update docstring #417

mtuchi opened this issue Feb 19, 2024 · 0 comments

Comments

@mtuchi
Copy link
Contributor

mtuchi commented Feb 19, 2024

Description

Inspect the jsdocs for all functions in packages/common and make sure they align with what the function is suppose to do.
Add examples with captions for functions that returns {Operation}

Suggestions

Improvements suggestion for each() function

/**
 * Scopes an array of data based on a JSONPath, a function, or an object.
 * Useful when the source data has `n` items you would like to map to
 * an operation.
 * The operation will receive a slice of the data based on each item
 * of the JSONPath, function result, or the provided object.
 *
 * Note: It's the responsibility of the provided operation to ensure that
 * the results make their way back into the state's references.
 *
 * It should be designed to handle each item in the scoped data.
 * The Promise resolves after applying the operation on each item in the scoped data.
 * @public
 * @example <caption>Using JSONPath referencing a point in `state`</caption>
 * each("$.data.users[*]",
 *   create("SObject",
 *     field("FirstName", sourceValue("$.firstName"))
 *   )
 * )
 *
 * @example <caption>Using a function to be called with `state`</caption>
 * each(state=> state.data.users,
 *   create("SObject",
 *     field("FirstName", sourceValue("$.firstName"))
 *   )
 * )
 * @example <caption>Using an Object Literal of the data itself.</caption>
 * each(dataValue('users'),
 *   create("SObject",
 *     field("FirstName", sourceValue("$.firstName"))
 *   )
 * )
 *
 * @function
 *
 * @param {String|Function|Object} dataSource - JSONPath referencing a point in `state`, a function that takes state and returns an array of data, or an object representing data itself.
 *   - If a string, it represents a JSONPath pointing to a location in the `state` object.
 *   - If a function, it should take the `state` as an argument and return an array of data.
 *   - If an object, it returns an Object Literal of the data itself.
 *
 * @param {Function} operation -  The operation that takes `state` and returns a modified `state`.
 *
 * @returns {Operation}
 */
export function each(dataSource, operation) {// Implementation of the function goes here }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant