Socket
Book a DemoInstallSign in
Socket

as-object

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-object

Object API implementation for AssemblyScript

latest
Source
npmnpm
Version
0.1.4
Version published
Maintainers
2
Created
Source

AS-OBJECT

AssemblyScript WebAssembly

Object API implementation for AssemblyScript with additional features.

Setup

npm install as-object
npm install visitor-as

Add the transform to your asc command

--transform json-as/transform

Alternatively, add it to your asconfig.json (e.g. in package.json)

{
  "options": {
    "transform": ["json-as/transform"]
  }
}

Usage

import { Object } from "as-object/assembly";
// Must import as-variant or it will not work
import { Variant } from "as-variant/assembly";
@object
class Vec3 {
    x!: f32;
    y!: f32;
    z!: f32;
}

const vec: Vec3 = {
    x: 3.4,
    y: 1.2,
    z: 8.3
}

console.log("[" + Object.keys(vec).map<string>(v => `"${v}"`).join(", ") + "]");
// ["x", "y", "z"]
console.log(Object.types(vec).join(", "));
// f32, f32, f32
console.log(Object.name(vec));
// Vec3
console.log("[" + Object.values(vec).map<f32>(v => v.get<f32>()).join(",") + "]");
// [3.4000000953674318,1.2000000476837159,8.300000190734864]

Keywords

assemblyscript

FAQs

Package last updated on 30 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts