Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: convert to typescript #5

Merged
merged 7 commits into from Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions README.md
Expand Up @@ -52,8 +52,8 @@
### Example

```javascript
const { createHAMT } = require('hamt-sharding')
const crypto = require('crypto-promise')
import { createHAMT } from 'hamt-sharding'
import crypto from 'crypto-promise'

// decide how to hash buffers made from keys, can return a Promise
const hashFn = async (buf) => {
Expand All @@ -76,13 +76,13 @@ const output = await bucket.get('key')
## API

```javascript
const { createHAMT } = require('hamt-sharding')
import { createHAMT } from 'hamt-sharding'
```

### `bucket.put(key, value)`

```javascript
const { createHAMT } = require('hamt-sharding')
import { createHAMT } from 'hamt-sharding'
const bucket = createHAMT({...})

await bucket.put('key', 'value')
Expand All @@ -91,7 +91,7 @@ await bucket.put('key', 'value')
### `bucket.get(key)`

```javascript
const { createHAMT } = require('hamt-sharding')
import { createHAMT } from 'hamt-sharding'
const bucket = createHAMT({...})

await bucket.put('key', 'value')
Expand All @@ -102,7 +102,7 @@ console.info(await bucket.get('key')) // 'value'
### `bucket.del(key)`

```javascript
const { createHAMT } = require('hamt-sharding')
import { createHAMT } from 'hamt-sharding'
const bucket = createHAMT({...})

await bucket.put('key', 'value')
Expand All @@ -114,7 +114,7 @@ console.info(await bucket.get('key')) // undefined
### `bucket.leafCount()`

```javascript
const { createHAMT } = require('hamt-sharding')
import { createHAMT } from 'hamt-sharding'
const bucket = createHAMT({...})

console.info(bucket.leafCount()) // 0
Expand All @@ -127,7 +127,7 @@ console.info(bucket.leafCount()) // 1
### `bucket.childrenCount()`

```javascript
const { createHAMT } = require('hamt-sharding')
import { createHAMT } from 'hamt-sharding'
const bucket = createHAMT({...})

console.info(bucket.childrenCount()) // 0
Expand All @@ -141,7 +141,7 @@ console.info(bucket.childrenCount()) // 234 -- dependent on hashing algorithm
### `bucket.eachLeafSeries()`

```javascript
const { createHAMT } = require('hamt-sharding')
import { createHAMT } from 'hamt-sharding'
const bucket = createHAMT({...})

await bucket.put('key', 'value')
Expand Down
23 changes: 18 additions & 5 deletions package.json
Expand Up @@ -3,15 +3,18 @@
"version": "2.0.1",
"description": "JavaScript implementation of sharding using hash array mapped tries",
"leadMaintainer": "Alex Potsides <alex.potsides@protocol.ai>",
"main": "src/index.js",
"main": "dist/src/index.js",
"type": "module",
"scripts": {
"test": "aegir test",
"prepare": "aegir build --no-bundle",
"pretest": "npm run build",
"test": "aegir test -f ./dist/test/*.js",
"prepare": "npm run build",
"lint": "aegir ts -p check && aegir lint",
"release": "aegir release",
"release-minor": "aegir release --type minor",
"release-major": "aegir release --type major",
"coverage": "aegir coverage"
"coverage": "aegir coverage",
"build": "tsc"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -44,5 +47,15 @@
"contributors": [
"achingbrain <alex@achingbrain.net>"
],
"types": "dist/src/index.d.ts"
"typesVersions": {
"*": {
"src/*": [
"dist/src/*",
"dist/src/*/index"
]
}
},
"files": [
"dist/src"
]
}