-
Notifications
You must be signed in to change notification settings - Fork 163
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
023208a
commit 4daeadf
Showing
25 changed files
with
172 additions
and
39 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 was deleted.
Oops, something went wrong.
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,40 @@ | ||
import { String } from 'typebox' | ||
import { TypeSystem } from '@sinclair/typebox/system' | ||
import { TypeCompiler } from '@sinclair/typebox/compiler' | ||
import { Value, ValuePointer } from '@sinclair/typebox/value' | ||
import { Type, TypeGuard, Kind, Static, TSchema } from '@sinclair/typebox' | ||
|
||
// ----------------------------------------------------------- | ||
// Create: Type | ||
// ----------------------------------------------------------- | ||
|
||
const T = Type.Object({ | ||
x: Type.Number(), | ||
y: Type.Number(), | ||
z: Type.Number(), | ||
}) | ||
|
||
type T = Static<typeof T> | ||
|
||
console.log(T) | ||
|
||
// ----------------------------------------------------------- | ||
// Create: Value | ||
// ----------------------------------------------------------- | ||
|
||
const V = Value.Create(T) | ||
|
||
console.log(V) | ||
|
||
// ----------------------------------------------------------- | ||
// Compile: Type | ||
// ----------------------------------------------------------- | ||
|
||
const C = TypeCompiler.Compile(T) | ||
|
||
console.log(C.Code()) | ||
|
||
// ----------------------------------------------------------- | ||
// Check: Value | ||
// ----------------------------------------------------------- | ||
|
||
console.log(C.Check(V)) |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { shell } from '@sinclair/hammer' | ||
|
||
export async function measurement() { | ||
await shell(`hammer run task/benchmark/measurement/module/index.ts --dist target/benchmark/measurement`) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// ------------------------------------------------------------------ | ||
// CJS-Transform | ||
// ------------------------------------------------------------------ | ||
import * as Path from 'node:path' | ||
import * as Fs from 'node:fs' | ||
|
||
// prettier-ignore | ||
function shouldProcess(sourcePath: string) { | ||
const extname = Path.extname(sourcePath) | ||
return ['.mjs'].includes(extname) | ||
} | ||
// prettier-ignore | ||
function rewriteSpecifiers(contents: string): string { | ||
return contents.replaceAll('.mjs', '') | ||
} | ||
// prettier-ignore | ||
function newExtension(extname: string) { | ||
return extname === '.mjs' ? '.js' : extname | ||
} | ||
// prettier-ignore | ||
function processFile(sourcePath: string) { | ||
if(!shouldProcess(sourcePath)) return | ||
const extname = Path.extname(sourcePath) | ||
const dirname = Path.dirname(sourcePath) | ||
const basename = Path.basename(sourcePath, extname) | ||
const new_extname = newExtension(extname) | ||
const sourceContent = Fs.readFileSync(sourcePath, 'utf-8') | ||
const targetContent = rewriteSpecifiers(sourceContent) | ||
const targetPath = `${Path.join(dirname, basename)}${new_extname}` | ||
Fs.writeFileSync(sourcePath, targetContent) | ||
Fs.renameSync(sourcePath, targetPath) | ||
} | ||
// prettier-ignore | ||
function processSourcePath(sourcePath: string) { | ||
const stat = Fs.statSync(sourcePath) | ||
if(stat.isDirectory()) return readDirectory(sourcePath) | ||
if(stat.isFile()) return processFile(sourcePath) | ||
} | ||
// prettier-ignore | ||
function readDirectory(sourceDirectory: string) { | ||
for(const entry of Fs.readdirSync(sourceDirectory)) { | ||
const sourcePath = Path.join(sourceDirectory, entry) | ||
processSourcePath(sourcePath) | ||
} | ||
} | ||
// prettier-ignore | ||
export function convertToCommonJs(sourceDirectory: string) { | ||
readDirectory(sourceDirectory) | ||
} |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './build' |
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