Skip to content

Commit

Permalink
chore: autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Nov 25, 2023
1 parent dca91fb commit 9b2a488
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

- [Why?](#why)
- [Usage](#usage)
- [dbj2](#dbj2)
- [sdbm](#sdbm)
- [Original Version](#original-version)
- [GAWK Version](#gawk-version)
- [dbj2](#dbj2)
- [sdbm](#sdbm)
- [Original Version](#original-version)
- [GAWK Version](#gawk-version)
- [License](#license)

# Why?
Expand Down
14 changes: 5 additions & 9 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,14 @@ function createPackages() {
name: 'create-final-packages',
async renderStart(info) {
const pkg = {}
if (info.format == 'cjs') {
pkg.type = 'commonjs'
}
if (['esm', 'es'].includes(info.format)) {
pkg.type = 'module'
}
if (info.format == 'cjs') pkg.type = 'commonjs'

if (['esm', 'es'].includes(info.format)) pkg.type = 'module'

const pkgPath = join(info.dir, 'package.json')
await mkdir(info.dir, { recursive: true })

if (existsSync(pkgPath)) {
return
}
if (existsSync(pkgPath)) return

await fs.writeFile(
join(info.dir, 'package.json'),
Expand Down
3 changes: 1 addition & 2 deletions src/sdbm.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ export function sdbm(toHash) {
export function sdbmGawk(toHash) {
let hash = BigInt(0)

for (let i = 0; i < toHash.length; i++) {
for (let i = 0; i < toHash.length; i++)
hash = BigInt(toHash.charCodeAt(i)) + (hash << 6n) + (hash << 16n) - hash
}

return '' + hash
}
4 changes: 2 additions & 2 deletions tests/djb2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import * as assert from 'uvu/assert'
import { djb2 } from '../src/djb2.js'

test('short hash', () => {
assert.equal(djb2('hello'), "261238937")
assert.equal(djb2('hello'), '261238937')
})

test('long hash', () => {
assert.equal(
djb2(
`Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.`
),
"4439231447"
'4439231447'
)
})

Expand Down

0 comments on commit 9b2a488

Please sign in to comment.