UNPKG

@typed/new-type

Version:
26 lines 1.52 kB
import { isNewType } from './new-type'; const and = (f, g) => (value) => f(value) && g(value); const or = (f, g) => (value) => f(value) || g(value); export const isInteger = isNewType((n) => Number.isInteger(n)); export const isZero = isNewType((x) => x === 0); export const isNonZero = isNewType((x) => x !== 0); const _isNonZeroInteger = and(isNonZero, isInteger); export const isNonZeroInteger = isNewType((x) => _isNonZeroInteger(x)); export const isPositive = isNewType((x) => x > 0); export const isNegative = isNewType((x) => x < 0); const _isNonNegative = or(isZero, isPositive); export const isNonNegative = isNewType((x) => _isNonNegative(x)); const _isNonPositive = or(isZero, isNegative); export const isNonPositive = isNewType((n) => _isNonPositive(n)); const _isPositiveInteger = and(isInteger, isPositive); export const isPositiveInteger = isNewType((n) => _isPositiveInteger(n)); const _isNegativeInteger = and(isNegative, isInteger); export const isNegativeInteger = isNewType((n) => _isNegativeInteger(n)); const _isNonNegativeInteger = or(isZero, isPositiveInteger); export const isNonNegativeInteger = isNewType((n) => _isNonNegativeInteger(n)); const _isNonPositiveInteger = or(isZero, isNegativeInteger); export const isNonPositiveInteger = isNewType((n) => _isNonPositiveInteger(n)); export const isEmptyString = isNewType((x) => x === ''); export const isNonEmptyString = isNewType((x) => x !== ''); export const isCharacter = isNewType((x) => x.length === 1); //# sourceMappingURL=new-types.js.map