Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const gt = x => y => x > y;
- const lt = x => y => x < y;
- const or = x => y => x || y;
- const and = x => y => x && y;
- const type = x => typeof x;
- // like type('foo') => 'string';
- // like type(undefined) => 'undefined';
- const equal = x => y => x === y;
- // like eq(false)(false) => true;
- // like eq(false)(true) => false;
- const nequal = x => y => x !== y;
- // like neq(false)(true) => true;
- // like neq(true)(true) => false;
- const $typeof = x => y => equal(x)(type(y));
- // like $typeof('string')('foo') => true;
- // like $typeof('undefined')(undefined) => true;
- // like $typeof('boolean')('fizzbuzz') => false;
- const undef = x => $typeof('undefined')(x);
- // like undef(undefined) => true;
- // like undef('foo') => false;
- const def = x => nequal(type(x))('undefined');
- // like def(undefined) => false;
- // like def('foo') => true;
- const gte = x => y => or(gt(x)(y))(eq(x)(y));
- const lte = x => y => or(lt(x)(y))(eq(x)(y));
- const ss = x => y => or(or(and(gt(x)(y))(1))(and(gt(y)(x))(-1)))(0);
- // like ss(10)(1) => 1;
- // like ss(1)(10) => -1;
- // like ss(1)(1) => 0;
- const is = x => y => x.__proto__.isPrototypeOf(new y());
- // like is(x)(Array); => true;
- // like is(true)(String) => false;
- const is_not = x => y => equal(is(x)(y))(false);
- const is_null = x => equal(x)(null);
- export {
- gt,
- lt,
- and,
- or,
- type,
- equal,
- nequal,
- undef,
- def,
- gte,
- lte,
- ss,
- is,
- is_not,
- is_null
- };
Add Comment
Please, Sign In to add comment