Comparing version
@@ -1,2 +0,2 @@ | ||
import type { bigintTypeSymbol, booleanTypeSymbol, dateTypeSymbol, neverTypeSymbol, nullTypeSymbol, numberTypeSymbol, regexpTypeSymbol, stringTypeSymbol, undefinedTypeSymbol, unknownTypeSymbol, voidTypeSymbol } from '../types'; | ||
import type { bigintTypeSymbol, booleanTypeSymbol, dateTypeSymbol, functionTypeSymbol, neverTypeSymbol, nullTypeSymbol, numberTypeSymbol, regexpTypeSymbol, stringTypeSymbol, undefinedTypeSymbol, unknownTypeSymbol, voidTypeSymbol } from '../types'; | ||
export interface ECMAScriptTypes { | ||
@@ -12,2 +12,3 @@ [neverTypeSymbol]: never; | ||
[booleanTypeSymbol]: boolean; | ||
[functionTypeSymbol]: Function; | ||
[dateTypeSymbol]: Date; | ||
@@ -14,0 +15,0 @@ [regexpTypeSymbol]: RegExp; |
@@ -13,2 +13,3 @@ declare global { | ||
[booleanTypeSymbol]: boolean; | ||
[functionTypeSymbol]: Function; | ||
[dateTypeSymbol]: Date; | ||
@@ -42,2 +43,4 @@ [regexpTypeSymbol]: RegExp; | ||
export declare const boolean: import("./core").AtomicType<typeof booleanTypeSymbol>; | ||
export declare const functionTypeSymbol: unique symbol; | ||
export declare const Function: import("./core").AtomicType<typeof functionTypeSymbol>; | ||
export declare const dateTypeSymbol: unique symbol; | ||
@@ -44,0 +47,0 @@ export declare const Date: import("./core").AtomicType<typeof dateTypeSymbol>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RegExp = exports.regexpTypeSymbol = exports.Date = exports.dateTypeSymbol = exports.boolean = exports.booleanTypeSymbol = exports.bigint = exports.bigintTypeSymbol = exports.number = exports.numberTypeSymbol = exports.string = exports.stringTypeSymbol = exports.nullType = exports.nullTypeSymbol = exports.void = exports.voidType = exports.voidTypeSymbol = exports.undefined = exports.undefinedTypeSymbol = exports.unknown = exports.unknownTypeSymbol = exports.never = exports.neverTypeSymbol = void 0; | ||
exports.RegExp = exports.regexpTypeSymbol = exports.Date = exports.dateTypeSymbol = exports.Function = exports.functionTypeSymbol = exports.boolean = exports.booleanTypeSymbol = exports.bigint = exports.bigintTypeSymbol = exports.number = exports.numberTypeSymbol = exports.string = exports.stringTypeSymbol = exports.nullType = exports.nullTypeSymbol = exports.void = exports.voidType = exports.voidTypeSymbol = exports.undefined = exports.undefinedTypeSymbol = exports.unknown = exports.unknownTypeSymbol = exports.never = exports.neverTypeSymbol = void 0; | ||
const core_1 = require("./core"); | ||
@@ -12,3 +12,3 @@ const utils_1 = require("./utils"); | ||
exports.unknownTypeSymbol = Symbol(); | ||
exports.unknown = (0, core_1.atomic)(exports.unknownTypeSymbol, () => { }); | ||
exports.unknown = (0, core_1.atomic)(exports.unknownTypeSymbol, []); | ||
exports.undefinedTypeSymbol = Symbol(); | ||
@@ -29,2 +29,4 @@ exports.undefined = (0, core_1.atomic)(exports.undefinedTypeSymbol, value => (0, utils_1.constraint)(value === void 0, () => `Expected undefined, getting ${toString.call(value)}.`)); | ||
exports.boolean = (0, core_1.atomic)(exports.booleanTypeSymbol, value => (0, utils_1.constraint)(typeof value === 'boolean', () => `Expected boolean, getting ${toString.call(value)}.`)); | ||
exports.functionTypeSymbol = Symbol(); | ||
exports.Function = (0, core_1.atomic)(exports.functionTypeSymbol, value => (0, utils_1.constraint)(typeof value === 'function', () => `Expected function, getting ${toString.call(value)}.`)); | ||
exports.dateTypeSymbol = Symbol(); | ||
@@ -31,0 +33,0 @@ exports.Date = (0, core_1.atomic)(exports.dateTypeSymbol, value => (0, utils_1.constraint)(value instanceof globalThis.Date, () => `Expected instance of Date, getting ${toString.call(value)}.`)); |
{ | ||
"name": "x-value", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"repository": "https://github.com/vilic/x-value.git", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -6,2 +6,3 @@ import {atomicTypeSymbol, medium} from '../core'; | ||
dateTypeSymbol, | ||
functionTypeSymbol, | ||
neverTypeSymbol, | ||
@@ -27,2 +28,3 @@ nullTypeSymbol, | ||
[booleanTypeSymbol]: boolean; | ||
[functionTypeSymbol]: Function; | ||
[dateTypeSymbol]: Date; | ||
@@ -29,0 +31,0 @@ [regexpTypeSymbol]: RegExp; |
@@ -18,2 +18,3 @@ import {atomic} from './core'; | ||
[booleanTypeSymbol]: boolean; | ||
[functionTypeSymbol]: Function; | ||
[dateTypeSymbol]: Date; | ||
@@ -37,3 +38,3 @@ [regexpTypeSymbol]: RegExp; | ||
export const unknownTypeSymbol = Symbol(); | ||
export const unknown = atomic(unknownTypeSymbol, () => {}); | ||
export const unknown = atomic(unknownTypeSymbol, []); | ||
@@ -98,2 +99,10 @@ export const undefinedTypeSymbol = Symbol(); | ||
export const functionTypeSymbol = Symbol(); | ||
export const Function = atomic(functionTypeSymbol, value => | ||
constraint( | ||
typeof value === 'function', | ||
() => `Expected function, getting ${toString.call(value)}.`, | ||
), | ||
); | ||
export const dateTypeSymbol = Symbol(); | ||
@@ -100,0 +109,0 @@ export const Date = atomic(dateTypeSymbol, value => |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
266404
0.39%5698
0.28%