
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
AssemblyScript project initializer with bilingual (English/Chinese) support, enabling quick creation of WebAssembly projects via 'npm init as'
create-as is a lightweight project initializer for AssemblyScript, enabling quick creation of WebAssembly (Wasm) projects via npm init as. It supports both English and Chinese languages, adapting to different developers' preferences.
npm init as <project-directory>, following npm initializer conventionsadd/multiply example functions; compile, test, and preview immediately after installing dependenciesNo prior installation required - use directly via npm init (supports npm/yarn/pnpm):
# Basic usage: Create project named "my-as-project" (language selection prompt)
npm init as my-as-project
# Advanced: Create in current directory (auto-confirm all options, default English)
npm init as . -y
# Advanced: Create project with terminal colors disabled
npm init as ./demo --no-colors
After executing the command (in non--y mode), you'll be prompted to select the project language:
Select project language (Default: English)
1. English (en)
2. Chinese (zh-CN)
Enter number (1/2) or press Enter:
1: Select English (terminal prompts and file comments in English)2: Select Chinese (terminal prompts and file comments in Chinese)After creation, the generated project structure looks like this (English example):
my-as-project/
├── assembly/ # AssemblyScript source directory
│ └── index.ts # Entry file (contains add/multiply examples)
│ └── tsconfig.json # TS configuration (inherits AssemblyScript standards)
├── build/ # Wasm build output directory
│ └── .gitignore # Ignore build artifacts (keep only .gitignore)
├── tests/ # Test directory
│ └── index.js # Test file (validates Wasm function functionality)
├── index.html # Browser preview example (loads and calls Wasm)
├── asconfig.json # AssemblyScript build configuration (debug/release)
└── package.json # Project configuration (dependencies, scripts)
After project creation, use these commands for development workflow (automatically adapts to your package manager):
| Command | Description | Example (npm) |
|---|---|---|
| Install dependencies | Installs AssemblyScript and other development dependencies | npm install |
| Build Wasm module | Generates both debug (development) and release (optimized) versions | npm run asbuild |
| Build debug version | Generates Wasm with debugging information (for development) | npm run asbuild:debug |
| Build release version | Generates optimized Wasm (smaller size, better performance) | npm run asbuild:release |
| Run tests | Executes test cases to verify Wasm function correctness | npm test |
| Browser preview | Starts local server to preview Wasm in browser | npm start |
| Option | Alias | Description |
|---|---|---|
--help | -h | Show help information (including usage examples and options) |
--yes | -y | Auto-confirm all options (skips language selection and confirmation) |
--no-colors | - | Disable terminal color output (for plain text environments) |
--version | -v | Show current version of create-as |
// AssemblyScript entry file (compiles to WebAssembly)
// Docs: https://www.assemblyscript.org
/**
* Example: Add two numbers (i32 = 32-bit signed integer)
* @param a First number
* @param b Second number
* @returns Sum of a and b
*/
export function add(a: i32, b: i32): i32 {
return a + b;
}
/**
* Extended example: Multiply two numbers
*/
export function multiply(a: i32, b: i32): i32 {
return a * b;
}
import assert from "assert";
import { add, multiply } from "../build/debug.js";
// Test add function (basic addition)
assert.strictEqual(add(1, 2), 3, "add(1,2) should return 3");
assert.strictEqual(add(-1, 5), 4, "add(-1,5) should return 4");
// Test multiply function (basic multiplication)
assert.strictEqual(multiply(2, 3), 6, "multiply(2,3) should return 6");
assert.strictEqual(multiply(-2, 4), -8, "multiply(-2,4) should return -8");
console.log("✅ All tests passed!");
Automatically loads the compiled Wasm module and displays results in the browser:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AssemblyScript Wasm Example</title>
<script type="module">
// Load compiled Wasm module (ES Module format)
import { add, multiply } from "./build/release.js";
// Display results on page
document.addEventListener("DOMContentLoaded", () => {
const result = `
<h2>AssemblyScript Wasm Example</h2>
<p>add(1, 2) = ${add(1, 2)}</p>
<p>multiply(3, 4) = ${multiply(3, 4)}</p>
`;
document.body.innerHTML = result;
});
</script>
</head>
<body></body>
</html>
npm install (or yarn install/pnpm install) after project creation - required for compilationnpm start uses the serve tool (automatically invoked via npx, no additional installation needed)devDependencies.assemblyscript in package.jsonFor bugs, translation errors, or feature requests, please report via:
MIT License
Free to use, modify, and distribute under the terms of the MIT License.
FAQs
AssemblyScript project initializer with bilingual (English/Chinese) support, enabling quick creation of WebAssembly projects via 'npm init as'
The npm package create-as receives a total of 1 weekly downloads. As such, create-as popularity was classified as not popular.
We found that create-as demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.