fazer-lang 2.1.1 → 2.2.1

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Fazer Corp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,200 +1,62 @@
1
- # Fazer Language Reference Manual
1
+ # Fazer
2
2
 
3
- > **The Next-Generation Scripting Language for High-Performance Computing & Security.**
4
- > *Copyright © 2026 L'EMPRISE. All Rights Reserved.*
3
+ **Fazer** is a powerful, concise scripting language designed for automation, security, and data processing. It features a unique syntax with pipe operators (`→>`), pattern matching (`case`), and a batteries-included standard library.
5
4
 
6
- [![npm version](https://img.shields.io/npm/v/fazer-lang.svg)](https://www.npmjs.com/package/fazer-lang)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ ## Installation
8
6
 
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.
16
-
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
- ---
25
-
26
- ## 2. Installation
27
-
28
- ### Global Installation (Recommended)
29
- To access the `fazer` command globally on your system:
7
+ Install Fazer globally using npm:
30
8
 
31
9
  ```bash
32
10
  npm install -g fazer-lang
33
11
  ```
34
12
 
35
- ### Verification
36
- ```bash
37
- fazer --version
38
- # Output: 2.1.0
39
- ```
40
-
41
- ---
42
-
43
- ## 3. The Core Philosophy: The Pipe (`→>`)
13
+ ## Usage
44
14
 
45
- In most languages, you write:
46
- ```javascript
47
- // JavaScript / Python style
48
- print(sha256(readFile("data.txt")));
49
- ```
50
- This requires reading "inside-out".
51
-
52
- **In Fazer, you write:**
53
- ```fazer
54
- "data.txt" →> readText() →> sha256() →> print()
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.
15
+ Run the REPL (interactive mode):
57
16
 
58
- ---
59
-
60
- ## 4. Language Guide
61
-
62
- ### Variables & Constants
63
- Fazer uses dynamic typing. Variables are declared implicitly.
64
-
65
- ```fazer
66
- x = 10
67
- name = "L'EMPRISE"
68
- isActive = true
69
- ```
70
-
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.
80
-
81
- ```fazer
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
89
- end
90
- ```
91
-
92
- ### Functions (`fn`)
93
- Functions are first-class citizens.
94
-
95
- ```fazer
96
- fn multiply(a, b) →
97
- return(a * b)
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"))
17
+ ```bash
18
+ fazer
121
19
  ```
122
20
 
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.
21
+ Run a script:
129
22
 
130
- ```fazer
131
- pass = "super_secret"
132
- "My Secret Data" →> encText(pass) →> saveText("secret.enc")
23
+ ```bash
24
+ fazer my_script.fz
133
25
  ```
134
26
 
135
- ### 5.3. File System (`FS`)
136
- Robust, synchronous file operations.
137
-
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).
27
+ ## Features
146
28
 
147
- ### 5.4. Networking & Web (`Net`)
148
- Create high-performance web servers instantly.
29
+ - **Pipe Operator**: Chain functions easily: `readText("in.txt") →> encText(pass) →> writeText("out.enc")`
30
+ - **Pattern Matching**: Expressive control flow with `case`
31
+ - **Batteries Included**: Built-in modules for:
32
+ - File System (`readText`, `writeText`, `ls`, `exists`)
33
+ - Cryptography (`aes-256-gcm`, `sha256`)
34
+ - Networking (`fetch`, `server`, `discord`)
35
+ - JSON (`json`, `parseJson`)
36
+ - System (`exec`, `env`, `argv`)
37
+ - **Single File**: The runtime is compact and efficient.
149
38
 
150
- * **`server(port, handlerFunctionName)`**: Starts a blocking HTTP server.
39
+ ## Example
151
40
 
152
- **Example Web Server:**
153
41
  ```fazer
154
- fn handler(req) →
155
- # req has .method, .url, .headers
156
- println("Hit: " + req.url)
42
+ fn main() →
43
+ println(style("Welcome to Fazer", "cyan"))
157
44
 
158
- return({
159
- "status": 200,
160
- "headers": { "Content-Type": "application/json" },
161
- "body": json({ "message": "Welcome to Fazer API" })
162
- })
45
+ files := ls(".")
46
+ println("Found " + len(files) + " files.")
47
+
48
+ case exists("secret.txt")
49
+ true →
50
+ content := readText("secret.txt")
51
+ println("Secret content: " + content)
52
+ end
53
+ else → end
54
+ end
163
55
  end
164
56
 
165
- server(3000, "handler")
57
+ main()
166
58
  ```
167
59
 
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
-
174
- ---
175
-
176
- ## 6. Advanced Usage: Building Standalone Executables
177
-
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.
179
-
180
- **Command:**
181
- ```bash
182
- # Requires 'pkg' installed via npm
183
- pkg fazer.js --targets node18-win-x64,node18-linux-x64 --output my_app
184
- ```
185
-
186
- This capability makes Fazer the ideal choice for deploying secure, self-contained tools to client environments.
187
-
188
- ---
189
-
190
- ## 7. Copyright & Legal
191
-
192
- **Fazer Language** is a proprietary technology developed by **L'EMPRISE**.
193
- Unauthorized reproduction of the core interpreter logic without attribution is prohibited.
194
-
195
- * **Copyright**: © 2026 L'EMPRISE.
196
- * **License**: MIT (Open Source for usage).
197
-
198
- ---
60
+ ## License
199
61
 
200
- > *"Control the code, control the world."* — **L'EMPRISE**
62
+ MIT