-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: optimize object types, split up tests (#1131)
- Loading branch information
1 parent
cda8376
commit 24df831
Showing
72 changed files
with
2,121 additions
and
1,333 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
import { type } from "arktype" | ||
|
||
const oneTo9999 = type("1 <= number.integer <= 9999") | ||
|
||
const T = type({ | ||
PORT: ["string.integer.parse", "=>", oneTo9999] | ||
export const cloudinaryResource = type({ | ||
"[string]": "unknown", | ||
"alt?": "string", | ||
"caption?": "string" | ||
}) | ||
const defaults: typeof T.infer = { | ||
PORT: 123 | ||
} | ||
|
||
process.env.PORT = "456" | ||
|
||
const out = T.assert(process.env) | ||
|
||
console.log(out.PORT) | ||
const user = type({ | ||
name: "string", | ||
device: { | ||
platform: "'android' | 'ios'", | ||
"version?": "number | string" | ||
} | ||
}) | ||
|
||
export const _assetOptionsSchema = type({ | ||
"assetType?": type("string") | ||
.default("image") | ||
.configure({ | ||
text: "Uses Generative Fill to extended padded image with AI", | ||
url: "https://cloudinary.com/documentation/transformation_reference#g_gravity" | ||
} as ArkEnv.meta) | ||
// ---cut--- | ||
user.extends("object") // true | ||
user.extends("string") // false | ||
// true (string is narrower than unknown) | ||
user.extends({ | ||
name: "unknown" | ||
}) | ||
// false (string is wider than "Alan") | ||
user.extends({ | ||
name: "'Alan'" | ||
}) |
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
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
Oops, something went wrong.