-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: javascript readme * chore: javascript readme * Update javascript/README.md --------- Co-authored-by: Shawn <shawn.ck.yang@gmail.com>
- Loading branch information
1 parent
500a4ec
commit c5e894e
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.