setup repo and add unit tests
This commit is contained in:
14
README.md
14
README.md
@@ -21,22 +21,24 @@ type result = Pipe<
|
||||
## TODO
|
||||
|
||||
- [ ] Composition
|
||||
- [ ] Pipe
|
||||
- [ ] Compose
|
||||
- [x] Pipe
|
||||
- [x] PipeRight
|
||||
- [x] Call
|
||||
- [x] Apply
|
||||
- [ ] Tuples
|
||||
- [ ] Head
|
||||
- [ ] Tail
|
||||
- [ ] Map
|
||||
- [ ] FlatMap
|
||||
- [ ] Filter
|
||||
- [ ] Reduce
|
||||
- [ ] Find
|
||||
- [ ] Zip
|
||||
- [ ] Partition
|
||||
- [ ] Drop n
|
||||
- [ ] Take n
|
||||
- [ ] TakeWhile
|
||||
- [ ] Join separator
|
||||
- [x] Join separator
|
||||
- [x] Map
|
||||
- [x] Filter
|
||||
- [x] Reduce
|
||||
- [ ] Object
|
||||
- [ ] Assign
|
||||
- [ ] FromEntries
|
||||
|
||||
4
jest.config.cjs
Normal file
4
jest.config.cjs
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "node",
|
||||
};
|
||||
4591
package-lock.json
generated
4591
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
43
package.json
43
package.json
@@ -1,24 +1,51 @@
|
||||
{
|
||||
"name": "hotscript",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"description": "Type-level madness",
|
||||
"type": "module",
|
||||
"source": "src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.module.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"default": "./dist/index.modern.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"types": "dist/index.d.ts",
|
||||
"module": "./dist/index.module.js",
|
||||
"unpkg": "./dist/index.umd.js",
|
||||
"scripts": {
|
||||
"build": "microbundle",
|
||||
"dev": "microbundle watch",
|
||||
"prepublishOnly": "npm run test && npm run build",
|
||||
"test": "jest",
|
||||
"clear-test": "jest --clearCache",
|
||||
"perf": "tsc --project tests/tsconfig.json --noEmit --extendedDiagnostics",
|
||||
"fmt": "prettier ./src/** ./tests/** -w",
|
||||
"check": "tsc --strict --noEmit --extendedDiagnostics"
|
||||
},
|
||||
"files": [
|
||||
"dist/**/*"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/gvergnaud/PipeScript.git"
|
||||
"url": "git+https://github.com/gvergnaud/HOTScript.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/gvergnaud/PipeScript/issues"
|
||||
"url": "https://github.com/gvergnaud/HOTScript/issues"
|
||||
},
|
||||
"homepage": "https://github.com/gvergnaud/PipeScript#readme",
|
||||
"homepage": "https://github.com/gvergnaud/HOTScript#readme",
|
||||
"author": "Gabriel Vergnaud",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^29.4.0",
|
||||
"jest": "^29.4.2",
|
||||
"microbundle": "^0.15.1",
|
||||
"prettier": "^2.8.4",
|
||||
"ts-jest": "^29.0.5",
|
||||
"typescript": "^4.9.5"
|
||||
}
|
||||
}
|
||||
|
||||
1
src/index.ts
Normal file
1
src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./HOTScript";
|
||||
@@ -1,9 +1,9 @@
|
||||
import { HOT, Numbers, Strings, Tuples } from "../HOTScript";
|
||||
import { HOT, Numbers, Strings, Tuples } from "../src";
|
||||
import { Equal, Expect } from "./helpers";
|
||||
|
||||
describe("HOTScript", () => {
|
||||
describe("Composition", () => {
|
||||
describe("Pipe", () => {
|
||||
it("Pipe", () => {
|
||||
type res1 = HOT.Pipe<
|
||||
// ^?
|
||||
[1, 2, 3, 4, 3, 4],
|
||||
@@ -20,7 +20,7 @@ describe("HOTScript", () => {
|
||||
type tes1 = Expect<Equal<res1, 78>>;
|
||||
});
|
||||
|
||||
describe("PipeRight", () => {
|
||||
it("PipeRight", () => {
|
||||
type res1 = HOT.PipeRight<
|
||||
// ^?
|
||||
[
|
||||
@@ -39,7 +39,7 @@ describe("HOTScript", () => {
|
||||
});
|
||||
|
||||
describe("Tuples", () => {
|
||||
describe("Map", () => {
|
||||
it("Map", () => {
|
||||
interface ToPhrase extends HOT.Fn {
|
||||
output: `number is ${Extract<
|
||||
this["args"][0],
|
||||
@@ -53,5 +53,27 @@ describe("HOTScript", () => {
|
||||
Equal<res1, ["number is 1", "number is 2", "number is 3"]>
|
||||
>;
|
||||
});
|
||||
|
||||
it("Filter", () => {
|
||||
interface IsNumber extends HOT.Fn {
|
||||
output: this["args"][0] extends number ? true : false;
|
||||
}
|
||||
|
||||
type res1 = HOT.Call<Tuples.Filter<IsNumber>, [1, 2, "oops", 3]>;
|
||||
// ^?
|
||||
type tes1 = Expect<Equal<res1, [1, 2, 3]>>;
|
||||
});
|
||||
|
||||
it("Reduce", () => {
|
||||
interface ToUnaryTupleArray extends HOT.Fn {
|
||||
output: this["args"] extends [infer acc extends any[], infer item]
|
||||
? [...acc, [item]]
|
||||
: never;
|
||||
}
|
||||
|
||||
type res1 = HOT.Call<Tuples.Reduce<[], ToUnaryTupleArray>, [1, 2, 3]>;
|
||||
// ^?
|
||||
type tes1 = Expect<Equal<res1, [[1], [2], [3]]>>;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
11
test/tsconfig.json
Normal file
11
test/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"strict": true,
|
||||
"downlevelIteration": true,
|
||||
"noEmit": true,
|
||||
"target": "ES2020",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"exclude": ["src/", "dist/", "example/"]
|
||||
}
|
||||
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"declaration": true,
|
||||
"target": "ESNext",
|
||||
"strict": true,
|
||||
"outDir": "dist/"
|
||||
},
|
||||
"include": ["src/"],
|
||||
"exclude": ["tests/", "dist/", "examples/"]
|
||||
}
|
||||
Reference in New Issue
Block a user