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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 0 additions & 40 deletions bench/index.js

This file was deleted.

43 changes: 43 additions & 0 deletions bench/index.ts
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit 98f1476

Please sign in to comment.