Skip to content

Commit

Permalink
refactor: rename files from .ts to .mts
Browse files Browse the repository at this point in the history
  • Loading branch information
gjbkz committed Aug 31, 2023
1 parent c684d07 commit 946436e
Show file tree
Hide file tree
Showing 113 changed files with 312 additions and 307 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"overrides": [
{
"files": [
"*.test.ts"
"*.test.mts"
],
"plugins": [
"jest"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/cacheResult.private.ts → src/cacheResult.private.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const cacheResult = <T>(fn: () => T): (() => T) => {
export const cacheResult = <T,>(fn: () => T): (() => T) => {
let cached: { value: T } | undefined;
return () => {
if (cached) {
Expand Down
8 changes: 4 additions & 4 deletions src/cloneDefinition.ts → src/cloneDefinition.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import {
isDefinitionCandidates,
isDefinitionConditions,
isDefinitionEnum,
} from './definition.private';
} from './definition.private.mjs';
import {
DefinitionCandidates,
DefinitionConditions,
DefinitionEnum,
} from './generics';
import type { DefinitionObject, TypeGuard } from './generics';
import { is$RegExp } from './primitive.private';
} from './generics.mjs';
import type { DefinitionObject, TypeGuard } from './generics.mjs';
import { is$RegExp } from './primitive.private.mjs';

export function cloneDefinition(definition: RegExp): RegExp;
export function cloneDefinition<T>(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/codePoints.test.ts → src/codePoints.test.mts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
listCodePoints,
SPACE,
toSmallLatinCodePoint,
} from './codePoints';
} from './codePoints.mjs';

describe(toSmallLatinCodePoint.name, () => {
const tests: Array<[number, number]> = [
Expand Down
14 changes: 7 additions & 7 deletions src/createTypeChecker.ts → src/createTypeChecker.mts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable func-style */
import { cacheResult } from './cacheResult.private';
import { cloneDefinition } from './cloneDefinition';
import { cacheResult } from './cacheResult.private.mjs';
import { cloneDefinition } from './cloneDefinition.mjs';
import {
arrayDefinitionStore,
dictionaryDefinitionStore,
optionalDefinitionStore,
} from './definition.private';
} from './definition.private.mjs';
import type {
Definition,
DefinitionCandidates,
Expand All @@ -15,15 +15,15 @@ import type {
KeyValuePair,
TypeChecker,
TypeGuard,
} from './generics';
import { ModuleError } from './ModuleError.private';
} from './generics.mjs';
import { ModuleError } from './ModuleError.private.mjs';
import {
is$Array,
is$Object,
is$String,
is$TypeChecker,
} from './primitive.private';
import { testValue } from './testValue';
} from './primitive.private.mjs';
import { testValue } from './testValue.mjs';

const { entries, defineProperties } = Object as {
entries: <T>(object: T) => Array<KeyValuePair<T>>;
Expand Down
12 changes: 6 additions & 6 deletions src/createTypeChecker.test.ts → src/createTypeChecker.test.mts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { isString } from './is/String';
import { createTypeChecker } from './createTypeChecker';
import { definition } from './definition';
import { isNull } from './is/Null';
import { is$String } from './primitive.private';
import { testValue } from './testValue';
import { isString } from './is/String.mjs';
import { createTypeChecker } from './createTypeChecker.mjs';
import { definition } from './definition.mjs';
import { isNull } from './is/Null.mjs';
import { is$String } from './primitive.private.mjs';
import { testValue } from './testValue.mjs';

const catchError = (fn: () => void) => {
try {
Expand Down
14 changes: 8 additions & 6 deletions src/definition.ts → src/definition.mts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {
isDefinitionCandidates,
isDefinitionConditions,
} from './definition.private';
} from './definition.private.mjs';
import {
DefinitionCandidates,
DefinitionConditions,
DefinitionEnum,
} from './generics';
import type { Definition } from './generics';
} from './generics.mjs';
import type { Definition } from './generics.mjs';

export const definition = {
enum: <T>(...values: Array<T>): DefinitionEnum<T> => {
enum: <T,>(...values: Array<T>): DefinitionEnum<T> => {
return new DefinitionEnum<T>(values);
},
some: <T>(...definitions: Array<Definition<T>>): DefinitionCandidates<T> => {
some: <T,>(...definitions: Array<Definition<T>>): DefinitionCandidates<T> => {
const set = new DefinitionCandidates<T>();
for (const d1 of definitions) {
for (const d2 of isDefinitionCandidates(d1) ? [...d1] : [d1]) {
Expand All @@ -22,7 +22,9 @@ export const definition = {
}
return set;
},
every: <T>(...definitions: Array<Definition<T>>): DefinitionConditions<T> => {
every: <T,>(
...definitions: Array<Definition<T>>
): DefinitionConditions<T> => {
const set = new DefinitionConditions<T>();
for (const d1 of definitions) {
for (const d2 of isDefinitionConditions(d1) ? [...d1] : [d1]) {
Expand Down
10 changes: 5 additions & 5 deletions src/definition.private.ts → src/definition.private.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
DefinitionCandidates,
DefinitionConditions,
DefinitionEnum,
} from './generics';
import type { Definition, TypeChecker } from './generics';
} from './generics.mjs';
import type { Definition, TypeChecker } from './generics.mjs';

export const arrayDefinitionStore = new WeakMap<
TypeChecker<unknown>,
Expand All @@ -18,12 +18,12 @@ export const dictionaryDefinitionStore = new WeakMap<
Definition
>();

export const isDefinitionEnum = <T>(
export const isDefinitionEnum = <T,>(
input: Definition<T>,
): input is DefinitionEnum<T> => input instanceof DefinitionEnum;
export const isDefinitionCandidates = <T>(
export const isDefinitionCandidates = <T,>(
input: Definition<T>,
): input is DefinitionCandidates<T> => input instanceof DefinitionCandidates;
export const isDefinitionConditions = <T>(
export const isDefinitionConditions = <T,>(
input: Definition<T>,
): input is DefinitionConditions<T> => input instanceof DefinitionConditions;
12 changes: 6 additions & 6 deletions src/ensure.ts → src/ensure.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ import type {
DefinitionObject,
TypeChecker,
Definition,
} from './generics';
} from './generics.mjs';
import {
isDefinitionEnum,
isDefinitionCandidates,
isDefinitionConditions,
arrayDefinitionStore,
optionalDefinitionStore,
} from './definition.private';
import { stringifyDefinition } from './stringifyDefinition.private';
import { ModuleError } from './ModuleError.private';
} from './definition.private.mjs';
import { stringifyDefinition } from './stringifyDefinition.private.mjs';
import { ModuleError } from './ModuleError.private.mjs';
import {
is$Array,
is$Function,
is$Object,
is$RegExp,
is$String,
is$TypeChecker,
} from './primitive.private';
import { testValue } from './testValue';
} from './primitive.private.mjs';
import { testValue } from './testValue.mjs';

export interface CheckErrorFailedResult {
path: string;
Expand Down
4 changes: 2 additions & 2 deletions src/ensure.test.ts → src/ensure.test.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ensure } from './ensure';
import { isString } from './is/String';
import { ensure } from './ensure.mjs';
import { isString } from './is/String.mjs';

test('throw an error if 3rd is undefined', () => {
const regexp = /^TypeCheckError/;
Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions src/generics.test.ts → src/generics.test.mts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { testValue } from './testValue';
import { createTypeChecker } from './createTypeChecker';
import { testValue } from './testValue.mjs';
import { createTypeChecker } from './createTypeChecker.mjs';
import type {
DefinedType,
GuardedType,
Merge,
Nominal,
TypeGuard,
UndefinedAsOptional,
} from './generics';
import { isPositiveSafeInteger } from './is/PositiveSafeInteger';
import { isString } from './is/String';
import { isNegativeSafeInteger } from './is/NegativeSafeInteger';
import { definition } from './definition';
} from './generics.mjs';
import { isPositiveSafeInteger } from './is/PositiveSafeInteger.mjs';
import { isString } from './is/String.mjs';
import { isNegativeSafeInteger } from './is/NegativeSafeInteger.mjs';
import { definition } from './definition.mjs';

test('UndefinedAsOptional', () => {
interface A1 {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/getType.test.ts → src/getType.test.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getType } from './getType';
import { getType } from './getType.mjs';

const tests: Array<[unknown, string]> = [
[null, 'Null'],
Expand Down
51 changes: 51 additions & 0 deletions src/index.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Generated by @nlib/indexen
export * from './cloneDefinition.mjs';
export * from './codePoints.mjs';
export * from './createTypeChecker.mjs';
export * from './definition.mjs';
export * from './ensure.mjs';
export * from './generics.mjs';
export * from './getType.mjs';
export * from './object.mjs';
export * from './parseIpv4Address.mjs';
export * from './parseIpv6Address.mjs';
export * from './splitString.mjs';
export * from './testValue.mjs';
export * from './is/AlphaNumericString.mjs';
export * from './is/Array.mjs';
export * from './is/Base64String.mjs';
export * from './is/Base64UrlString.mjs';
export * from './is/Boolean.mjs';
export * from './is/CapitalHexString.mjs';
export * from './is/CapitalLatinString.mjs';
export * from './is/DomainName.mjs';
export * from './is/EmailAddress.mjs';
export * from './is/EmailAddressLocalPart.mjs';
export * from './is/FiniteNumber.mjs';
export * from './is/Function.mjs';
export * from './is/HttpMethod.mjs';
export * from './is/HttpResponseStatusCode.mjs';
export * from './is/HttpsUrlString.mjs';
export * from './is/Ipv4Address.mjs';
export * from './is/Ipv6Address.mjs';
export * from './is/LatinString.mjs';
export * from './is/NegativeFiniteNumber.mjs';
export * from './is/NegativeSafeInteger.mjs';
export * from './is/NonNegativeFiniteNumber.mjs';
export * from './is/NonNegativeSafeInteger.mjs';
export * from './is/NonPositiveFiniteNumber.mjs';
export * from './is/NonPositiveSafeInteger.mjs';
export * from './is/Null.mjs';
export * from './is/NumberString.mjs';
export * from './is/Object.mjs';
export * from './is/PositiveFiniteNumber.mjs';
export * from './is/PositiveSafeInteger.mjs';
export * from './is/SafeInteger.mjs';
export * from './is/SmallHexString.mjs';
export * from './is/SmallLatinString.mjs';
export * from './is/String.mjs';
export * from './is/TypedArray.mjs';
export * from './is/UUID.mjs';
export * from './is/Undefined.mjs';
export * from './is/UrlHostString.mjs';
export * from './is/ValidDate.mjs';
51 changes: 0 additions & 51 deletions src/index.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createTypeChecker } from '../createTypeChecker';
import type { Nominal } from '../generics';
import { LatinCharacters } from './LatinString';
import { NumericCharacters } from './NumberString';
import { createTypeChecker } from '../createTypeChecker.mjs';
import type { Nominal } from '../generics.mjs';
import { LatinCharacters } from './LatinString.mjs';
import { NumericCharacters } from './NumberString.mjs';

export const AlphaNumericCharacters = `${LatinCharacters}${NumericCharacters}`;
export type AlphaNumericString = Nominal<string, 'AlphaNumericString'>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { listCheckerTests } from './tests.private';
import { isAlphaNumericString } from './AlphaNumericString';
import { listCheckerTests } from './tests.private.mjs';
import { isAlphaNumericString } from './AlphaNumericString.mjs';

for (const { key, input, expected } of listCheckerTests(
'EmptyString',
Expand Down
4 changes: 4 additions & 0 deletions src/is/Array.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createTypeChecker } from '../createTypeChecker.mjs';
import { is$Array } from '../primitive.private.mjs';

export const isArray = createTypeChecker('Array', is$Array);
4 changes: 2 additions & 2 deletions src/is/Array.test.ts → src/is/Array.test.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { listCheckerTests } from './tests.private';
import { isArray } from './Array';
import { listCheckerTests } from './tests.private.mjs';
import { isArray } from './Array.mjs';

for (const { key, input, expected } of listCheckerTests('EmptyArray')) {
test(`${key}${expected}`, () => {
Expand Down
4 changes: 0 additions & 4 deletions src/is/Array.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/is/Base64String.ts → src/is/Base64String.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createTypeChecker } from '../createTypeChecker';
import type { Nominal } from '../generics';
import { createTypeChecker } from '../createTypeChecker.mjs';
import type { Nominal } from '../generics.mjs';

export type Base64String = Nominal<string, 'Base64String'>;
export const isBase64String = createTypeChecker<Base64String, 'Base64String'>(
Expand Down
4 changes: 2 additions & 2 deletions src/is/Base64String.test.ts → src/is/Base64String.test.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { listCheckerTests } from './tests.private';
import { isBase64String } from './Base64String';
import { listCheckerTests } from './tests.private.mjs';
import { isBase64String } from './Base64String.mjs';

for (const { key, input, expected } of listCheckerTests(
'Base64',
Expand Down
4 changes: 2 additions & 2 deletions src/is/Base64UrlString.ts → src/is/Base64UrlString.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createTypeChecker } from '../createTypeChecker';
import type { Nominal } from '../generics';
import { createTypeChecker } from '../createTypeChecker.mjs';
import type { Nominal } from '../generics.mjs';

export type Base64UrlString = Nominal<string, 'Base64UrlString'>;
export const isBase64UrlString = createTypeChecker<
Expand Down
Loading

0 comments on commit 946436e

Please sign in to comment.