fazer-lang 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +184 -80
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,137 +1,241 @@
1
- # Fazer Language (fz)
1
+ # Fazer Language Reference Manual
2
2
 
3
- > **The Unique, High-Performance Scripting Language for the Modern Era.**
4
- > "Batteries included" logic, powerful pipes, and unbreakable security.
3
+ > **The Next-Generation Scripting Language for High-Performance Computing & Security.**
4
+ > *Copyright © 2026 L'EMPRISE. All Rights Reserved.*
5
5
 
6
6
  [![npm version](https://img.shields.io/npm/v/fazer-lang.svg)](https://www.npmjs.com/package/fazer-lang)
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
8
 
9
- Fazer is a new interpreted language designed for **speed**, **readability**, and **power**. It combines the best of functional programming (pipes) with imperative simplicity.
9
+ ---
10
+
11
+ ## 1. Introduction
12
+
13
+ **Fazer (fz)** is not just another scripting language. It is a precision tool engineered by **L'EMPRISE** for developers who demand **clarity**, **security**, and **efficiency**.
14
+
15
+ Unlike traditional languages that bury logic in verbose syntax, Fazer prioritizes the **Data Flow**. By utilizing the revolutionary Arrow Pipe Operator (`→>`), Fazer allows data to flow naturally from one operation to the next, mirroring the human thought process.
10
16
 
11
- ## 🚀 Features
17
+ ### Why Fazer?
18
+
19
+ * **Superior Readability**: Logic flows left-to-right. No more nesting hell `func(func(func(x)))`.
20
+ * **Security First**: AES-256-GCM encryption is a first-class citizen, not an afterthought.
21
+ * **Batteries Included**: HTTP Server, FileSystem, System Execution, and JSON parsing are built-in. No external dependencies required for standard tasks.
22
+ * **Universal Compatibility**: Runs on any Node.js environment or compiles to a standalone, dependency-free Binary (EXE/Linux).
23
+
24
+ ---
12
25
 
13
- * **Unique Syntax**: Use the Arrow Pipe `→>` to chain operations like a pro.
14
- * **Batteries Included**:
15
- * 🔐 **Crypto**: AES-256-GCM, SHA256 built-in.
16
- * 🌐 **HTTP Server**: Create web servers in 3 lines of code.
17
- * 📂 **Filesystem**: Read, write, check existence, manipulate paths.
18
- * 💻 **System**: Execute shell commands, handle JSON natively.
19
- * **Visuals**: Built-in support for colored output (`style`) and UI boxes (`box`).
20
- * **Portable**: Runs anywhere Node.js runs (or compiles to a standalone EXE).
26
+ ## 2. Installation
21
27
 
22
- ## 📦 Installation
28
+ ### Global Installation (Recommended)
29
+ To access the `fazer` command globally on your system:
23
30
 
24
31
  ```bash
25
32
  npm install -g fazer-lang
26
33
  ```
27
34
 
28
- ## ⚡ Quick Start
35
+ ### Verification
36
+ ```bash
37
+ fazer --version
38
+ # Output: 2.1.0
39
+ ```
29
40
 
30
- Create a file `hello.fz`:
41
+ ---
31
42
 
32
- ```fazer
33
- fn main() →
34
- box("WELCOME", "Hello from Fazer!", style("Power is yours.", "cyan"))
35
-
36
- # Pipe magic
37
- "secret message" →> sha256() →> println()
38
- end
43
+ ## 3. The Core Philosophy: The Pipe (`→>`)
39
44
 
40
- main()
45
+ In most languages, you write:
46
+ ```javascript
47
+ // JavaScript / Python style
48
+ print(sha256(readFile("data.txt")));
41
49
  ```
50
+ This requires reading "inside-out".
42
51
 
43
- Run it:
44
- ```bash
45
- fazer run hello.fz
52
+ **In Fazer, you write:**
53
+ ```fazer
54
+ "data.txt" →> readText() →> sha256() →> print()
46
55
  ```
56
+ This is the **Pipeline Architecture**. The result of the left side is automatically injected as the *first argument* of the function on the right.
57
+
58
+ ---
47
59
 
48
- ## 📖 Ultra-Precise Documentation
60
+ ## 4. Language Guide
49
61
 
50
- ### 1. The Pipe Operator (`→>`)
51
- The heart of Fazer. It passes the result of the left expression as the *first argument* to the function on the right.
62
+ ### Variables & Constants
63
+ Fazer uses dynamic typing. Variables are declared implicitly.
52
64
 
53
65
  ```fazer
54
- # Standard
55
- println(sha256("text"))
56
-
57
- # Fazer Style
58
- "text" →> sha256() →> println()
66
+ x = 10
67
+ name = "L'EMPRISE"
68
+ isActive = true
59
69
  ```
60
70
 
61
- ### 2. Control Flow
71
+ ### Data Types
72
+ * **String**: `"Hello World"` (supports concatenation with `+`)
73
+ * **Number**: `42`, `3.14`
74
+ * **Boolean**: `true`, `false`
75
+ * **Object/Map**: `{"key": "value"}`
76
+ * **Null**: `null`
77
+
78
+ ### Control Flow: The Power of `case`
79
+ Fazer replaces the archaic `if/else/switch` with a unified, powerful `case` structure.
62
80
 
63
- **Functions (`fn`)**
64
81
  ```fazer
65
- fn add(a, b) →
66
- return(a + b)
82
+ fn analyze(val) →
83
+ case val
84
+ 0 → println("Zero detected") end
85
+ > 100 → println("High value detected") end
86
+ "admin" → println("Access Granted") end
87
+ else → println("Unknown value") end
88
+ end
67
89
  end
68
90
  ```
69
91
 
70
- **Pattern Matching (`case`)**
71
- Instead of boring `if/else`, use `case`:
92
+ ### Functions (`fn`)
93
+ Functions are first-class citizens.
72
94
 
73
95
  ```fazer
74
- case x
75
- 10 → println("It is ten") end
76
- > 10 → println("Greater than ten") end
77
- else → println("Something else") end
96
+ fn multiply(a, b) →
97
+ return(a * b)
78
98
  end
99
+
100
+ # Using with pipe
101
+ 5 →> multiply(10) →> println() # Output: 50
102
+ ```
103
+
104
+ ---
105
+
106
+ ## 5. Standard Library Reference (StdLib)
107
+
108
+ Fazer comes equipped with a professional-grade standard library.
109
+
110
+ ### 5.1. Input / Output & UI (`IO`)
111
+
112
+ * **`print(val)`**: Prints value to stdout (no newline).
113
+ * **`println(val)`**: Prints value with newline.
114
+ * **`ask(prompt)`**: Pauses execution and waits for user input. Returns the string entered.
115
+ * **`style(text, color)`**: Applies ANSI colors to text.
116
+ * *Colors*: `"red"`, `"green"`, `"yellow"`, `"blue"`, `"magenta"`, `"cyan"`, `"white"`, `"gray"`.
117
+ * **`box(title, lines...)`**: Renders a professional ASCII interface box. Automatically handles alignment and ANSI codes.
118
+
119
+ ```fazer
120
+ box("SYSTEM ALERT", "Access Restricted", style("L'EMPRISE Protocol", "red"))
79
121
  ```
80
122
 
81
- ### 3. Built-in Modules (Standard Library)
123
+ ### 5.2. Cryptography (`Crypto`)
124
+ **Security Level: Military Grade (AES-256-GCM).**
125
+
126
+ * **`sha256(data)`**: Returns the SHA-256 hash of the data (hex string).
127
+ * **`encText(plainText, password)`**: Encrypts text using AES-256-GCM. Returns a secure JSON string containing IV, AuthTag, and Ciphertext.
128
+ * **`decText(encryptedJson, password)`**: Decrypts the JSON string. Throws error if password is wrong or integrity is compromised.
82
129
 
83
- #### 🖥️ I/O & UI
84
- * `println(x)`: Print to stdout with newline.
85
- * `print(x)`: Print without newline.
86
- * `ask(prompt)`: Read user input.
87
- * `style(text, color)`: Colorize text (red, green, blue, cyan, yellow, etc.).
88
- * `box(title, lines...)`: Draw a beautiful ASCII box (handles ANSI colors correctly!).
130
+ ```fazer
131
+ pass = "super_secret"
132
+ "My Secret Data" →> encText(pass) →> saveText("secret.enc")
133
+ ```
89
134
 
90
- #### 📂 File System
91
- * `readText(path)` / `saveText(content, path)`
92
- * `readB64(path)` / `saveB64(content, path)`
93
- * `exists(path)`: Returns true/false.
94
- * `ls(dir)`: List files.
95
- * `rm(path)`: Delete file/dir (recursive).
96
- * `mkdir(path)`: Create directory.
135
+ ### 5.3. File System (`FS`)
136
+ Robust, synchronous file operations.
97
137
 
98
- #### 🔐 Cryptography (AES-256-GCM)
99
- * `encText(text, pass)`: Encrypt text.
100
- * `decText(b64, pass)`: Decrypt text.
101
- * `sha256(data)`: Hash data.
138
+ * **`readText(path)`**: Reads file as UTF-8 string.
139
+ * **`saveText(content, path)`**: Writes string to file (overwrites).
140
+ * **`readB64(path)`**: Reads file as Base64 string (useful for binaries).
141
+ * **`saveB64(content, path)`**: Writes Base64 string to file.
142
+ * **`exists(path)`**: Returns `true` if file/directory exists, `false` otherwise.
143
+ * **`ls(path)`**: Returns an array of file names in the directory.
144
+ * **`rm(path)`**: Recursively deletes a file or directory. **Handle with care.**
145
+ * **`mkdir(path)`**: Creates a directory (recursive).
102
146
 
103
- #### 🌐 Network & System (NEW!)
104
- * `server(port, handlerFn)`: Start an HTTP server.
105
- * `exec(cmd)`: Run a shell command (e.g., `exec("dir")`).
106
- * `json(obj)`: Convert object to JSON string.
107
- * `parseJson(str)`: Parse JSON string to object.
147
+ ### 5.4. Networking & Web (`Net`)
148
+ Create high-performance web servers instantly.
108
149
 
109
- ### 4. Example: Web Server
150
+ * **`server(port, handlerFunctionName)`**: Starts a blocking HTTP server.
110
151
 
152
+ **Example Web Server:**
111
153
  ```fazer
112
- fn handleRequest(req) →
113
- println("Request received: " + req.url)
154
+ fn handler(req) →
155
+ # req has .method, .url, .headers
156
+ println("Hit: " + req.url)
157
+
114
158
  return({
115
159
  "status": 200,
116
- "headers": { "Content-Type": "text/plain" },
117
- "body": "Hello from Fazer Server!"
160
+ "headers": { "Content-Type": "application/json" },
161
+ "body": json({ "message": "Welcome to Fazer API" })
118
162
  })
119
163
  end
120
164
 
121
- println("Starting server...")
122
- server(8080, "handleRequest")
165
+ server(3000, "handler")
123
166
  ```
124
167
 
168
+ ### 5.5. System & Utilities (`Sys`)
169
+
170
+ * **`exec(command)`**: Executes a shell command and returns the output (stdout).
171
+ * **`json(obj)`**: Serializes an object/array to a JSON string.
172
+ * **`parseJson(jsonString)`**: Parses a JSON string into an object.
173
+
125
174
  ---
126
175
 
127
- ## 🛠️ Distribution
176
+ ## 6. Advanced Usage: Building Standalone Executables
128
177
 
129
- To compile your script into a standalone executable:
178
+ You can compile your Fazer scripts into standalone executables (`.exe` for Windows, binary for Linux) that do not require Node.js or Fazer to be installed on the target machine.
130
179
 
180
+ **Command:**
131
181
  ```bash
132
- pkg fazer.js --targets node18-win-x64 --output myapp.exe
182
+ # Requires 'pkg' installed via npm
183
+ pkg fazer.js --targets node18-win-x64,node18-linux-x64 --output my_app
133
184
  ```
134
185
 
135
- ## 📜 License
186
+ This capability makes Fazer the ideal choice for deploying secure, self-contained tools to client environments.
187
+
188
+ ---
189
+
190
+ ## 8. Fazer vs The World: A Technical Comparison
191
+
192
+ Why choose Fazer when you have JavaScript, Python, or Go? Because Fazer is designed for a specific purpose: **High-level Orchestration with Low-level Power**.
193
+
194
+ ### 8.1. Fazer vs JavaScript / Node.js
195
+
196
+ * **The Problem with JS**: "Callback Hell" and "Promise Chaining". JavaScript forces you to write code "inside-out" or manage endless `.then()` chains.
197
+ * *JS*: `process(parse(read(file)))`
198
+ * **The Fazer Solution**: Linear data flow. The pipe operator (`→>`) is not just sugar; it's the core of the language.
199
+ * *Fazer*: `file →> read() →> parse() →> process()`
200
+ * **Ecosystem**: To get encryption, HTTP server, and file system operations in Node.js, you often need to install external packages or write boilerplate code using `fs`, `http`, and `crypto` modules. Fazer includes these batteries **natively**. `encText` and `server` are there from line 1.
201
+
202
+ ### 8.2. Fazer vs Python
203
+
204
+ * **Distribution**: Sharing a Python script is painful. The user needs Python installed, then `pip install -r requirements.txt`, and version conflicts are common.
205
+ * **Fazer's Edge**: Fazer compiles to a **single, standalone binary** (EXE for Windows, Bin for Linux). You give the file to the user, they double-click, and it runs. No installation, no dependencies, no friction.
206
+ * **Performance**: While Python interprets line-by-line, Fazer's lightweight runtime is optimized for rapid I/O and cryptographic operations, making it feel snappier for CLI tools.
207
+
208
+ ### 8.3. Fazer vs Bash / Shell
209
+
210
+ * **Cross-Platform Nightmare**: A Bash script written for Linux often fails on Windows (PowerShell/CMD) or macOS due to syntax differences (`ls` vs `dir`, `/` vs `\`).
211
+ * **Fazer's Universality**: Fazer abstracts the operating system. `ls()`, `rm()`, and `exec()` work identically on Windows, Linux, and macOS. Write once, control any system.
212
+ * **Safety**: Bash has no real error handling or types. A wrong variable expansion can delete your hard drive (`rm -rf /$VAR`). Fazer provides a structured, safe environment with scoped variables and error handling.
213
+
214
+ ### 8.4. Fazer vs C/C++
215
+
216
+ * **Development Speed**: Writing a secure HTTP server with AES encryption in C++ takes days and hundreds of lines of code. In Fazer, it takes **5 lines**.
217
+ * **Memory Safety**: No manual memory management, no buffer overflows, no segmentation faults. Fazer handles the dirty work so you can focus on the logic.
218
+
219
+ ### Summary Table
220
+
221
+ | Feature | Fazer | JavaScript | Python | Bash |
222
+ | :--- | :---: | :---: | :---: | :---: |
223
+ | **Pipeline Logic** | ✅ Native (`→>`) | ❌ (Plugins needed) | ❌ | ✅ (Pipes `|`) |
224
+ | **Distribution** | ✅ Single Binary | ❌ (Requires Runtime) | ❌ (Complex) | ✅ (Source only) |
225
+ | **Cryptography** | ✅ Built-in AES-256 | ⚠️ Module required | ⚠️ Module required | ❌ External tools |
226
+ | **Cross-Platform** | ✅ 100% | ✅ | ✅ | ❌ |
227
+ | **Setup Time** | ⚡ Instant | 🐢 Slow (npm install) | 🐢 Slow (pip install) | ⚡ Instant |
228
+
229
+ ---
230
+
231
+ ## 9. Copyright & Legal
232
+
233
+ **Fazer Language** is a proprietary technology developed by **L'EMPRISE**.
234
+ Unauthorized reproduction of the core interpreter logic without attribution is prohibited.
235
+
236
+ * **Copyright**: © 2026 L'EMPRISE.
237
+ * **License**: MIT (Open Source for usage).
238
+
239
+ ---
136
240
 
137
- MIT © Fazer Corp (2026)
241
+ > *"Control the code, control the world."* — **L'EMPRISE**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fazer-lang",
3
- "version": "2.1.0",
3
+ "version": "2.1.2",
4
4
  "description": "Fazer — A unique, high-performance scripting language with powerful pipe operators (→>) and batteries-included stdlib (crypto, http, fs, json).",
5
5
  "main": "fazer.js",
6
6
  "bin": {