AgentSkillsCN

east-node-std

适用于East语言的Node.js平台函数。在编写需要控制台I/O、文件系统操作、HTTP请求、加密处理、时间操作、路径管理、随机数生成,或进行测试的East程序时使用。触发关键词包括:(1) 使用@elaraai/east-node-std编写East程序;(2) 调用Console.log、FileSystem.readFile、Fetch.get、Crypto.uuid、Time.now、Path.join、Random.normal等平台函数;(3) 通过describeEast和Assert对East代码进行测试。

SKILL.md
--- frontmatter
name: east-node-std
description: "Node.js platform functions for the East language. Use when writing East programs that need Console I/O, FileSystem operations, HTTP Fetch requests, Cryptography, Time operations, Path manipulation, Random number generation, or Testing. Triggers for: (1) Writing East programs with @elaraai/east-node-std, (2) Using platform functions like Console.log, FileSystem.readFile, Fetch.get, Crypto.uuid, Time.now, Path.join, Random.normal, (3) Testing East code with describeEast and Assert."

East Node Standard Library

Node.js platform functions for the East language. Enables East programs to interact with the filesystem, network, console, and other I/O operations.

Quick Start

typescript
import { East, StringType, NullType } from "@elaraai/east";
import { NodePlatform, Console, FileSystem } from "@elaraai/east-node-std";

const processFile = East.function(
    [StringType],
    NullType,
    ($, path) => {
        const content = $.let(FileSystem.readFile(path));
        $(Console.log(content));
    }
);

// Compile with NodePlatform (includes all platform functions)
const compiled = East.compile(processFile.toIR(), NodePlatform);
await compiled("input.txt");

Decision Tree: Which Module to Use

code
Task → What do you need?
    │
    ├─ Console (stdout/stderr output)
    │   └─ .log(), .error(), .write()
    │
    ├─ FileSystem (read/write files and directories)
    │   ├─ Text → .readFile(), .writeFile(), .appendFile()
    │   ├─ Binary → .readFileBytes(), .writeFileBytes()
    │   ├─ Query → .exists(), .isFile(), .isDirectory()
    │   ├─ Directory → .createDirectory(), .readDirectory()
    │   └─ Delete → .deleteFile()
    │
    ├─ Fetch (HTTP requests)
    │   └─ .get(), .getBytes(), .post(), .request()
    │
    ├─ Crypto (hashing, UUIDs, random bytes)
    │   └─ .uuid(), .randomBytes(), .hashSha256(), .hashSha256Bytes()
    │
    ├─ Time (timestamps and delays)
    │   └─ .now(), .sleep()
    │
    ├─ Path (path manipulation)
    │   └─ .join(), .resolve(), .dirname(), .basename(), .extname()
    │
    ├─ Random (statistical distributions)
    │   ├─ Basic → .uniform(), .normal(), .range()
    │   ├─ Continuous → .exponential(), .weibull(), .pareto(), .logNormal()
    │   ├─ Discrete → .bernoulli(), .binomial(), .geometric(), .poisson()
    │   ├─ Composite → .irwinHall(), .bates()
    │   └─ Control → .seed()
    │
    └─ Assert (testing with describeEast)
        └─ .is(), .equal(), .notEqual(), .less(), .lessEqual(), .greater(), .greaterEqual(), .between(), .throws(), .fail()

Compiling East Programs

Option 1: Use NodePlatform (all modules)

typescript
const compiled = East.compile(myFunction.toIR(), NodePlatform);

Option 2: Use specific module implementations

typescript
const compiled = East.compile(myFunction.toIR(), [...Console.Implementation, ...FileSystem.Implementation]);

Reference Documentation

  • API Reference - Complete function signatures, types, and arguments for all modules
  • Examples - Working code examples by use case

Available Modules

ModuleImportPurpose
Consoleimport { Console } from "@elaraai/east-node-std"stdout/stderr output
FileSystemimport { FileSystem } from "@elaraai/east-node-std"Read/write files and directories
Fetchimport { Fetch } from "@elaraai/east-node-std"HTTP requests
Cryptoimport { Crypto } from "@elaraai/east-node-std"Hashing, UUIDs, random bytes
Timeimport { Time } from "@elaraai/east-node-std"Timestamps and sleep
Pathimport { Path } from "@elaraai/east-node-std"Path manipulation
Randomimport { Random } from "@elaraai/east-node-std"14 statistical distributions
Assertimport { Assert, describeEast } from "@elaraai/east-node-std"Testing utilities

Accessing Types

typescript
import { Fetch } from "@elaraai/east-node-std";

// Access types via Module.Types.TypeName
const method = Fetch.Types.Method;
const config = Fetch.Types.RequestConfig;
const response = Fetch.Types.Response;