Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
@yoomoney/pure-process
Advanced tools
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
});
0.2.0
this
argument of the function created with pipeP
or parallelMerge
is propagated to argument functionsparallelMerge
can be called without argumentsFAQs
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.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.