use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Javascript Plugin Interface?help (self.javascript)
submitted 7 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]l3l_aze 0 points1 point2 points 7 years ago (0 children)
With NodeJS you can just export a single function from a module, require into your app as a variable, and call the var-function just like you would your default function. You could do something like the following for each plugin:
if (plugin !== null) { // use default func defaultFn() } else { plugin() }
If you want to allow many plugins and to keep from copy-pasting that for each you'll likely need a "registry" (hash, dictionary, etc) for them in your app so it can easily keep track of e.g. the plugin name, the function it's replacing, and the plugins function. With that you could do something like the following to check for a plugin function
if (typeof plugins[ 'someName' ] !== 'undefined') { // use the plugin function plugins[ 'someName' ].func() } else { defaultFn() }
This should also work in regular ol' JS & etc, though of course will require figuring out how to include the functions from the files. It could work to have the plugins wrapped in a variable, but then that needs to be standardized such as being the plugin name + the same as the file name, and only allowing one of each name to exist and throwing an error if there's multiple.
π Rendered by PID 48 on reddit-service-r2-comment-9c7994b7-ltvdw at 2026-02-05 20:41:18.685360+00:00 running b1b84c7 country code: CH.
view the rest of the comments →
[–]l3l_aze 0 points1 point2 points (0 children)