Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
lift.js is a compact monad opinionated javascript library. It implements Just
(Identity), Maybe
, Valid
(Validation) and a nice Monad
factory. The unit
comes with a lift
function so you can add functionnality later in code to your monad. It's ment to be flexible and simple to use. It's written with es6 so it's less than 100 lines.
npm install liftjs
yarn add liftjs
https://github.com/atomable/lift.js
All the following work, pick your demon. lift.js
can be required directly for es next project or you can use the lift-min.js
for all legacy applications.
var lift = require('liftjs');
const lift = require('liftjs');
import lift from 'liftjs';
import { Monad, Just, Maybe, Valid, Curry } from 'liftjs';
Monad(modifier[monad, value]: null) : unit
const Person = Monad();
const person = Person({ firstname: 'Bill', lastname: 'Murray' });
// with a modifier
const doubleIt = Monad((monad, value) => {
monad.double = value * 2;
});
const two = doubleIt(2);
two.double();
// 4
With the lift
function you can add function at any time on the monads.
Monad[A].lift[name, func[A] : Monad[A]];
const justWithLog = Just(5);
Just.lift('log', console.log);
justWithLog.log();
// console> 5
You can also use it on your custom monads.
const Person = Monad();
const person = Person({ firstname: 'Bill', lastname: 'Murray' });
const FullName = Monad();
Person.lift('compose', person => FullName(`${person.firstname}, ${person.lastname}`));
person.compose().run(console.log);
// console> Bill, Murray
Just
is an implementaion of the Identity
monad. It's called Just
because an 8 character variable is just too long.
The folowing function are available on Just
, Maybe
, Valid
.
Monad[A].bind[func[A] : Monad[B], args] : Monad[B]
const justWithValue = Just(5).bind((value)=> Just(value));
// Just[5]
Monad[A].of[B] : Monad[B]
const justWithValue = Just(5).of(6);
// Just[6]
const justWithValue = Just(5).of(Just(6));
// Just[6]
Monad[A].get[] : A
const value = Just(5).get();
// 5
Monad[A].map[func[A] : B ] : Monad[B]
const justWithValue = Just(7).map(value => value * 2);
// Just[14]
Monad[Monad[A]].join[] : Monad[A]
const justWithValue = Just(Just(5)).join()
// Just[5]
Monad[A].toMaybe[] : Maybe[A]
const maybeWithValue = Just(5).toMaybe();
// Maybe[5]
Monad[A].run[func[A] : null]: Monad[A]
Just(5).run(value => console.log(value));
// console> 5
Maybe(A) : Maybe[A]
const maybeWithoutValue = Maybe()
// Maybe[]
const maybeWithValue = Maybe(2)
// Maybe[2]
const maybeWithoutValue = Maybe(undefined)
// Maybe[]
const maybeWithoutValue = Maybe(null)
// Maybe[]
Maybe[A].isNothing[] : boolean
const value = Maybe(5).isNothing();
// false
const value = Maybe(5).n();
// false
Maybe[A].is[] : boolean
const value = Maybe(5).is();
// true
const value = Maybe(5).i();
// true
Maybe[A].or[B] : A or B
const maybeWithValue = Maybe().or(15);
// 15
Maybe[A].else[Monad[B]] : Maybe[A] or Monad[B]
const maybeWithValue = Maybe(5).else(Maybe(15));
// Maybe[5]
const maybeWithValue = Maybe().e(Just(15));
// Just[15]
Curry
is a factory that takes a function and returs a curried function.
Curry(func) : func
const curried = Curry((a, b) => a * b);
curried(3)(6);
// 18
Curry((a, b, c) => a + b + c)(1, 2, 3)
// 6
I don't plan on adding all the typical monads to the library, if you feel one should be added you are welcome to make a pull request or to fork. I'm thinking of Free, IO and List, but not sure yet. It will depend on what I use in my own projects.
Below are the things that I actually plan on doing. Soon.
Valid
lift_value
functionmethod
functionap
function just Just
and Maybe
& testsWritten and maintained by pre63.
Sponsored by atomable.
Based on Douglas Crockford MONAD.
Special thanks to Monet for the inspiration.
FAQs
lift.js is a compact monad opinionated javascript library
The npm package liftjs receives a total of 2 weekly downloads. As such, liftjs popularity was classified as not popular.
We found that liftjs 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.