
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@funkia/jabz
Advanced tools
Powerful and practical abstractions for JavaScript. Functors, monads, foldables traversables and all that jazz.
For a more detailed introduction to the design of the specification and a comparison to Fantasy Land please see this blog post.
npm install @funkia/jabz
See the API documentation and the example below.
Note that the specification for the abstractions is not written down formally yet. But the source code contain TypeScript interfaces that documents the different required methods. The laws associated with the abstractions are as expected if one is familiar with them.
This example demonstrates some of what Jabz can do by implementing a simple singly linked list aka. a cons list.
@monad @traversable
class Cons {
constructor(v, t) {
this.val = v;
this.tail = t;
}
concat(c) {
return this === nil ? c : cons(this.val, this.tail.concat(c));
}
of(b: B) {
return cons(b, nil);
}
chain<B>(f) {
return this === nil ? nil : f(this.val).concat(this.tail.chain(f));
}
traverse<B>(a, f) {
return this === nil ? a.of(nil) : lift(cons, f(this.val), this.tail.traverse(a, f));
}
}
const nil = new Cons(undefined, undefined);
function cons(a: A, as) {
return new Cons(a, as);
}
function fromArray(as) {
return as.length === 0 ? nil : cons(as[0], fromArray(as.slice(1)));
}
Since Cons
contains the methods of
and chain
it can
implement monad. This is done with the @monad
decorator. JavaScript
decorators are just plain old functions so they can also be used
without the decorator syntax
monad(Cons);
The function allows implementations flexibility in what methods they
choose to provide. For instance monad can also be implemented by
defining a of
, a map
and a chain
method.
Similar to Monad, Traversable is implemented by defining the
traverse
method and using the traversable
decorator.
When we implement Monad Jabz automatically derives implementations for
Functor and Applicative. Likewise when we implement Traversable it
derives Foldable. Thus, Jabz can give us a lot of things for free just
from the few methods the Cons
class defines.
Map functions over elements in the list.
mapTo((n) => n * n, fromArray([1, 2, 3, 4])); //=> [1, 4, 9, 16]
Change each element in the list to a constant.
mapTo(8, fromArray([1, 2, 3, 4])); //=> [8, 8, 8, 8]
Apply a list of functions to a list of values.
ap(fromArray([(n) => n * 2, (n) => n * n]), fromArray(1, 2, 3)); //=> [2, 4, 6, 1, 4, 9]
Folding.
foldr((n, m) => n + m, 3, fromArray([1, 2, 3, 4, 5])); //=> 18
Find an element satisfying a predicate.
find((n) => n > 6, fromArray([1, 8, 3, 7, 5])); //=> just(8)
findLast((n) => n > 6, fromArray([1, 8, 3, 7, 5])); //=> just(7)
We can convert a cons-list to an array
toArray(fromArray([1, 2, 3, 4])); //=> [1, 2, 3, 4]
We can flatten nested cons-lists.
flatten(fromArray([fromArray([1, 2]), fromArray([3, 4, 5])])); //=> [1, 2, 3, 4, 5]
Seamless instances means that certain native JavaScript types can be used as if they implemented the abstractions relevant for them.
string
, implements setoid and monoid.array
, implements setoid, monoid, functor, foldable and traversable.FAQs
Powerful and practical abstractions.
The npm package @funkia/jabz receives a total of 5 weekly downloads. As such, @funkia/jabz popularity was classified as not popular.
We found that @funkia/jabz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.