Skip to content

Commit a234c35

Browse files
authored
Merge pull request #8 from traversable/eq-complete
housekeeping, prep work for separating `schema-core` from extensions, helpers
2 parents bfa6d9a + b95cfef commit a234c35

File tree

7 files changed

+37
-35
lines changed

7 files changed

+37
-35
lines changed

.changeset/fluffy-mirrors-open.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@traversable/schema-zod-adapter": patch
3+
"@traversable/schema": patch
4+
---
5+
6+
chore(schema,zod): prep work for breaking out `schema-core`

packages/schema-zod-adapter/src/exports.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export {
55
fromConstantToSchemaString,
66
toString,
77
} from './functor.js'
8+
export * as Print from './print.js'

packages/schema-zod-adapter/src/functor.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { z } from 'zod'
33
import type * as T from '@traversable/registry'
44
import { fn, has, parseKey } from '@traversable/registry'
55
import { Json } from '@traversable/json'
6+
import * as Print from './print.js'
67

78
export {
89
toString,
@@ -393,39 +394,6 @@ const DepthFunctor: T.IndexedFunctor<number, Json.Free> = {
393394
}
394395
}
395396

396-
declare namespace Print {
397-
export interface Options {
398-
indent?: number
399-
separator?: string
400-
}
401-
}
402-
403-
namespace Print {
404-
export const defaults = {
405-
indent: 0,
406-
separator: "",
407-
} as const satisfies Required<Options>
408-
409-
export const pad = ({ indent = defaults.indent }: Options) => " ".repeat(indent)
410-
export const tab = ({ indent = defaults.indent }: Options) => " ".repeat(indent + 2)
411-
export const newline = ({ indent = defaults.indent }: Options, count = 0) => "\n" + " ".repeat(indent + (2 * (count + 1)))
412-
413-
export function lines($?: Options):
414-
<L extends string, const Body extends string[], R extends string>(left: L, ...body: [...Body, R])
415-
=> `${L}${string}${R}`
416-
export function lines($: Options = defaults) {
417-
return (...args: [string, ...string[], string]) => {
418-
const [left, body, right] = [args.at(0), args.slice(1, -1), args.at(-1)]
419-
return ""
420-
+ left
421-
+ [body.map((_) => newline($) + _).join(",")].join("," + newline($, -1))
422-
+ newline($, -1)
423-
+ right
424-
}
425-
}
426-
427-
}
428-
429397
namespace Algebra {
430398
export const toString: T.Functor.Algebra<Z.Free, string> = (x) => {
431399
switch (true) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export interface Options {
2+
indent?: number
3+
separator?: string
4+
}
5+
6+
export const defaults = {
7+
indent: 0,
8+
separator: "",
9+
} as const satisfies Required<Options>
10+
11+
export const pad = ({ indent = defaults.indent }: Options) => " ".repeat(indent)
12+
export const tab = ({ indent = defaults.indent }: Options) => " ".repeat(indent + 2)
13+
export const newline = ({ indent = defaults.indent }: Options, count = 0) => "\n" + " ".repeat(indent + (2 * (count + 1)))
14+
15+
export function lines($?: Options):
16+
<L extends string, const Body extends string[], R extends string>(left: L, ...body: [...Body, R])
17+
=> `${L}${string}${R}`
18+
export function lines($: Options = defaults) {
19+
return (...args: [string, ...string[], string]) => {
20+
const [left, body, right] = [args.at(0), args.slice(1, -1), args.at(-1)]
21+
return ""
22+
+ left
23+
+ [body.map((_) => newline($) + _).join(",")].join("," + newline($, -1))
24+
+ newline($, -1)
25+
+ right
26+
}
27+
}

packages/schema/src/ast.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * as AST from './_internal.js'
1+
export * as AST from './_ast.js'

packages/schema/src/predicates.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Predicate } from './types.js'
22
import type { Force, Intersect } from '@traversable/registry'
33
import { symbol as Symbol, URI } from '@traversable/registry'
4-
import type * as AST from './_internal.js'
4+
import type * as AST from './_ast.js'
55
import type { SchemaOptions } from './options.js'
66

77
export {

0 commit comments

Comments
 (0)