diff --git a/README.md b/README.md index 567d4e8..b0cd86d 100644 --- a/README.md +++ b/README.md @@ -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? diff --git a/rollup.config.js b/rollup.config.js index ecdd699..029dd90 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -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'), diff --git a/src/sdbm.js b/src/sdbm.js index 9d7dcc3..c35de69 100644 --- a/src/sdbm.js +++ b/src/sdbm.js @@ -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 } diff --git a/tests/djb2.test.js b/tests/djb2.test.js index 44c8d10..3e03486 100644 --- a/tests/djb2.test.js +++ b/tests/djb2.test.js @@ -3,7 +3,7 @@ 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', () => { @@ -11,7 +11,7 @@ test('long hash', () => { 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' ) })