Skip to content

Commit

Permalink
Merge branch 'next' into feat-user-friendly-param-type
Browse files Browse the repository at this point in the history
  • Loading branch information
usualoma committed May 24, 2024
2 parents 79357f6 + 22a6519 commit b934b46
Show file tree
Hide file tree
Showing 242 changed files with 3,283 additions and 14,952 deletions.
1 change: 0 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

- [ ] Add tests
- [ ] Run tests
- [ ] `bun denoify` to generate files for Deno
- [ ] `bun run format:fix && bun run lint:fix` to format the code
20 changes: 5 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,15 @@ jobs:
- run: bun run build
- run: bun run test

denoify:
name: "Checking if you've done denoify"
jsr-dry-run:
name: "Checking if it's valid for JSR"
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18.x'
- uses: oven-sh/setup-bun@v1
- uses: denoland/setup-deno@v1
with:
bun-version: '1.0.25'
- run: bun install
- run: |
bun run denoify
if [[ `git status --porcelain` ]]; then
exit 1
fi
deno-version: v1.x
- run: deno publish --dry-run

deno:
name: 'Deno'
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: ci

on: [push]

jobs:
deno:
name: publish-to-jsr
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v4

- name: Install deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x

- name: Publish to JSR
run: deno run -A jsr:@david/publish-on-tag@0.1.3
54 changes: 50 additions & 4 deletions benchmarks/utils/src/get-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,61 @@ bench('noop', () => {})
const request = new Request('http://localhost/about/me')

group('getPath', () => {
bench('slice + indexOf', () => {
bench('slice + indexOf : w/o decodeURI', () => {
const url = request.url
const queryIndex = url.indexOf('?', 8)
url.slice(url.indexOf('/', 8), queryIndex === -1 ? undefined : queryIndex)
return url.slice(url.indexOf('/', 8), queryIndex === -1 ? undefined : queryIndex)
})

bench('regexp', () => {
bench('regexp : w/o decodeURI', () => {
const match = request.url.match(/^https?:\/\/[^/]+(\/[^?]*)/)
match ? match[1] : ''
return match ? match[1] : ''
})

bench('slice + indexOf', () => {
const url = request.url
const queryIndex = url.indexOf('?', 8)
const path = url.slice(url.indexOf('/', 8), queryIndex === -1 ? undefined : queryIndex)
return path.includes('%') ? decodeURIComponent(path) : path
})

bench('slice + for-loop + flag', () => {
const url = request.url
let start = url.indexOf('/', 8)
let i = start
let hasPercentEncoding = false
for (; i < url.length; i++) {
const charCode = url.charCodeAt(i)
if (charCode === 37) {
// '%'
hasPercentEncoding = true
} else if (charCode === 63) {
// '?'
break
}
}
return hasPercentEncoding ? decodeURIComponent(url.slice(start, i)) : url.slice(start, i)
})

bench('slice + for-loop + immediate return', () => {
const url = request.url
const start = url.indexOf('/', 8)
let i = start
for (; i < url.length; i++) {
const charCode = url.charCodeAt(i)
if (charCode === 37) {
// '%'
// If the path contains percent encoding, use `indexOf()` to find '?' and return the result immediately.
// Although this is a performance disadvantage, it is acceptable since we prefer cases that do not include percent encoding.
const queryIndex = url.indexOf('?', i)
const path = url.slice(start, queryIndex === -1 ? undefined : queryIndex)
return decodeURI(path.includes('%25') ? path.replace(/%25/g, '%2525') : path)
} else if (charCode === 63) {
// '?'
break
}
}
return url.slice(start, i)
})
})

Expand Down
Binary file modified bun.lockb
Binary file not shown.
21 changes: 0 additions & 21 deletions deno_dist/LICENSE

This file was deleted.

92 changes: 0 additions & 92 deletions deno_dist/README.md

This file was deleted.

24 changes: 0 additions & 24 deletions deno_dist/adapter/deno/deno.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions deno_dist/adapter/deno/index.ts

This file was deleted.

32 changes: 0 additions & 32 deletions deno_dist/adapter/deno/serve-static.ts

This file was deleted.

27 changes: 0 additions & 27 deletions deno_dist/adapter/deno/ssg.ts

This file was deleted.

30 changes: 0 additions & 30 deletions deno_dist/adapter/deno/websocket.ts

This file was deleted.

17 changes: 0 additions & 17 deletions deno_dist/adapter/netlify/handler.ts

This file was deleted.

1 change: 0 additions & 1 deletion deno_dist/adapter/netlify/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions deno_dist/adapter/netlify/mod.ts

This file was deleted.

Loading

0 comments on commit b934b46

Please sign in to comment.