Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
current-executing-script
Advanced tools
Readme
Get the currently executing script, regardless of its source/trigger/synchronicity. Similar to HTML5's document.currentScript
but arguably much more useful!
This utility comprises a set of behaviors for detecting the currently executing script, which does not comply with the HTML spec's concept of document.currentScript
. However, personally, I find it much more useful!
It can get the script
element that was the source of the nearest (deepest) frame in the call stack (so, the currently executing code), regardless of whether or not said source script is being evaluated synchronously for the first time by the browser.
It also has experimental support for getting the script
element that was the source of the farthest (most shallow) frame in the call stack, regardless of whether or not said source script is being evaluated synchronously for the first time by the browser.
Finally, it has experimental support for getting the script
element or attribute node (e.g. onclick
) responsible for creating the current call stack.
If you are only interested in getting the currently synchronously evaluating script (i.e. like an HTML spec-compliant polyfill for document.currentScript
), take a look at JamesMGreene/document.currentScript instead.
Forthcoming....
npm install current-executing-script
Alternatively, you can download/clone its GitHub repo: JamesMGreene/currentExecutingScript
To get the nearest (deepest) script for the current call stack:
var scriptEl1 = currentExecutingScript();
var scriptEl2 = currentExecutingScript.near();
EXPERIMENTAL!!!
To get the farthest (most shallow) script for the current call stack:
var scriptEl = currentExecutingScript.far();
IMPORTANT: Note that the accuracy of this may be limited by the allowed stack depth of each browser. For example, Chrome defaults to collecting a maximum of the 10 nearest frames but can be configured to collect more (see Error.stackTraceLimit
and --stack-trace-limit
). This library will automatically configure it to Infinity
on your behalf.
EXPERIMENTAL!!!
To get the script or attribute node (e.g. onclick
) responsible for initiating the current call stack:
var scriptElOrAttrNode = currentExecutingScript.origin();
In most situations, the result of .origin()
will commonly match the result of .far()
unless the current call stack was initiated by something other than a script
element (e.g. an onclick
attribute node).
IMPORTANT: Note that the accuracy of this may be limited by the allowed stack depth of each browser. For example, Chrome defaults to collecting a maximum of the 10 nearest frames but can be configured to collect more (see Error.stackTraceLimit
and --stack-trace-limit
). This library will automatically configure it to Infinity
on your behalf.
skipStackDepth
The stack depth to skip over when analyzing call stack frames (defaults to 1
, to ensure it skips over its own functions).
document.currentScript
: https://developer.mozilla.org/en-US/docs/Web/API/document.currentScriptFAQs
Get the currently executing script, regardless of its source/trigger/synchronicity. Similar to HTML5's `document.currentScript` but arguably much more useful!
The npm package current-executing-script receives a total of 2,808 weekly downloads. As such, current-executing-script popularity was classified as popular.
We found that current-executing-script demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.