feat: Attempt step one per roadmap
This commit is contained in:
parent
4db2d968e4
commit
5618725276
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*~
|
@ -3,14 +3,20 @@
|
|||||||
version: '0.0.0',
|
version: '0.0.0',
|
||||||
description: 'Proof of concepts for a PocoMath-adjacent approach to a possible math.ts (TypeScript analogue of mathjs)',
|
description: 'Proof of concepts for a PocoMath-adjacent approach to a possible math.ts (TypeScript analogue of mathjs)',
|
||||||
main: 'index.js',
|
main: 'index.js',
|
||||||
'scripts': {
|
scripts: {
|
||||||
test: 'echo "Error: no test specified" && exit 1'
|
test: 'echo "Error: no test specified" && exit 1',
|
||||||
},
|
},
|
||||||
keywords: ['math', 'typescript'],
|
keywords: [
|
||||||
|
'math',
|
||||||
|
'typescript',
|
||||||
|
],
|
||||||
repository: {
|
repository: {
|
||||||
type: 'git',
|
type: 'git',
|
||||||
url: 'https://code.studioinfinity.org/glen/typomath.git',
|
url: 'https://code.studioinfinity.org/glen/typomath.git',
|
||||||
},
|
},
|
||||||
author: 'Glen Whitney',
|
author: 'Glen Whitney',
|
||||||
license: 'Apache-2.0'
|
license: 'Apache-2.0',
|
||||||
|
dependencies: {
|
||||||
|
'over.ts': 'github:m93a/over.ts',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
15
pnpm-lock.yaml
Normal file
15
pnpm-lock.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
lockfileVersion: 5.4
|
||||||
|
|
||||||
|
specifiers:
|
||||||
|
over.ts: github:m93a/over.ts
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
over.ts: github.com/m93a/over.ts/0fd6e18afd4ca5a23c9e09d1fcd6b7357b642247
|
||||||
|
|
||||||
|
packages:
|
||||||
|
|
||||||
|
github.com/m93a/over.ts/0fd6e18afd4ca5a23c9e09d1fcd6b7357b642247:
|
||||||
|
resolution: {tarball: https://codeload.github.com/m93a/over.ts/tar.gz/0fd6e18afd4ca5a23c9e09d1fcd6b7357b642247}
|
||||||
|
name: over.ts
|
||||||
|
version: 0.0.0
|
||||||
|
dev: false
|
22
src/steps/one.ts
Normal file
22
src/steps/one.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import { useTypes } from 'over';
|
||||||
|
|
||||||
|
const types = {
|
||||||
|
number: (x: unknown): x is number => typeof x === 'number',
|
||||||
|
bigint: (x: unknown): x is bigint => typeof x === 'bigint'
|
||||||
|
}
|
||||||
|
|
||||||
|
const overload = useTypes(types)
|
||||||
|
|
||||||
|
const add = overload({
|
||||||
|
'number,number -> number': (a,b) => {
|
||||||
|
console.log('Adding numbers', a, b)
|
||||||
|
return a+b
|
||||||
|
},
|
||||||
|
'bigint,bigint -> bigint': (a,b) => {
|
||||||
|
console.log('Adding bigints', a, b)
|
||||||
|
return a+b
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log('Sum of 5 and 7 is', add(5,7))
|
||||||
|
console.log('Sum of 5n and 7n is', add(5n, 7n))
|
Loading…
Reference in New Issue
Block a user