Research
Recent Trends in Malicious Packages Targeting Discord
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
@yoomoney/pure-process
Advanced tools
Changelog
0.2.0
this
argument of the function created with pipeP
or parallelMerge
is propagated to argument functionsparallelMerge
can be called without argumentsReadme
Primitives for business logic structuring
npm install @yoomoney/pure-process
const {exit} = require('@yoomoney/pure-process');
const EXIT_CODE = {
needLogin: 'needLogin'
};
const getUser = async() => {
const {user, latency} = await fetchUser();
if (!user) {
exit(EXIT_CODE.needLogin, {latency});
}
return user;
};
const getPosts = async(user) => ({
posts: await fetchPosts(user.id)
});
const process = () => Promise.resolve()
.then(getUser)
.then(getPosts)
.then(...exit());
const output = await process();
if (output.exitCode === EXIT_CODE.needLogin) {
output.latency;
} else {
output.exitCode; // main (default)
output.posts;
}
const {createExit} = require('@yoomoney/pure-process');
enum ExitCode {
NeedLogin = 'NEED_LOGIN',
NoPosts = 'NO_POSTS'
};
const exit = createExit<{
exitCode: ExitCode.NeedLogin;
latency: number;
} | {
exitCode: ExitCode.NoPosts
}>();
const getUser = async() => {
const {user, latency} = await fetchUser();
if (!user) {
exit(ExitCode.NeedLogin, {latency});
}
return user;
};
const getPosts = async(user: User) => ({
posts: await fetchPosts(user.id)
});
const process = () => Promise.resolve()
.then(getUser)
.then(getPosts)
.then(...exit());
const output = await process();
if (output.exitCode === ExitCode.NeedLogin) {
output.latency;
} else {
output.exitCode; // main (default)
output.posts;
}
const {pipeP, parallelMerge} = require('@yoomoney/pure-process');
const stepA = () => ({
resultA: 1
});
const stepB = ({resultA}) => ({
resultB: resultA + 1
});
const stepC = ({resultA}) => ({
resultC: resultA + 2
});
const process = () => Promise.resolve()
.then(stepA)
.then((data) => Promise.all([
stepB(data),
stepC(data)
]).then(([result1, result2]) => ({
...data,
...result1,
...result2
}))
);
// Equivalent
const process = pipeP(
stepA,
parallelMerge(
stepB,
stepC
)
);
expect(await process()).toEqual({
resultA: 1,
resultB: 2,
resultC: 3
});
this
argument of the created function is propagated to argument functions.
const process = pipeP(
stepA,
stepB,
exit.pipe
);
const {skipErrors} = require('@yoomoney/pure-process');
const stepA = async(data) => ({
...data,
resultA: await fetchCritical()
});
const stepB = async(data) => ({
...data,
resultB: await fetchNonCritical()
});
const process = (data) => Promise.resolve(data)
.then(stepA)
.then(skipErrors(stepB));
await process({
// Optional
logError: console.log
});
FAQs
Primitives for business logic structuring
We found that @yoomoney/pure-process demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
The Socket research team breaks down a sampling of malicious packages that download and execute files, among other suspicious behaviors, targeting the popular Discord platform.
Security News
Socket CEO Feross Aboukhadijeh joins a16z partners to discuss how modern, sophisticated supply chain attacks require AI-driven defenses and explore the challenges and solutions in leveraging AI for threat detection early in the development life cycle.
Security News
NIST's new AI Risk Management Framework aims to enhance the security and reliability of generative AI systems and address the unique challenges of malicious AI exploits.