Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
FxJS is a functional programming library that uses basic JavaScript values and emphasizes repeatable programming and Promise.
const res = go(
L.range(Infinity),
L.filter(a => a % 2),
L.take(3),
reduce(add));
log(res); // 9
go(
L.range(Infinity),
L.map(delay(1000)),
L.map(a => a + 10),
L.take(3),
each(log));
// After 1 second 10
// After 2 seconds 11
// After 3 seconds 12
// L.interval = time => L.map(delay(time), L.range(Infinity));
(async () => {
await go(
L.interval(1000),
L.map(a => a + 30),
L.takeUntil(a => a == 33),
each(log));
// After 1 second 30
// After 2 seconds 31
// After 3 seconds 32
// After 4 seconds 33
const res = await go(
L.interval(1000),
L.map(a => a + 20),
L.takeWhile(a => a < 23),
L.map(tap(log)),
reduce(add));
// After 5 seconds 20
// After 6 seconds 21
// After 7 seconds 22
log(res);
// 63
} ());
npm i fxjs2
map(a => a + 10, [1, 2, 3]);
// [11, 12, 13]
filter(a => a % 2, [1, 2, 3]);
// [1, 3]
const add = (a, b) => a + b
reduce(add, [1, 2, 3]);
// 6
reduce(add, 10, [1, 2, 3]);
// 16
reduce(add, {a: 1, b: 2, c: 3});
// 6
await reduce(add, [Promise.resolve(1), 2, 3])
// 6
take(1, [1, 2, 3]);
// [1]
take(2, [1, 2, 3])
// [1, 2]
const iterator = L.map(a => a + 10, [1, 2, 3]);
take(2, iterator);
// [11, 12]
const iterator = L.filter(a => a % 2, [1, 2, 3, 4, 5]);
take(2, iterator);
// [1, 3]
const iterator = L.filter(a => a % 2, L.map(a => a + 10, [1, 2, 3, 4, 5]));
take(2, iterator);
// [11, 13]
const b = go(
0,
a => a + 1,
a => a + 10,
a => a + 100);
console.log(b);
// 111
try {
const b = go(
0,
a => { throw { hi: 'ho' } },
a => a + 10,
a => a + 100);
console.log(b);
} catch (c) {
console.log(c);
}
// { hi: 'ho' }
const b = await go(
0,
a => Promise.resolve(a + 1),
a => a + 10,
a => a + 100);
console.log(b);
// 111
try {
const b = await go(
0,
a => Promise.resolve(a + 1),
a => Promise.reject({ hi: 'ho' }),
a => a + 100);
console.log(b);
} catch (c) {
console.log(c);
}
// { hi: 'ho' }
try {
const b = await go(
0,
a => Promise.resolve(a + 1),
a => Promise.reject({ hi: 'ho' }),
a => a + 100);
console.log(b);
} catch (c) {
console.log(c);
}
// { hi: 'ho' }
const f1 = pipeS(
a => a % 2 ? stop(a) : a,
a => a + 10);
f1(1); // 1
f1(2); // 12
goS({a: 1, b: 2},
stopIf({a: 1}),
({a, b}) => ({a: a + 10, b})); // {a: 1, b: 2}
goS({a: 2, b: 2},
stopIf({a: 1}),
({a, b}) => ({a: a + 10, b})); // {a: 12, b: 2}
goS({a: 1, b: 2},
stopIf({a: 1}, null),
({a, b}) => ({a: a + 10, b}));
// null
FAQs
Functional Extensions for modern Javascript
The npm package fxjs2 receives a total of 25 weekly downloads. As such, fxjs2 popularity was classified as not popular.
We found that fxjs2 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
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.