Skip to content

Commit

Permalink
better example + API.md (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihei committed Feb 10, 2018
1 parent a36e82f commit 9772fe8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 31 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ npm install avro-crc64
```

## Documentation
- API (tbd)
- [API](docs/API.md)

## Examples

One can find this example in the /examples folder.

```js
/* example 1 */
const { fingerprint64AvroSchema } = require('../src');
const { fingerprint64AvroSchema } = require('avro-crc64');

const avroSchemaExample = {
type: 'record',
Expand All @@ -36,9 +33,8 @@ const avroSchemaExample = {

fingerprint64AvroSchema(JSON.stringify(avroSchemaExample))
.then((uint8) => {
const hexFingerprint = Buffer.from(uint8).toString('hex');
const hexFingerprint = Buffer.from(uint8.buffer).toString('hex');

return console.log(hexFingerprint); // logs "b75d6f7da238cf70"
})
;
```
;```
15 changes: 15 additions & 0 deletions docs/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# avro-crc64 API

## fingerprint64AvroSchema(schemaString: string): Promise<Uint8Array>
fingerprint64AvroSchema returns a promise which resolves to a Rabin 64-bit crc fingerprint as 8 byte [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).

### Parameters
- schemaString<string>: [Apache AVRO](https://avro.apache.org/docs/current/) schema in string representation

### Returns
- Promise<Uint8Array>: 64-bit fingerprint

### Errors
The returned promise will reject with:
- AvroSchemaStringSyntaxError<Error>: In case parsing of schemaString fails with a SytaxError Exception
- InvalidAvroSchemaError<Error>: In case a [AVSC](https://github.com/mtth/avsc) AVRO Type could not be instantiated with parsed schemaString object.
23 changes: 0 additions & 23 deletions examples/example1.js

This file was deleted.

0 comments on commit 9772fe8

Please sign in to comment.