Skip to content

Commit

Permalink
Neo.Main: getByPath() => add support for accessing window methods & p…
Browse files Browse the repository at this point in the history
…assing params #6314
  • Loading branch information
tobiu committed Jan 27, 2025
1 parent 7fd43ba commit 1ac142c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,19 @@ class Main extends core.Base {
/**
* Request specific accessible window attributes by path into the app worker.
* Keep in mind that this excludes anything DOM related or instances.
* Example: Neo.Main.getByPath({path: 'navigator.language'}).then(data => {})
* In case your path matches a method, you can also pass params for it.
* @example:
* Neo.Main.getByPath({path: 'navigator.language'}).then(data => {})
* @example:
* Neo.Main.getByPath({path: 'CSS.supports', params: ['display: flex']}).then(data => {})
* @param {Object} data
* @param {Array} data.params=[]
* @param {String} data.path
* @returns {*}
*/
getByPath(data) {
return Neo.nsWithArrays(data.path)
getByPath({params=[], path}) {
let target = Neo.nsWithArrays(path);
return Neo.isFunction(target) ? target(...params) : target
}

/**
Expand Down

0 comments on commit 1ac142c

Please sign in to comment.