Skip to content

Commit

Permalink
feat: author package with deno
Browse files Browse the repository at this point in the history
  • Loading branch information
maraisr committed Mar 30, 2024
1 parent cfc0c8c commit 98f1476
Show file tree
Hide file tree
Showing 27 changed files with 1,196 additions and 934 deletions.
49 changes: 20 additions & 29 deletions .github/workflows/ci.yml
Expand Up @@ -2,42 +2,33 @@ name: CI

on:
push:
branches: [main]
pull_request: {}
workflow_call:

jobs:
test:
name: Node.js v${{ matrix.node }}
deno:
runs-on: ubuntu-latest
strategy:
matrix:
node: [16, 18, 20]
steps:
- uses: actions/checkout@main
- uses: actions/checkout@v3

- name: (env) setup node v${{ matrix.node }}
uses: actions/setup-node@main
- uses: denoland/setup-deno@v1
with:
node-version: ${{ matrix.node }}
check-latest: true
deno-version: v1.x

- name: (env) setup bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.0.0
- run: deno fmt --check
- run: deno lint
- run: deno check **/*.ts

- name: (env) cache
uses: actions/cache@v3
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-${{ matrix.node }}-${{ hashFiles('**/package.json') }}
restore-keys: ${{ runner.os }}-${{ matrix.node }}-
- name: Tests
run: |-
deno test --coverage=cov/
deno coverage cov/
- name: (env) globals
run: bun add -g oxlint
npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- run: bun install
- run: oxlint .
- run: bun run build
- run: bun run typecheck
- run: npm run test
- run: deno task build
20 changes: 4 additions & 16 deletions .gitignore
@@ -1,17 +1,5 @@
node_modules
.DS_Store
*-lock.json
*.lock
*.log

/coverage
/.nyc_output

# Editors
*.iml
/.idea
/.vscode

# Code
/index.*
/cache.*
node_modules
/npm
*.lcov
/cov
7 changes: 0 additions & 7 deletions .prettierignore

This file was deleted.

Empty file added bench/deno.json
Empty file.
38 changes: 38 additions & 0 deletions bench/deno.lock
@@ -0,0 +1,38 @@
{
"version": "3",
"packages": {
"specifiers": {
"jsr:@mr/object-identity": "jsr:@mr/object-identity@0.1.2",
"npm:@marais/bench": "npm:@marais/bench@0.0.8",
"npm:dataloader": "npm:dataloader@2.2.2"
},
"jsr": {
"@mr/object-identity@0.1.2": {
"integrity": "18e50582c702c0f532dc9eb3cd93549cc0574522312786355adba9061f4fc7ce"
}
},
"npm": {
"@marais/bench@0.0.8": {
"integrity": "sha512-DZ3TqK1eUN77E2nV2Aj2aady61rveJGqGAPNQglzoJL001HJq9elFLRS6pw25e6geIEmRld9cJ5F/EHFUYa+DQ==",
"dependencies": {
"@thi.ng/bench": "@thi.ng/bench@3.5.1"
}
},
"@thi.ng/api@8.9.31": {
"integrity": "sha512-YuodNQ4TnxV8OIa8xiF9JQ+vBam16W3Z9EbTAAgX/VlQUQ7NEVBbFO8eNGcpyrfOoWdSX4b9JcPbAXuB1dfg1g==",
"dependencies": {}
},
"@thi.ng/bench@3.5.1": {
"integrity": "sha512-ekueeRFmWdXiCB9vnZxzOXKJ9s6ol3injV79hHZXrL+XqjPiP9VyX4fnVvQ/vTCzR27+wYM8fbz3S1veUEF84w==",
"dependencies": {
"@thi.ng/api": "@thi.ng/api@8.9.31"
}
},
"dataloader@2.2.2": {
"integrity": "sha512-8YnDaaf7N3k/q5HnTJVuzSyLETjoZjVmHc4AeKAzOvKHEFQKcn64OKBfzHYtE9zGjctNM7V9I0MfnUVLpi7M5g==",
"dependencies": {}
}
}
},
"remote": {}
}
40 changes: 0 additions & 40 deletions bench/index.js

This file was deleted.

43 changes: 43 additions & 0 deletions bench/index.ts
@@ -0,0 +1,43 @@
import { suite } from 'npm:@marais/bench';
import DataLoader from 'npm:dataloader';
import * as dldr from '../mod.ts';
import * as dldrCache from '../cache/mod.ts';

const loadFn: dldr.LoadFn<any, string> = async (keys: string[]) => Promise.resolve(keys);

await suite<any[]>(
{
dldr: () => {
return (keys) => Promise.all(keys.map((key) => dldr.load(loadFn, key)));
},
'dldr/cache': () => {
const cache = new Map();
return (keys) =>
Promise.all(
keys.map((key) => dldrCache.load(loadFn, cache, key)),
);
},
dataloader: () => {
const loader = new DataLoader(loadFn as any, {
cache: false,
});

return (keys) => loader.loadMany(keys);
},
'dataloader/cache': () => {
const loader = new DataLoader(loadFn as any, {
cache: true,
});

return (keys) => loader.loadMany(keys);
},
},
(run) => {
const keys = ['a', 'b', 'c', 'a'];
run(
undefined,
() => keys,
(results) => results.every((result, i) => result === keys[i]),
);
},
);
8 changes: 0 additions & 8 deletions bench/package.json

This file was deleted.

51 changes: 0 additions & 51 deletions bench/pnpm-lock.yaml

This file was deleted.

Binary file removed bun.lockb
Binary file not shown.

0 comments on commit 98f1476

Please sign in to comment.