Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@ansi-art/async-context
Advanced tools
A construct for chainable contexts which use async functions compatible with callbacks or promises.
Assuming we have an object with a function that takes an object and returns a transformed version of that object:
let str ='';
const myObject = {
foo: (item, callback)=>{
str += `foo ${str}`
callback(null, str);
}
};
Take that object and make a context using it:
import { asyncContext } from '@ansi-art/async-context';
const context = asyncContext(myObject);
const value = await context.foo().foo().foo();
// value === "foo foo foo"
kitchen-sync
kitchen-sync
allows you to support both callbacks and promises with no stack fragmentation in the event callbacks are used, allowing for simpler debugging internally to a set of libraries, for example, but allowing external use of more modern idioms.
import { kitchenSync } from `@ansi-art/async-context/kitchen-sync`;
(async ()=>{
const fn = (arg, cb){
const callback = kitchenSync(cb);
someFunctionThatTakesCallbacks(callback);
return callback.return;
}
const result = await fn(someArgValue);
})();
That's all.
Run the es module tests to test the root modules
npm run import-test
to run the same test inside the browser:
npm run browser-test
to run the same test headless in chrome, firefox and safari:
npm run headless-browser-test
to run the same test inside docker:
npm run container-test
Run the commonjs tests against the /dist
commonjs source (generated with the build-commonjs
target).
npm run require-test
All work is done in the .mjs files and will be transpiled on commit to commonjs and tested.
If the above tests pass, then attempt a commit which will generate .d.ts files alongside the src
files and commonjs classes in dist
FAQs
A construct for chainable contexts
We found that @ansi-art/async-context demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.