Skip to content

Commit

Permalink
better docs
Browse files Browse the repository at this point in the history
  • Loading branch information
WebReflection committed Apr 10, 2024
1 parent a1e87fa commit 9dabb18
Showing 1 changed file with 51 additions and 3 deletions.
54 changes: 51 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ The "*one-stop shop*" solution for JS Proxies and FFI APIs.

**[Documentation](https://webreflection.github.io/js-proxy/)**

- - -

### Table of content

* [API](#api) that describes the default exported utility
* [jsProxy](#jsproxy) that describes the namespace returned by the utility
* [Heap](#heap) that describes what `js-proxy/heap` exports as extra utility
* **[API](#api)** that describes the default exported utility
* **[jsProxy](#jsproxy)** that describes the namespace returned by the utility
* **[Heap](#heap)** that describes what `js-proxy/heap` exports as extra utility
* **[Traps](#traps)** that describes what `js-proxy/traps` exports
* **[Types](#types)** that describes what `js-proxy/types` exports

## API

Expand Down Expand Up @@ -355,3 +359,47 @@ addEventListener('message', ({ data }) => {
In the outer world, the `proxy.object({_ref: value})` could forward back via `postMessage` all traps, including the `destruct` when it happens, so that the worker can apply and reply with the result.

As summary, this export helps relating any reference to a unique identifier and it holds such reference until it's dropped. This is particularly useful to avoid the current realm collecting that reference, as it might be used solely in the outer world, still enabling, via `destruct` ability, to free memory on occasion.


## Traps

The `js-proxy/traps` exports the following:

```js
// Standard Proxy Traps
export const APPLY = 'apply';
export const CONSTRUCT = 'construct';
export const DEFINE_PROPERTY = 'defineProperty';
export const DELETE_PROPERTY = 'deleteProperty';
export const GET = 'get';
export const GET_OWN_PROPERTY_DESCRIPTOR = 'getOwnPropertyDescriptor';
export const GET_PROTOTYPE_OF = 'getPrototypeOf';
export const HAS = 'has';
export const IS_EXTENSIBLE = 'isExtensible';
export const OWN_KEYS = 'ownKeys';
export const PREVENT_EXTENSION = 'preventExtensions';
export const SET = 'set';
export const SET_PROTOTYPE_OF = 'setPrototypeOf';

// Custom (JS)Proxy Traps
export const DESTRUCT = 'destruct';
export const VALUE_OF = 'valueOf';
```


## Types

The `js-proxy/types` exports the following:

```js
export const ARRAY = 'array';
export const BIGINT = 'bigint';
export const BOOLEAN = 'boolean';
export const FUNCTION = 'function';
export const NULL = 'null';
export const NUMBER = 'number';
export const OBJECT = 'object';
export const STRING = 'string';
export const SYMBOL = 'symbol';
export const UNDEFINED = 'undefined';
```

0 comments on commit 9dabb18

Please sign in to comment.