From 06726e91fc092d89166ce9097d992dbac5beaaef Mon Sep 17 00:00:00 2001 From: Sean Sube Date: Sat, 8 Oct 2022 15:44:06 -0500 Subject: [PATCH] fix: replace deprecated utility fns --- src/schema.ts | 6 +++--- src/type/Include.ts | 6 +++--- src/type/Regexp.ts | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/schema.ts b/src/schema.ts index 1a2034c..68d5529 100644 --- a/src/schema.ts +++ b/src/schema.ts @@ -1,4 +1,4 @@ -import { mustCoalesce } from '@apextoaster/js-utils'; +import { mustDefault } from '@apextoaster/js-utils'; import { DEFAULT_SCHEMA, Schema } from 'js-yaml'; import { envType } from './type/Env'; @@ -17,7 +17,7 @@ export interface SchemaOptions { * @public */ export function createSchema(options: SchemaOptions): Schema { - const base = mustCoalesce(options.base, DEFAULT_SCHEMA); + const base = mustDefault(options.base, DEFAULT_SCHEMA); return base.extend([ envType, @@ -43,7 +43,7 @@ export interface IncludeSchemaOptions { * @deprecated use `createSchema` unless the include type is needed, since it requires a number of callbacks */ export function createIncludeSchema(options: Readonly): Schema { - const base = mustCoalesce(options.base, DEFAULT_SCHEMA); + const base = mustDefault(options.base, DEFAULT_SCHEMA); const { includeType, setSchema } = createInclude({ ...options.include, schema: base, diff --git a/src/type/Include.ts b/src/type/Include.ts index 38e94f0..e0246d3 100644 --- a/src/type/Include.ts +++ b/src/type/Include.ts @@ -1,4 +1,4 @@ -import { InvalidArgumentError, mustCoalesce, NotFoundError, Optional } from '@apextoaster/js-utils'; +import { InvalidArgumentError, Maybe, mustDefault, NotFoundError } from '@apextoaster/js-utils'; import { DEFAULT_SCHEMA, load, Schema, Type as YamlType } from 'js-yaml'; export type ReaderEncoding = 'ascii' | 'utf-8'; @@ -18,7 +18,7 @@ export interface IncludeOptions { join: (...path: Array) => string; read: IncludeReader; resolve: (path: string) => string; - schema: Optional; + schema: Maybe; } export interface IncludeResult { @@ -40,7 +40,7 @@ const ERROR_INCLUDE_PARSE = 'error loading included file'; */ export function createInclude(options: Readonly): IncludeResult { const mutableOptions = { - schema: mustCoalesce(options.schema, DEFAULT_SCHEMA), + schema: mustDefault(options.schema, DEFAULT_SCHEMA), }; const includeType = new YamlType('!include', { diff --git a/src/type/Regexp.ts b/src/type/Regexp.ts index 5d578ed..dfcfe2d 100644 --- a/src/type/Regexp.ts +++ b/src/type/Regexp.ts @@ -1,4 +1,4 @@ -import { InvalidArgumentError, isNil } from '@apextoaster/js-utils'; +import { InvalidArgumentError, isNone } from '@apextoaster/js-utils'; import { Type as YamlType } from 'js-yaml'; export const REGEXP_REGEXP = /^\/(.+)\/([gimsuy]*)$/; @@ -13,7 +13,7 @@ export const regexpType = new YamlType('!regexp', { }, construct(value: string): RegExp { const match = REGEXP_REGEXP.exec(value); - if (isNil(match)) { + if (isNone(match)) { throw new InvalidArgumentError('invalid regexp'); } const [/* input */, expr, flags] = Array.from(match);