-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f6b185
commit 8088101
Showing
7 changed files
with
181 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
export function justMeta(schema) { | ||
const something = schema.meta; | ||
return something; | ||
import { object } from './object.js'; | ||
import { objMapEntries } from './utils.js'; | ||
export function justMeta(insure) { | ||
// object.getMeta(insure) -> if not object -> null | ||
object; | ||
// @ts-expect-error more explicit? | ||
if (insure.meta?.type === 'object') { | ||
const { schema, ...rest } = insure.meta; | ||
const ret = objMapEntries(schema, ([key, value]) => { | ||
return [key, justMeta(value)]; | ||
}); | ||
return { schema: ret, ...rest }; | ||
} | ||
// @ts-expect-error more explicit? | ||
if (insure.meta?.type === 'optional') { | ||
const { schema, ...rest } = insure.meta; | ||
return { | ||
schema: justMeta(schema), | ||
...rest, | ||
}; | ||
} | ||
// @ts-expect-error more explicit? | ||
if (insure.meta?.type === 'array') { | ||
const { schema, ...rest } = insure.meta; | ||
return { | ||
schema: justMeta(schema), | ||
...rest, | ||
}; | ||
} | ||
if (insure.meta) { | ||
return insure.meta; | ||
} | ||
return 'unknown'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
export {}; | ||
/** | ||
* Check source. | ||
* Maps over an object using `Object.entries` and returns a new object. | ||
*/ | ||
export function objMapEntries(value, callback) { | ||
// @ts-expect-error We expect an error here | ||
return Object.fromEntries(Object.entries(value).map(callback)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters