Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exalted.future

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exalted.future - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

289

dist/index.esm.js

@@ -0,1 +1,22 @@

var id = function id(a) {
return a;
};
var noop = function noop() {};
var isNull = function isNull(value) {
return value === null || value === undefined;
};
var Identity$1 = {
Left: id,
Right: id
};
var iff = function iff() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : id;
var a = arguments.length > 1 ? arguments[1] : undefined;
return f(a);
};
var compose = function compose() {

@@ -15,8 +36,2 @@ for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {

var fmap = function fmap(f) {
return function (functor) {
return functor.map(f);
};
};
var map = function map() {

@@ -28,4 +43,4 @@ for (var _len2 = arguments.length, functions = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {

return function (functor) {
return functions.reduceRight(function (acc, f) {
return fmap(f)(acc);
return functions.reduceRight(function (functor, f) {
return functor.map(f);
}, functor);

@@ -35,77 +50,48 @@ };

var id = function id(a) {
return a;
var eq = function eq(a, r) {
return r.cata({
Right: function Right(b) {
return a === b;
},
Left: function Left(b) {
return a === b;
}
});
};
var leftIdentity = {
Left: id
};
var rightIdentity = {
Right: id
};
var identity = {
Left: id,
Right: id
};
var isNull = function isNull(value) {
return value === null || value === undefined;
};
var identity$1 = function identity$1(a) {
return a;
};
var Right = function Right(a) {
return {
ap: function ap(app) {
return app.isLeft ? app : app.map(function () {
var b = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return b(a);
return app.isLeft ? app : app.map(function (b) {
return iff(b, a);
});
},
bimap: function bimap() {
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity$1;
return right(a);
bimap: function bimap(_, r) {
return iff(r, a);
},
cata: function cata() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
Right: identity$1
};
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Identity;
return f.Right(a);
},
chain: function chain() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return f(a);
chain: function chain(f) {
return iff(f, a);
},
equals: function equals(r) {
return r.cata({
Right: function Right(b) {
return a === b;
},
Left: function Left(b) {
return a === b;
}
});
return eq(a, r);
},
fold: function fold() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return f(a);
fold: function fold(f) {
return iff(f, a);
},
foldl: function foldl() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return f(null);
foldl: function foldl(f) {
return iff(f, null);
},
foldr: function foldr() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return f(a);
foldr: function foldr(f) {
return iff(f, a);
},
inspect: function inspect() {
return "Right(".concat(a, ")");
return 'Right(' + a + ')';
},
isLeft: false,
map: function map() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return Right(f(a));
map: function map(f) {
return Right(iff(f, a));
},

@@ -130,11 +116,7 @@ of: function of(a) {

},
bimap: function bimap() {
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity$1;
return left(a);
bimap: function bimap(l, _) {
return iff(l, a);
},
cata: function cata() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
Left: identity$1
};
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Identity;
return f.Left(a);

@@ -149,25 +131,15 @@ },

equals: function equals(l) {
return l.cata({
Left: function Left(b) {
return a === b;
},
Right: function Right(b) {
return a === b;
}
});
return eq(a, l);
},
fold: function fold() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return f(a);
fold: function fold(f) {
return iff(f, a);
},
foldl: function foldl() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return f(a);
foldl: function foldl(f) {
return iff(f, a);
},
foldr: function foldr() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
return f(null);
foldr: function foldr(f) {
return iff(f, null);
},
inspect: function inspect() {
return "Left(".concat(a, ")");
return 'Left(' + a + ')';
},

@@ -196,7 +168,5 @@ isLeft: true,

var encase = function encase() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$1;
var encase = function encase(f) {
try {
return Right(f(null));
return Right(iff(f, null));
} catch (err) {

@@ -245,3 +215,3 @@ return Left(err);

Future.of = function (x) {
return Future(function (reject, resolve) {
return Future(function (_, resolve) {
return resolve(x);

@@ -282,28 +252,18 @@ });

var identity$2 = function identity$2(a) {
return a;
};
var Id = function Id(a) {
return {
ap: function ap(app) {
return app.map(function () {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$2;
return f(a);
return app.map(function (f) {
return iff(f, a);
});
},
bimap: function bimap() {
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$2;
var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity$2;
return right(a);
bimap: function bimap(_, r) {
return iff(r, a);
},
cata: function cata() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
Right: identity$2
};
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Identity$1;
return f.Right(a);
},
chain: function chain() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$2;
return f(a);
chain: function chain(f) {
return iff(f, a);
},

@@ -317,16 +277,13 @@ equals: function equals(id) {

},
fold: function fold() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$2;
return f(a);
fold: function fold(f) {
return iff(f, a);
},
foldl: function foldl() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$2;
return f(null);
foldl: function foldl(f) {
return iff(f, null);
},
foldr: function foldr() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$2;
return f(a);
foldr: function foldr(f) {
return iff(f, a);
},
map: function map(f) {
return Id(f(a));
return Id(iff(f, a));
},

@@ -337,3 +294,3 @@ of: function of(a) {

inspect: function inspect() {
return "Id(".concat(a, ")");
return 'Id(' + a + ')';
}

@@ -347,18 +304,2 @@ };

var isNull$1 = function isNull$1(value) {
return value === null || value === undefined;
};
var Maybe = function Maybe(a) {
return isNull$1(a) ? Nothing() : Just(a);
};
Maybe.of = function (a) {
return Maybe(a);
};
var identity$3 = function identity$3(a) {
return a;
};
var Nothing = function Nothing() {

@@ -369,11 +310,7 @@ return {

},
bimap: function bimap() {
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$3;
var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity$3;
return left(null);
bimap: function bimap(l, _) {
return iff(l, null);
},
cata: function cata() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
Left: identity$3
};
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Identity$1;
return f.Left(null);

@@ -384,5 +321,4 @@ },

},
alt: function alt() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$3;
return Maybe(f(null));
alt: function alt(f) {
return Maybe(iff(f, null));
},

@@ -392,9 +328,9 @@ equals: function equals(id) {

Right: function Right(b) {
return isNull$1(b);
return isNull(b);
}
});
},
fold: function fold() {},
foldl: function foldl() {},
foldr: function foldr() {},
fold: noop,
foldl: noop,
foldr: noop,
inspect: function inspect() {

@@ -423,16 +359,11 @@ return 'Nothing()';

},
bimap: function bimap() {
var left = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$3;
var right = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : identity$3;
return right(a);
bimap: function bimap(_, r) {
return iff(r, a);
},
cata: function cata() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
Right: identity$3
};
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : Identity$1;
return f.Right(a);
},
chain: function chain() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$3;
return f(a);
chain: function chain(f) {
return iff(f, a);
},

@@ -449,17 +380,14 @@ alt: function alt() {

},
fold: function fold() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$3;
return f(a);
fold: function fold(f) {
return iff(f, a);
},
foldl: function foldl() {},
foldr: function foldr() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$3;
return f(a);
foldl: noop,
foldr: function foldr(f) {
return iff(f, a);
},
inspect: function inspect() {
return "Just(".concat(a, ")");
return 'Just(' + a + ')';
},
map: function map() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$3;
return Maybe(f(a));
map: function map(f) {
return Maybe(iff(f, a));
},

@@ -476,7 +404,5 @@ of: function of(a) {

var encase$1 = function encase$1() {
var f = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : identity$3;
var encase$1 = function encase$1(f) {
try {
return Maybe(f(null));
return Maybe(iff(f, null));
} catch (_) {

@@ -489,2 +415,11 @@ return Nothing();

Nothing.encase = encase$1;
var Maybe = function Maybe(a) {
return isNull(a) ? Nothing() : Just(a);
};
Maybe.of = function (a) {
return Maybe(a);
};
Maybe.encase = encase$1;

@@ -518,2 +453,2 @@

export { Either, Future, Id, Just, Left, Maybe, Nothing, Right, compose, get, head, identity, last, leftIdentity, map, nullable, rightIdentity, tail };
export { Either, Future, Id, Identity$1 as Identity, Just, Left, Maybe, Nothing, Right, compose, get, head, id, iff, isNull, last, map, noop, nullable, tail };

@@ -7,2 +7,12 @@ (function (global, factory) {

const id = a => a;
const noop = () => {};
const isNull = value => value === null || value === undefined;
const Identity$1 = { Left: id, Right: id };
const iff = (f = id, a) => f(a);
const compose = (...rest) => (...a) =>

@@ -13,31 +23,19 @@ rest

const fmap = f => functor => functor.map(f);
const map = (...functions) => functor =>
functions.reduceRight((acc, f) => fmap(f)(acc), functor);
functions.reduceRight((functor, f) => functor.map(f), functor);
const id = a => a;
const eq = (a, r) => r.cata({ Right: b => a === b, Left: b => a === b });
const leftIdentity = { Left: id };
const rightIdentity = { Right: id };
const identity = { Left: id, Right: id };
const isNull = value => value === null || value === undefined;
const identity$1 = a => a;
const Right = a => ({
ap: app => (app.isLeft ? app : app.map((b = identity$1) => b(a))),
bimap: (left = identity$1, right = identity$1) => right(a),
cata: (f = { Right: identity$1 }) => f.Right(a),
chain: (f = identity$1) => f(a),
equals: r => r.cata({ Right: b => a === b, Left: b => a === b }),
fold: (f = identity$1) => f(a),
foldl: (f = identity$1) => f(null),
foldr: (f = identity$1) => f(a),
inspect: () => `Right(${a})`,
ap: app => (app.isLeft ? app : app.map((b) => iff(b,a))),
bimap: (_, r) => iff(r, a),
cata: (f = Identity) => f.Right(a),
chain: (f) => iff(f,a),
equals: r => eq(a,r),
fold: (f) => iff(f, a),
foldl: (f) => iff(f, null),
foldr: (f) => iff(f,a),
inspect: () => 'Right(' + a + ')',
isLeft: false,
map: (f = identity$1) => Right(f(a)),
map: (f) => Right(iff(f,a)),
of: a => Right(a),

@@ -51,11 +49,11 @@ swap: () => Left(a)

ap: app => (app.isLeft ? app : Left(a)),
bimap: (left = identity$1, right = identity$1) => left(a),
cata: (f = { Left: identity$1 }) => f.Left(a),
bimap: (l, _) => iff(l, a),
cata: (f = Identity) => f.Left(a),
chain: () => Left(a),
map: () => Left(a),
equals: l => l.cata({ Left: b => a === b, Right: b => a === b }),
fold: (f = identity$1) => f(a),
foldl: (f = identity$1) => f(a),
foldr: (f = identity$1) => f(null),
inspect: () => `Left(${a})`,
equals: l => eq(a,l),
fold: (f) => iff(f,a),
foldl: (f ) => iff(f,a),
foldr: (f ) => iff(f, null),
inspect: () => 'Left(' + a + ')',
isLeft: true,

@@ -72,5 +70,5 @@ of: a => Left(a),

const encase = (f = identity$1) => {
const encase = (f) => {
try {
return Right(f(null))
return Right(iff(f, null))
} catch (err) {

@@ -100,3 +98,3 @@ return Left(err)

Future.of = x => Future((reject, resolve) => resolve(x));
Future.of = x => Future((_, resolve) => resolve(x));

@@ -124,16 +122,14 @@ Future.fromPromise = promise =>

const identity$2 = a => a;
const Id = a => ({
ap: app => app.map((f = identity$2) => f(a)),
bimap: (left = identity$2, right = identity$2) => right(a),
cata: (f = { Right: identity$2 }) => f.Right(a),
chain: (f = identity$2) => f(a),
ap: app => app.map((f) => iff(f, a)),
bimap: (_, r) => iff(r,a),
cata: (f = Identity$1) => f.Right(a),
chain: (f ) => iff(f,a),
equals: id => id.cata({ Right: b => a === b }),
fold: (f = identity$2) => f(a),
foldl: (f = identity$2) => f(null),
foldr: (f = identity$2) => f(a),
map: f => Id(f(a)),
fold: (f ) => iff(f,a),
foldl: (f ) => iff(f,null),
foldr: (f ) => iff(f,a),
map: f => Id(iff(f, a)),
of: a => Id(a),
inspect: () => `Id(${a})`
inspect: () => 'Id(' + a + ')'
});

@@ -143,20 +139,12 @@

const isNull$1 = value => value === null || value === undefined;
const Maybe = a => (isNull$1(a) ? Nothing() : Just(a));
Maybe.of = a => Maybe(a);
const identity$3 = a => a;
const Nothing = () => ({
ap: () => Nothing(),
bimap: (left = identity$3, right = identity$3) => left(null),
cata: (f = { Left: identity$3 }) => f.Left(null),
bimap: (l, _) => iff(l,null),
cata: (f = Identity$1) => f.Left(null),
chain: () => Nothing(),
alt: (f = identity$3) => Maybe(f(null)),
equals: id => id.cata({ Right: b => isNull$1(b) }),
fold: () => {},
foldl: () => {},
foldr: () => {},
alt: (f ) => Maybe(iff(f,null)),
equals: id => id.cata({ Right: b => isNull(b) }),
fold: noop,
foldl: noop,
foldr: noop,
inspect: () => 'Nothing()',

@@ -171,12 +159,12 @@ map: () => Nothing(),

ap: app => app.map(f => f(a)),
bimap: (left = identity$3, right = identity$3) => right(a),
cata: (f = { Right: identity$3 }) => f.Right(a),
chain: (f = identity$3) => f(a),
bimap: (_, r) => iff(r,a),
cata: (f = Identity$1) => f.Right(a),
chain: (f) => iff(f,a),
alt: () => Just(a),
equals: id => id.cata({ Right: b => a === b }),
fold: (f = identity$3) => f(a),
foldl: () => {},
foldr: (f = identity$3) => f(a),
inspect: () => `Just(${a})`,
map: (f = identity$3) => Maybe(f(a)),
fold: (f) => iff(f, a),
foldl: noop,
foldr: (f) => iff(f, a),
inspect: () => 'Just(' + a + ')',
map: (f) => Maybe(iff(f, a)),
of: a => Maybe(a)

@@ -187,5 +175,5 @@ });

const encase$1 = (f = identity$3) => {
const encase$1 = (f) => {
try {
return Maybe(f(null))
return Maybe(iff(f, null))
} catch (_) {

@@ -200,2 +188,6 @@ return Nothing()

const Maybe = a => (isNull(a) ? Nothing() : Just(a));
Maybe.of = a => Maybe(a);
Maybe.encase = encase$1;

@@ -214,2 +206,3 @@

exports.Id = Id;
exports.Identity = Identity$1;
exports.Just = Just;

@@ -223,8 +216,9 @@ exports.Left = Left;

exports.head = head;
exports.identity = identity;
exports.id = id;
exports.iff = iff;
exports.isNull = isNull;
exports.last = last;
exports.leftIdentity = leftIdentity;
exports.map = map;
exports.noop = noop;
exports.nullable = nullable;
exports.rightIdentity = rightIdentity;
exports.tail = tail;

@@ -231,0 +225,0 @@

{
"name": "exalted.future",
"version": "0.0.12",
"version": "0.0.13",
"description": "Exalted monadic library & functional fun, fantasy-land compliant, mostly.",

@@ -5,0 +5,0 @@ "repository": "https://github.com/pre63/exalted.future.git",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc