Skip to content

Commit

Permalink
[JavaScript] Fill in readme (#1110)
Browse files Browse the repository at this point in the history
* chore: javascript readme

* chore: javascript readme

* Update javascript/README.md

---------

Co-authored-by: Shawn <shawn.ck.yang@gmail.com>
  • Loading branch information
theweipeng and chaokunyang committed Nov 19, 2023
1 parent 500a4ec commit c5e894e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions javascript/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,43 @@
# Fury JavaScript
Javascript implementation for the fury protocol.
The CrossLanguage part of the protocol is not stable, so the output of this library may change in the future. Please be cautious when using it in a production environment.

## Install
```shell
npm install @furyjs/fury
npm install @furyjs/hps
```

## Usage
```Javascript
import Fury, { Type, InternalSerializerType } from '@furyjs/fury';

/**
* @furyjs/hps use v8's fast-calls-api that can be called directly by jit, ensure that the version of Node is 20 or above.
* Experimental feature, installation success cannot be guaranteed at this moment
* If you are unable to install the module, replace it with `const hps = null;`
**/
import hps from '@furyjs/hps';

// Now we describe data structures using JSON, but in the future, we will use more ways.
const description = Type.object('example.foo', {
foo: Type.string(),
});
const fury = new Fury({ hps });
const { serialize, deserialize } = fury.registerSerializer(description);
const input = serialize({ foo: 'hello fury' });
const result = deserialize(input);
console.log(result);
```

## Packages

### fury
Implement the protocol of fury, generate javascript code at runtime to make sure that all the code could be jit by v8 efficiently

### hps
Nodejs high-performance suite, ensuring that your Node.js version is 20 or later.
hps is use for detect the string type in v8. Fury support latin1 and utf8 string both, we should get the certain type of string before write it
in buffer. It is slow to detect the string is latin1 or utf8, but hps can detect it by a hack way, which is called FASTCALL in v8.
so it is not stable now.

Empty file removed javascript/packages/hps/README.md
Empty file.

0 comments on commit c5e894e

Please sign in to comment.