Innovenergy_trunk/frontend/node_modules/fp-ts/lib/number.js

131 lines
3.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Field = exports.MonoidProduct = exports.MonoidSum = exports.SemigroupProduct = exports.SemigroupSum = exports.MagmaSub = exports.Show = exports.Bounded = exports.Ord = exports.Eq = exports.isNumber = void 0;
// -------------------------------------------------------------------------------------
// refinements
// -------------------------------------------------------------------------------------
/**
* @category refinements
* @since 2.11.0
*/
var isNumber = function (u) { return typeof u === 'number'; };
exports.isNumber = isNumber;
// -------------------------------------------------------------------------------------
// instances
// -------------------------------------------------------------------------------------
/**
* @category instances
* @since 2.10.0
*/
exports.Eq = {
equals: function (first, second) { return first === second; }
};
/**
* @category instances
* @since 2.10.0
*/
exports.Ord = {
equals: exports.Eq.equals,
compare: function (first, second) { return (first < second ? -1 : first > second ? 1 : 0); }
};
/**
* @category instances
* @since 2.10.0
*/
exports.Bounded = {
equals: exports.Eq.equals,
compare: exports.Ord.compare,
top: Infinity,
bottom: -Infinity
};
/**
* @category instances
* @since 2.10.0
*/
exports.Show = {
show: function (n) { return JSON.stringify(n); }
};
/**
* @category instances
* @since 2.11.0
*/
exports.MagmaSub = {
concat: function (first, second) { return first - second; }
};
/**
* `number` semigroup under addition.
*
* @example
* import { SemigroupSum } from 'fp-ts/number'
*
* assert.deepStrictEqual(SemigroupSum.concat(2, 3), 5)
*
* @category instances
* @since 2.10.0
*/
exports.SemigroupSum = {
concat: function (first, second) { return first + second; }
};
/**
* `number` semigroup under multiplication.
*
* @example
* import { SemigroupProduct } from 'fp-ts/number'
*
* assert.deepStrictEqual(SemigroupProduct.concat(2, 3), 6)
*
* @category instances
* @since 2.10.0
*/
exports.SemigroupProduct = {
concat: function (first, second) { return first * second; }
};
/**
* `number` monoid under addition.
*
* The `empty` value is `0`.
*
* @example
* import { MonoidSum } from 'fp-ts/number'
*
* assert.deepStrictEqual(MonoidSum.concat(2, MonoidSum.empty), 2)
*
* @category instances
* @since 2.10.0
*/
exports.MonoidSum = {
concat: exports.SemigroupSum.concat,
empty: 0
};
/**
* `number` monoid under multiplication.
*
* The `empty` value is `1`.
*
* @example
* import { MonoidProduct } from 'fp-ts/number'
*
* assert.deepStrictEqual(MonoidProduct.concat(2, MonoidProduct.empty), 2)
*
* @category instances
* @since 2.10.0
*/
exports.MonoidProduct = {
concat: exports.SemigroupProduct.concat,
empty: 1
};
/**
* @category instances
* @since 2.10.0
*/
exports.Field = {
add: exports.SemigroupSum.concat,
zero: 0,
mul: exports.SemigroupProduct.concat,
one: 1,
sub: exports.MagmaSub.concat,
degree: function (_) { return 1; },
div: function (first, second) { return first / second; },
mod: function (first, second) { return first % second; }
};