You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-66Lines changed: 66 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ QuickJS Javascript引擎
50
50
*[4.3.4 Numbers](#434-numbers)
51
51
*[4.3.5 垃圾回收](#435-垃圾回收)
52
52
*[4.3.6 JSValue](#436-jsvalue)
53
-
*[4.3.7 Function call](#437-function-call)
53
+
*[4.3.7 函数调用](#437-函数调用)
54
54
*[4.4 RegExp](#44-regexp)
55
55
*[4.5 Unicode](#45-unicode)
56
56
*[4.6 BigInt and BigFloat](#46-bigint-and-bigfloat)
@@ -358,130 +358,130 @@ ES6模块完全支持。默认名称解析规则如下:
358
358
359
359
`EPIPE`
360
360
361
-
Integer value of common errors (additional error codes may be defined).
361
+
常见错误的整数值 (可以定义附加错误代码)。
362
362
363
363
`strerror(errno)`
364
364
365
-
Return a string that describes the error `errno`.
365
+
返回描述错误的字符串`errno`.
366
366
367
367
`open(filename, flags)`
368
368
369
-
Open a file (wrapper to the libc `fopen()`). Throws `std.Error`in case of I/O error.
369
+
打开一个文件(libc的包装器`fopen()`)。在I/O错误时抛出 `std.Error`
370
370
371
371
`tmpfile()`
372
372
373
-
Open a temporary file. Throws `std.Error`in case of I/O error.
373
+
打开一个临时文件。在I/O错误时抛出`std.Error`。
374
374
375
375
`puts(str)`
376
376
377
-
Equivalent to `std.out.puts(str)`.
377
+
相当于`std.out.puts(str)`.
378
378
379
379
`printf(fmt, ...args)`
380
380
381
-
Equivalent to `std.out.printf(fmt, ...args)`
381
+
相当于`std.out.printf(fmt, ...args)`
382
382
383
383
`sprintf(fmt, ...args)`
384
384
385
-
Equivalent to the libc sprintf().
385
+
相当于libc的sprintf().
386
386
387
387
`in`
388
388
389
389
`out`
390
390
391
391
`err`
392
392
393
-
Wrappers to the libc file `stdin`, `stdout`, `stderr`.
393
+
包装libc文件的`stdin`, `stdout`, `stderr`.
394
394
395
395
`SEEK_SET`
396
396
397
397
`SEEK_CUR`
398
398
399
399
`SEEK_END`
400
400
401
-
Constants for seek().
401
+
seek()的常量
402
402
403
403
`global`
404
404
405
-
Reference to the global object.
405
+
引用全局对象。
406
406
407
407
`gc()`
408
408
409
-
Manually invoke the cycle removal algorithm. The cycle removal algorithm is automatically started when needed, so this function is useful in case of specific memory constraints or for testing.
409
+
手动调用循环删除算法。循环移除算法在需要时自动启动,因此该功能在特定内存限制或测试时非常有用。
410
410
411
411
`getenv(name)`
412
412
413
-
Return the value of the environment variable `name`or`undefined`if it is not defined.
413
+
返回环境变量的值 `name`,或未定义时返回`undefined` .
414
414
415
-
FILE prototype:
415
+
FILE 原型:
416
416
417
417
`close()`
418
418
419
-
Close the file.
419
+
关闭文件。
420
420
421
421
`puts(str)`
422
422
423
-
Outputs the string with the UTF-8 encoding.
423
+
使用UTF-8编码输出字符串。
424
424
425
425
`printf(fmt, ...args)`
426
426
427
-
Formatted printf, same formats as the libc printf.
427
+
格式化printf,与libc printf格式相同。
428
428
429
429
`flush()`
430
430
431
-
Flush the buffered file.
431
+
刷新缓冲的文件。
432
432
433
433
`seek(offset, whence)`
434
434
435
-
Seek to a give file position (whence is `std.SEEK_*`). Throws a `std.Error` in case of I/O error.
435
+
寻找特定文件位置 (从哪里`std.SEEK_*`)。在I/O错误时抛出 `std.Error`。
436
436
437
437
`tell()`
438
438
439
-
Return the current file position.
439
+
返回当前文件位置。
440
440
441
441
`eof()`
442
442
443
-
Return true if end of file.
443
+
如果文件结束,则返回true。
444
444
445
445
`fileno()`
446
446
447
-
Return the associated OS handle.
447
+
返回关联的OS句柄。
448
448
449
449
`read(buffer, position, length)`
450
450
451
-
Read `length` bytes from the file to the ArrayBuffer `buffer` at byte position `position`(wrapper to the libc `fread`).
451
+
Read `length` bytes from the file to the ArrayBuffer `buffer` at byte position `position`(libc的包装器`fread`)。
452
452
453
453
`write(buffer, position, length)`
454
454
455
455
Write `length` bytes to the file from the ArrayBuffer `buffer` at byte position `position` (wrapper to the libc `fread`).
456
456
457
457
`getline()`
458
458
459
-
Return the next line from the file, assuming UTF-8 encoding, excluding the trailing line feed.
459
+
返回文件中的下一行,假设为UTF-8编码,不包括尾随换行符。
460
460
461
461
`getByte()`
462
462
463
-
Return the next byte from the file.
463
+
返回文件中的下一个字节。
464
464
465
465
`putByte(c)`
466
466
467
-
Write one byte to the file.
467
+
将一个字节写入文件。
468
468
469
469
#### 3.3.3 `os` 模块
470
470
471
-
The`os`module provides Operating System specific functions:
471
+
`os`模块提供操作系统特定功能:
472
472
473
-
*low level file access
474
-
*signals
475
-
*timers
476
-
*asynchronous I/O
473
+
*底层文件访问
474
+
*信号
475
+
*计时器
476
+
*异步 I/O
477
477
478
-
The OS functions usually return 0 if OK or an OS specific negative error code.
478
+
如果是OK,OS函数通常返回0,或者OS返回特定的错误代码。
479
479
480
-
Available exports:
480
+
可用导出函数:
481
481
482
482
`open(filename, flags, mode = 0o666)`
483
483
484
-
Open a file. Return a handle or < 0 if error.
484
+
打开一个文件。如果错误,返回句柄或<0。
485
485
486
486
`O_RDONLY`
487
487
@@ -497,19 +497,19 @@ Open a file. Return a handle or < 0 if error.
497
497
498
498
`O_TRUNC`
499
499
500
-
POSIX open flags.
500
+
POSIX打开标志。
501
501
502
502
`O_TEXT`
503
503
504
-
(Windows specific). Open the file in text mode. The default is binary mode.
504
+
(Windows特定)。以文本模式打开文件。默认为二进制模式。
505
505
506
506
`close(fd)`
507
507
508
-
Close the file handle `fd`.
508
+
关闭文件句柄`fd`.
509
509
510
510
`seek(fd, offset, whence)`
511
511
512
-
Seek in the file. Use `std.SEEK_*`for`whence`.
512
+
寻找文件。使用 `std.SEEK_*`或`whence`.
513
513
514
514
`read(fd, buffer, offset, length)`
515
515
@@ -521,35 +521,35 @@ Write `length` bytes to the file handle `fd` from the ArrayBuffer `buffer` at by
521
521
522
522
`isatty(fd)`
523
523
524
-
Return `true` is `fd`is a TTY (terminal) handle.
524
+
`fd`是一个TTY (终端)句柄返回 `true` 。
525
525
526
526
`ttyGetWinSize(fd)`
527
527
528
-
Return the TTY size as `[width, height]`or`null`if not available.
528
+
返回TTY大小 `[width, height]`或者如果不可用返回`null`。
529
529
530
530
`ttySetRaw(fd)`
531
531
532
-
Set the TTY in raw mode.
532
+
在原始模式下设置TTY。
533
533
534
534
`remove(filename)`
535
535
536
-
Remove a file. Return 0 if OK or < 0 if error.
536
+
删除文件。如果正常则返回0,如果错误则返回<0
537
537
538
538
`rename(oldname, newname)`
539
539
540
-
Rename a file. Return 0 if OK or < 0 if error.
540
+
重命名文件。如果正常则返回0,如果错误则返回<0
541
541
542
542
`setReadHandler(fd, func)`
543
543
544
-
Add a read handler to the file handle `fd`. `func` is called each time there is data pending for `fd`. A single read handler per file handle is supported. Use `func = null`to remove the hander.
Add a write handler to the file handle `fd`. `func`is called each time data can be written to `fd`. A single write handler per file handle is supported. Use `func = null` to remove the hander.
Call the function `func` when the signal `signal` happens. Only a single handler per signal number is supported. Use `null`to set the default handler or `undefined`to ignore the signal.
@@ -563,23 +563,23 @@ Call the function `func` when the signal `signal` happens. Only a single handler
563
563
564
564
`SIGTERM`
565
565
566
-
POSIX signal numbers.
566
+
POSIX 信号编号。
567
567
568
568
`setTimeout(func, delay)`
569
569
570
-
Call the function `func` after `delay` ms. Return a handle to the timer.
570
+
在 `delay` 毫秒之后调用函数 `func` 。返回计时器的句柄。
571
571
572
572
`clearTimer(handle)`
573
573
574
-
Cancel a timer.
574
+
取消计时器。
575
575
576
576
`platform`
577
577
578
-
Return a string representing the platform:`"linux"`, `"darwin"`, `"win32"` or `"js"`.
578
+
返回表示该平台的字符串:`"linux"`, `"darwin"`, `"win32"` or `"js"`.
579
579
580
580
### 3.4 QuickJS C API
581
581
582
-
The C API was designed to be simple and efficient. The C API is defined in the header `quickjs.h`.
582
+
C API的设计简单而有效。C API在`quickjs.h`标头中定义。
583
583
584
584
#### 3.4.1 运行时和上下文
585
585
@@ -708,42 +708,42 @@ In 64-bit code, JSValue are 128-bit large and no NaN boxing is used. The rationa
708
708
709
709
In both cases (32 or 64 bits), JSValue exactly fits two CPU registers, so it can be efficiently returned by C functions.
710
710
711
-
#### 4.3.7 Function call
711
+
#### 4.3.7 函数调用
712
712
713
-
The engine is optimized so that function calls are fast. The system stack holds the Javascript parameters and local variables.
713
+
引擎已经过优化,因此函数调用很快。系统堆栈包含Javascript参数和局部变量。
714
714
715
715
### 4.4 RegExp
716
716
717
-
A specific regular expression engine was developped. It is both small and efficient and supports all the ES2019 features including the Unicode properties. As the Javascript compiler, it directly generates bytecode without a parse tree.
Backtracking with an explicit stack is used so that there is no recursion on the system stack. Simple quantizers are specifically optimized to avoid recursions.
719
+
使用显式堆栈的回溯使得系统堆栈上没有递归。简单的量化器经过专门优化,以避免递归。
720
720
721
-
Infinite recursions coming from quantizers with empty terms are avoided.
721
+
来自具有空项的量化器的无限递归被避免。
722
722
723
-
The full regexp library weights about 15 KiB (x86 code), excluding the Unicode library.
723
+
完整的正则表达式文件库的权重约为15 KiB(x86代码),不包括Unicode库。
724
724
725
725
### 4.5 Unicode
726
726
727
-
A specific Unicode library was developped so that there is no dependency on an external large Unicode library such as ICU. All the Unicode tables are compressed while keeping a reasonnable access speed.
The library supports case conversion, Unicode normalization, Unicode script queries, Unicode general category queries and all Unicode binary properties.
The full Unicode library weights about 45 KiB (x86 code).
731
+
完整的Unicode库大约重量为45 KiB(x86代码)。
732
732
733
-
### 4.6 BigInt and BigFloat
733
+
### 4.6 BigInt 和 BigFloat
734
734
735
-
BigInt and BigFloat are implemented with the `libbf`library[4](#FOOT4). It weights about 60 KiB (x86 code) and provides arbitrary precision IEEE 754 floating point operations and transcendental functions with exact rounding.
0 commit comments