zuzu-js 0.1.0
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 +5 -0
- package/README.md +113 -0
- package/bin/zuzu +17 -0
- package/bin/zuzu-build-browser-bundle +57 -0
- package/bin/zuzu-generate-browser-stdlib +584 -0
- package/bin/zuzu-js +23 -0
- package/bin/zuzu-js-compile +152 -0
- package/bin/zuzu-js-electron +19 -0
- package/dist/zuzu-browser-worker.js +45574 -0
- package/dist/zuzu-browser.js +45362 -0
- package/lib/browser-bundle-entry.js +160 -0
- package/lib/browser-gui-renderer.js +387 -0
- package/lib/browser-runtime.js +167 -0
- package/lib/browser-worker-entry.js +413 -0
- package/lib/browser-ztests/runner.html +103 -0
- package/lib/browser-ztests/runner.js +369 -0
- package/lib/cli.js +350 -0
- package/lib/collections.js +367 -0
- package/lib/compiler.js +303 -0
- package/lib/electron/launcher.js +70 -0
- package/lib/electron/main.js +956 -0
- package/lib/electron/preload.js +80 -0
- package/lib/electron/renderer.html +122 -0
- package/lib/electron/renderer.js +24 -0
- package/lib/execution-metadata.js +18 -0
- package/lib/gui/dom-renderer.js +778 -0
- package/lib/host/browser-host.js +278 -0
- package/lib/host/capabilities.js +47 -0
- package/lib/host/electron-host.js +15 -0
- package/lib/host/node-host.js +74 -0
- package/lib/paths.js +150 -0
- package/lib/runtime-entrypoints.js +60 -0
- package/lib/runtime-helpers.js +886 -0
- package/lib/runtime.js +3529 -0
- package/lib/tap.js +37 -0
- package/lib/transpiler-new/ast.js +23 -0
- package/lib/transpiler-new/codegen.js +2455 -0
- package/lib/transpiler-new/errors.js +28 -0
- package/lib/transpiler-new/index.js +26 -0
- package/lib/transpiler-new/lexer.js +834 -0
- package/lib/transpiler-new/parser.js +2332 -0
- package/lib/transpiler-new/validate-bindings.js +326 -0
- package/lib/transpiler-utils.js +95 -0
- package/lib/transpiler.js +33 -0
- package/lib/zuzu.js +53 -0
- package/modules/javascript.js +193 -0
- package/modules/std/archive.js +603 -0
- package/modules/std/clib.js +338 -0
- package/modules/std/data/csv.js +1331 -0
- package/modules/std/data/json.js +531 -0
- package/modules/std/data/xml.js +441 -0
- package/modules/std/data/yaml.js +256 -0
- package/modules/std/db-worker.js +250 -0
- package/modules/std/db.js +664 -0
- package/modules/std/digest/_hash.js +443 -0
- package/modules/std/digest/md5.js +26 -0
- package/modules/std/digest/sha.js +72 -0
- package/modules/std/eval.js +10 -0
- package/modules/std/gui/objects.js +1519 -0
- package/modules/std/internals.js +571 -0
- package/modules/std/io/socks-worker.js +318 -0
- package/modules/std/io/socks.js +186 -0
- package/modules/std/io.js +475 -0
- package/modules/std/marshal/cbor.js +463 -0
- package/modules/std/marshal/graph.js +1624 -0
- package/modules/std/marshal.js +87 -0
- package/modules/std/math/bignum.js +91 -0
- package/modules/std/math.js +79 -0
- package/modules/std/net/dns.js +306 -0
- package/modules/std/net/http.js +820 -0
- package/modules/std/net/smtp.js +943 -0
- package/modules/std/net/url.js +109 -0
- package/modules/std/proc.js +602 -0
- package/modules/std/secure.js +3724 -0
- package/modules/std/string/base64.js +138 -0
- package/modules/std/string.js +299 -0
- package/modules/std/task.js +914 -0
- package/modules/std/time.js +579 -0
- package/modules/std/tui.js +188 -0
- package/modules/std/worker-thread.js +246 -0
- package/modules/std/worker.js +790 -0
- package/package.json +67 -0
- package/stdlib/modules/javascript.zzm +99 -0
- package/stdlib/modules/perl.zzm +105 -0
- package/stdlib/modules/std/archive.zzm +132 -0
- package/stdlib/modules/std/cache/lru.zzm +174 -0
- package/stdlib/modules/std/clib.zzm +112 -0
- package/stdlib/modules/std/colour.zzm +220 -0
- package/stdlib/modules/std/config.zzm +818 -0
- package/stdlib/modules/std/data/cbor.zzm +497 -0
- package/stdlib/modules/std/data/csv.zzm +285 -0
- package/stdlib/modules/std/data/ini.zzm +472 -0
- package/stdlib/modules/std/data/json/schema/core.zzm +573 -0
- package/stdlib/modules/std/data/json/schema/format.zzm +581 -0
- package/stdlib/modules/std/data/json/schema/model.zzm +255 -0
- package/stdlib/modules/std/data/json/schema/output.zzm +272 -0
- package/stdlib/modules/std/data/json/schema/relative_pointer.zzm +299 -0
- package/stdlib/modules/std/data/json/schema/validation.zzm +1503 -0
- package/stdlib/modules/std/data/json/schema.zzm +306 -0
- package/stdlib/modules/std/data/json.zzm +102 -0
- package/stdlib/modules/std/data/kdl/json.zzm +460 -0
- package/stdlib/modules/std/data/kdl/xml.zzm +387 -0
- package/stdlib/modules/std/data/kdl.zzm +1631 -0
- package/stdlib/modules/std/data/toml.zzm +756 -0
- package/stdlib/modules/std/data/toon.zzm +1017 -0
- package/stdlib/modules/std/data/xml/escape.zzm +156 -0
- package/stdlib/modules/std/data/xml.zzm +276 -0
- package/stdlib/modules/std/data/yaml.zzm +94 -0
- package/stdlib/modules/std/db.zzm +173 -0
- package/stdlib/modules/std/defer.zzm +75 -0
- package/stdlib/modules/std/digest/crc32.zzm +196 -0
- package/stdlib/modules/std/digest/md5.zzm +54 -0
- package/stdlib/modules/std/digest/sha.zzm +83 -0
- package/stdlib/modules/std/dump.zzm +317 -0
- package/stdlib/modules/std/eval.zzm +63 -0
- package/stdlib/modules/std/getopt.zzm +432 -0
- package/stdlib/modules/std/gui/dialogue.zzm +592 -0
- package/stdlib/modules/std/gui/objects.zzm +123 -0
- package/stdlib/modules/std/gui.zzm +1914 -0
- package/stdlib/modules/std/internals.zzm +139 -0
- package/stdlib/modules/std/io/socks.zzm +139 -0
- package/stdlib/modules/std/io.zzm +157 -0
- package/stdlib/modules/std/lingua/en.zzm +347 -0
- package/stdlib/modules/std/log.zzm +169 -0
- package/stdlib/modules/std/mail.zzm +2726 -0
- package/stdlib/modules/std/marshal.zzm +138 -0
- package/stdlib/modules/std/math/bignum.zzm +98 -0
- package/stdlib/modules/std/math/range.zzm +116 -0
- package/stdlib/modules/std/math/roman.zzm +156 -0
- package/stdlib/modules/std/math.zzm +141 -0
- package/stdlib/modules/std/net/dns.zzm +93 -0
- package/stdlib/modules/std/net/http.zzm +278 -0
- package/stdlib/modules/std/net/smtp.zzm +257 -0
- package/stdlib/modules/std/net/url.zzm +69 -0
- package/stdlib/modules/std/path/jsonpointer.zzm +526 -0
- package/stdlib/modules/std/path/kdl.zzm +1003 -0
- package/stdlib/modules/std/path/simple.zzm +520 -0
- package/stdlib/modules/std/path/z/context.zzm +147 -0
- package/stdlib/modules/std/path/z/evaluate.zzm +549 -0
- package/stdlib/modules/std/path/z/functions.zzm +874 -0
- package/stdlib/modules/std/path/z/lexer.zzm +490 -0
- package/stdlib/modules/std/path/z/node.zzm +1455 -0
- package/stdlib/modules/std/path/z/operators.zzm +445 -0
- package/stdlib/modules/std/path/z/parser.zzm +359 -0
- package/stdlib/modules/std/path/z.zzm +403 -0
- package/stdlib/modules/std/path/zz/functions.zzm +828 -0
- package/stdlib/modules/std/path/zz/operators.zzm +1036 -0
- package/stdlib/modules/std/path/zz.zzm +100 -0
- package/stdlib/modules/std/proc.zzm +155 -0
- package/stdlib/modules/std/result.zzm +149 -0
- package/stdlib/modules/std/secure.zzm +606 -0
- package/stdlib/modules/std/string/base64.zzm +66 -0
- package/stdlib/modules/std/string/quoted_printable.zzm +485 -0
- package/stdlib/modules/std/string.zzm +179 -0
- package/stdlib/modules/std/task.zzm +221 -0
- package/stdlib/modules/std/template/z.zzm +531 -0
- package/stdlib/modules/std/template/zz.zzm +62 -0
- package/stdlib/modules/std/time.zzm +188 -0
- package/stdlib/modules/std/tui.zzm +89 -0
- package/stdlib/modules/std/uuid.zzm +223 -0
- package/stdlib/modules/std/web/session.zzm +388 -0
- package/stdlib/modules/std/web/static.zzm +329 -0
- package/stdlib/modules/std/web.zzm +1942 -0
- package/stdlib/modules/std/worker.zzm +202 -0
- package/stdlib/modules/std/zuzuzoo.zzm +3960 -0
- package/stdlib/modules/test/more.zzm +528 -0
- package/stdlib/modules/test/parser.zzm +209 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
=encoding utf8
|
|
2
|
+
|
|
3
|
+
=head1 NAME
|
|
4
|
+
|
|
5
|
+
std/internals - Runtime internals helpers for advanced modules.
|
|
6
|
+
|
|
7
|
+
=head1 SYNOPSIS
|
|
8
|
+
|
|
9
|
+
from std/internals import class_name, classof, object_slots, ansi_esc,
|
|
10
|
+
ref_id, to_String, to_Number, to_Boolean, to_Regexp,
|
|
11
|
+
to_Regexp_with_flags,
|
|
12
|
+
make_instance, setprop, getprop, load_module;
|
|
13
|
+
|
|
14
|
+
let obj_class := class_name(some_object);
|
|
15
|
+
let obj_class_value := classof(some_object);
|
|
16
|
+
let slots := object_slots(some_object);
|
|
17
|
+
let id := ref_id(some_object);
|
|
18
|
+
|
|
19
|
+
=head1 IMPLEMENTATION SUPPORT
|
|
20
|
+
|
|
21
|
+
This module is supported by all implementations of ZuzuScript.
|
|
22
|
+
|
|
23
|
+
=head1 DESCRIPTION
|
|
24
|
+
|
|
25
|
+
This module provides low-level reflection helpers used by advanced
|
|
26
|
+
pure-Zuzu modules (for example C<std/dump>). These functions are
|
|
27
|
+
not intended for general application code.
|
|
28
|
+
|
|
29
|
+
Special properties are lexical metadata, not symbol bindings.
|
|
30
|
+
Calling C<setprop("paths", SomeClass)> does not create an identifier
|
|
31
|
+
named C<paths>.
|
|
32
|
+
|
|
33
|
+
=head1 EXPORTS
|
|
34
|
+
|
|
35
|
+
=head2 Functions
|
|
36
|
+
|
|
37
|
+
=over
|
|
38
|
+
|
|
39
|
+
=item * C<class_name(value)>
|
|
40
|
+
|
|
41
|
+
Parameters: C<value> is any value. Returns: C<String> or C<null>.
|
|
42
|
+
Returns the class name for object instances.
|
|
43
|
+
|
|
44
|
+
=item * C<classof(value)>
|
|
45
|
+
|
|
46
|
+
Parameters: C<value> is any value. Returns: class value or C<null>.
|
|
47
|
+
Returns the class value for object and collection values.
|
|
48
|
+
|
|
49
|
+
=item * C<object_slots(value)>
|
|
50
|
+
|
|
51
|
+
Parameters: C<value> is any value. Returns: C<Dict> or C<null>. Returns
|
|
52
|
+
a dictionary of object slots, excluding private underscore-prefixed
|
|
53
|
+
slots.
|
|
54
|
+
|
|
55
|
+
=item * C<ansi_esc()>
|
|
56
|
+
|
|
57
|
+
Parameters: none. Returns: C<String>. Returns a one-character ANSI
|
|
58
|
+
escape string.
|
|
59
|
+
|
|
60
|
+
=item * C<ref_id(value)>
|
|
61
|
+
|
|
62
|
+
Parameters: C<value> is any value. Returns: C<String> or C<null>.
|
|
63
|
+
Returns a stable reference id for reference-like values to support cycle
|
|
64
|
+
detection.
|
|
65
|
+
|
|
66
|
+
=item * C<to_String(value)>
|
|
67
|
+
|
|
68
|
+
Parameters: C<value> is any value. Returns: C<String>. Coerces
|
|
69
|
+
C<value> using the same rules as string operators.
|
|
70
|
+
|
|
71
|
+
=item * C<to_Number(value)>
|
|
72
|
+
|
|
73
|
+
Parameters: C<value> is any value. Returns: C<Number>. Coerces
|
|
74
|
+
C<value> using the same rules as numeric operators.
|
|
75
|
+
|
|
76
|
+
=item * C<to_Boolean(value)>
|
|
77
|
+
|
|
78
|
+
Parameters: C<value> is any value. Returns: C<Boolean>. Coerces
|
|
79
|
+
C<value> using the same rules as logical operators and conditions.
|
|
80
|
+
|
|
81
|
+
=item * C<to_Regexp(value)>
|
|
82
|
+
|
|
83
|
+
Parameters: C<value> is a regexp or pattern-like value. Returns:
|
|
84
|
+
C<Regexp>. Returns C<value> unchanged when it is a regexp, otherwise
|
|
85
|
+
coerces it to a string and compiles it as a regexp.
|
|
86
|
+
|
|
87
|
+
=item * C<to_Regexp_with_flags(value, flags)>
|
|
88
|
+
|
|
89
|
+
Parameters: C<value> is a regexp or pattern-like value and C<flags> is a
|
|
90
|
+
string of regexp flags. Returns: C<Regexp>. Coerces C<value> to a pattern
|
|
91
|
+
and compiles it using C<flags>.
|
|
92
|
+
|
|
93
|
+
=item * C<make_instance(klass, dict := null)>
|
|
94
|
+
|
|
95
|
+
Parameters: C<klass> is a class value and C<dict> is an optional slot
|
|
96
|
+
dictionary. Returns: object. Creates an instance without calling
|
|
97
|
+
C<__build__>.
|
|
98
|
+
|
|
99
|
+
=item * C<load_module(module, symbol := null)>
|
|
100
|
+
|
|
101
|
+
Parameters: C<module> is a module name and C<symbol> is an optional
|
|
102
|
+
export name. Returns: C<Dict> or value. Loads a module and returns all
|
|
103
|
+
exports, or one named export.
|
|
104
|
+
|
|
105
|
+
=item * C<setprop(key, value)>
|
|
106
|
+
|
|
107
|
+
Parameters: C<key> is a string and C<value> is any value. Returns:
|
|
108
|
+
C<null>. Sets a lexically scoped runtime special property on the current
|
|
109
|
+
frame.
|
|
110
|
+
|
|
111
|
+
=item * C<getprop(key)>
|
|
112
|
+
|
|
113
|
+
Parameters: C<key> is a string. Returns: value or C<null>. Returns a
|
|
114
|
+
lexically scoped runtime special property via outward lexical lookup.
|
|
115
|
+
|
|
116
|
+
=back
|
|
117
|
+
|
|
118
|
+
=head1 EXAMPLES
|
|
119
|
+
|
|
120
|
+
from std/internals import setprop, getprop;
|
|
121
|
+
from std/path/z import ZPath;
|
|
122
|
+
|
|
123
|
+
setprop( "paths", ZPath );
|
|
124
|
+
say( getprop( "paths" ) ); // Class object
|
|
125
|
+
|
|
126
|
+
do {
|
|
127
|
+
setprop( "paths", null );
|
|
128
|
+
say( getprop( "paths" ) ); // null (shadowed in this block)
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
say( getprop( "paths" ) ); // ZPath (outer lexical value)
|
|
132
|
+
|
|
133
|
+
=head1 COPYRIGHT AND LICENCE
|
|
134
|
+
|
|
135
|
+
B<< std/internals >> is copyright Toby Inkster.
|
|
136
|
+
|
|
137
|
+
It is free software; you may redistribute it and/or modify it under
|
|
138
|
+
the terms of either the Artistic License 1.0 or the GNU General Public
|
|
139
|
+
License version 2.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
=encoding utf8
|
|
2
|
+
|
|
3
|
+
=head1 NAME
|
|
4
|
+
|
|
5
|
+
std/io/socks - socket programming helpers for Zuzu.
|
|
6
|
+
|
|
7
|
+
=head1 SYNOPSIS
|
|
8
|
+
|
|
9
|
+
from std/io/socks import *;
|
|
10
|
+
|
|
11
|
+
let srv := listen_tcp( "127.0.0.1", 0 );
|
|
12
|
+
let cli := connect_tcp( "127.0.0.1", srv.port() );
|
|
13
|
+
let peer := srv.accept();
|
|
14
|
+
|
|
15
|
+
cli.say( "hello" );
|
|
16
|
+
let line := peer.next_line();
|
|
17
|
+
|
|
18
|
+
=head1 IMPLEMENTATION SUPPORT
|
|
19
|
+
|
|
20
|
+
This module is supported by zuzu.pl, zuzu-rust, and zuzu-js on Node and
|
|
21
|
+
Electron. It is not supported by zuzu-js in the browser.
|
|
22
|
+
|
|
23
|
+
=head1 DESCRIPTION
|
|
24
|
+
|
|
25
|
+
This module provides a practical API for TCP, UDP, and Unix domain
|
|
26
|
+
sockets.
|
|
27
|
+
|
|
28
|
+
When possible, method names mirror other stream APIs:
|
|
29
|
+
C<read>, C<write>, C<print>, C<say>, C<next_line>,
|
|
30
|
+
C<each_line>, and C<close>.
|
|
31
|
+
|
|
32
|
+
=head1 EXPORTS
|
|
33
|
+
|
|
34
|
+
=head2 Functions
|
|
35
|
+
|
|
36
|
+
=over
|
|
37
|
+
|
|
38
|
+
=item C<< listen_tcp(String host?, Number port?, Number backlog?) >>
|
|
39
|
+
|
|
40
|
+
Parameters: C<host>, C<port>, and C<backlog> are optional bind
|
|
41
|
+
settings. Returns: C<TCPServer>. Creates a TCP listening socket.
|
|
42
|
+
|
|
43
|
+
=item C<< connect_tcp(String host, Number port, Bool raw?) >>
|
|
44
|
+
|
|
45
|
+
Parameters: C<host> and C<port> identify the server, and C<raw> controls
|
|
46
|
+
line decoding. Returns: C<TCPSocket>. Connects to a TCP server.
|
|
47
|
+
|
|
48
|
+
=item C<< bind_udp(String host?, Number port?, Bool raw?) >>
|
|
49
|
+
|
|
50
|
+
Parameters: C<host>, C<port>, and C<raw> are optional bind settings.
|
|
51
|
+
Returns: C<UDPSocket>. Binds a UDP socket.
|
|
52
|
+
|
|
53
|
+
=item C<< connect_udp(String host, Number port, Bool raw?) >>
|
|
54
|
+
|
|
55
|
+
Parameters: C<host> and C<port> identify the peer, and C<raw> controls
|
|
56
|
+
byte handling. Returns: C<UDPSocket>. Creates a connected UDP socket.
|
|
57
|
+
|
|
58
|
+
=item C<< listen_unix(String path, Number backlog?) >>
|
|
59
|
+
|
|
60
|
+
Parameters: C<path> is the socket path and C<backlog> is optional.
|
|
61
|
+
Returns: C<UnixServer>. Creates a Unix domain stream server.
|
|
62
|
+
|
|
63
|
+
=item C<< connect_unix(String path, Bool raw?) >>
|
|
64
|
+
|
|
65
|
+
Parameters: C<path> is the socket path and C<raw> controls line
|
|
66
|
+
decoding. Returns: C<UnixSocket>. Connects to a Unix domain stream
|
|
67
|
+
server.
|
|
68
|
+
|
|
69
|
+
=back
|
|
70
|
+
|
|
71
|
+
=head2 Classes
|
|
72
|
+
|
|
73
|
+
=head3 Socket methods
|
|
74
|
+
|
|
75
|
+
=over
|
|
76
|
+
|
|
77
|
+
=item C<< socket.read(Number length?) >>
|
|
78
|
+
|
|
79
|
+
Parameters: C<length> is an optional byte count. Returns:
|
|
80
|
+
C<BinaryString> or C<String>. Reads data from the socket.
|
|
81
|
+
|
|
82
|
+
=item C<< socket.write(value) >>, C<< socket.print(value) >>, C<< socket.say(value) >>
|
|
83
|
+
|
|
84
|
+
Parameters: C<value> is data to send. Returns: C<null>. Writes data to
|
|
85
|
+
the socket, with C<say> adding a newline.
|
|
86
|
+
|
|
87
|
+
=item C<< socket.next_line() >>
|
|
88
|
+
|
|
89
|
+
Parameters: none. Returns: C<String>, C<BinaryString>, or C<null>.
|
|
90
|
+
Reads the next line.
|
|
91
|
+
|
|
92
|
+
=item C<< socket.each_line(callback) >>
|
|
93
|
+
|
|
94
|
+
Parameters: C<callback> is called for each line. Returns: C<null>.
|
|
95
|
+
Iterates over incoming lines.
|
|
96
|
+
|
|
97
|
+
=item C<< socket.close() >>
|
|
98
|
+
|
|
99
|
+
Parameters: none. Returns: C<null>. Closes the socket.
|
|
100
|
+
|
|
101
|
+
=item C<< socket.is_open() >>
|
|
102
|
+
|
|
103
|
+
Parameters: none. Returns: C<Boolean>. Returns true when the socket is
|
|
104
|
+
open.
|
|
105
|
+
|
|
106
|
+
=back
|
|
107
|
+
|
|
108
|
+
=head3 TCPSocket
|
|
109
|
+
|
|
110
|
+
C<peer_host()> and C<peer_port()> take no parameters and return the
|
|
111
|
+
remote host C<String> and port C<Number>.
|
|
112
|
+
|
|
113
|
+
=head3 TCPServer
|
|
114
|
+
|
|
115
|
+
C<accept()> returns C<TCPSocket>, C<port()> returns C<Number>,
|
|
116
|
+
C<host()> returns C<String>, and C<close()> closes the server and
|
|
117
|
+
returns C<null>.
|
|
118
|
+
|
|
119
|
+
=head3 UDPSocket
|
|
120
|
+
|
|
121
|
+
C<send(value, host?, port?)> returns C<null>; C<recv()> returns a
|
|
122
|
+
received datagram value; C<port()> and C<host()> return the bound port
|
|
123
|
+
and host; C<close()> closes the socket.
|
|
124
|
+
|
|
125
|
+
=head3 UnixSocket / UnixServer
|
|
126
|
+
|
|
127
|
+
Unix sockets support stream methods, and C<UnixServer> offers
|
|
128
|
+
C<accept()> returning C<UnixSocket>, C<path()> returning C<String>, and
|
|
129
|
+
C<close()> returning C<null>.
|
|
130
|
+
|
|
131
|
+
=head1 COPYRIGHT AND LICENCE
|
|
132
|
+
|
|
133
|
+
B<< std/io/socks >> is copyright Toby Inkster.
|
|
134
|
+
|
|
135
|
+
It is free software; you may redistribute it and/or modify it under
|
|
136
|
+
the terms of either the Artistic License 1.0 or the GNU General Public
|
|
137
|
+
License version 2.
|
|
138
|
+
|
|
139
|
+
=cut
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
=encoding utf8
|
|
2
|
+
|
|
3
|
+
=head1 NAME
|
|
4
|
+
|
|
5
|
+
std/io - Filesystem paths and standard stream helpers.
|
|
6
|
+
|
|
7
|
+
=head1 SYNOPSIS
|
|
8
|
+
|
|
9
|
+
from std/io import Path, STDIN, STDOUT, STDERR;
|
|
10
|
+
|
|
11
|
+
let p := new Path("notes.txt");
|
|
12
|
+
p.spew_utf8("hello\n");
|
|
13
|
+
|
|
14
|
+
p.each_line( line => {
|
|
15
|
+
STDOUT.print(line);
|
|
16
|
+
} );
|
|
17
|
+
|
|
18
|
+
=head1 IMPLEMENTATION SUPPORT
|
|
19
|
+
|
|
20
|
+
This module is supported by zuzu.pl, zuzu-rust, and zuzu-js on Node and
|
|
21
|
+
Electron. It is not supported by zuzu-js in the browser.
|
|
22
|
+
|
|
23
|
+
=head1 DESCRIPTION
|
|
24
|
+
|
|
25
|
+
This module provides path objects built on path semantics, an
|
|
26
|
+
iterator for directory traversal, and objects for standard I/O
|
|
27
|
+
streams.
|
|
28
|
+
|
|
29
|
+
=head1 EXPORTS
|
|
30
|
+
|
|
31
|
+
=head2 Classes
|
|
32
|
+
|
|
33
|
+
=over
|
|
34
|
+
|
|
35
|
+
=item C<Path>
|
|
36
|
+
|
|
37
|
+
Represents a filesystem path.
|
|
38
|
+
|
|
39
|
+
Construction and conversion:
|
|
40
|
+
|
|
41
|
+
=over
|
|
42
|
+
|
|
43
|
+
=item * C<< new Path(String path = "") >>
|
|
44
|
+
|
|
45
|
+
=item * C<to_String>
|
|
46
|
+
|
|
47
|
+
=back
|
|
48
|
+
|
|
49
|
+
Path queries and transforms:
|
|
50
|
+
|
|
51
|
+
=over
|
|
52
|
+
|
|
53
|
+
=item * C<basename>, C<canonpath>, C<realpath>, C<volume>
|
|
54
|
+
|
|
55
|
+
=item * C<absolute>, C<child>, C<parent>, C<sibling>
|
|
56
|
+
|
|
57
|
+
=item * C<is_absolute>, C<is_relative>, C<is_rootdir>
|
|
58
|
+
|
|
59
|
+
=item * C<subsumes>, C<exists>, C<is_file>, C<is_dir>
|
|
60
|
+
|
|
61
|
+
=back
|
|
62
|
+
|
|
63
|
+
Filesystem actions:
|
|
64
|
+
|
|
65
|
+
=over
|
|
66
|
+
|
|
67
|
+
=item * C<copy>, C<move>, C<remove>, C<mkdir>, C<mkdir_exclusive>,
|
|
68
|
+
C<remove_tree>
|
|
69
|
+
|
|
70
|
+
C<mkdir_exclusive()> performs one non-recursive directory creation
|
|
71
|
+
attempt. It returns true if the directory was created, false if the
|
|
72
|
+
path already exists, and throws for other filesystem errors.
|
|
73
|
+
|
|
74
|
+
=item * C<touch>, C<touchpath>, C<chmod>
|
|
75
|
+
|
|
76
|
+
=item * C<size>, C<size_human>, C<stat>, C<lstat>
|
|
77
|
+
|
|
78
|
+
=back
|
|
79
|
+
|
|
80
|
+
Text and binary I/O:
|
|
81
|
+
|
|
82
|
+
=over
|
|
83
|
+
|
|
84
|
+
=item * C<spew>, C<append>, C<slurp>, C<lines> (BinaryString)
|
|
85
|
+
|
|
86
|
+
=item * C<spew_utf8>, C<append_utf8>, C<slurp_utf8>, C<lines_utf8> (String)
|
|
87
|
+
|
|
88
|
+
=item * C<spew_async>, C<append_async>, C<slurp_async>, C<lines_async>
|
|
89
|
+
return awaitable C<Task> values for binary file I/O
|
|
90
|
+
|
|
91
|
+
=item * C<spew_utf8_async>, C<append_utf8_async>, C<slurp_utf8_async>,
|
|
92
|
+
C<lines_utf8_async> return awaitable C<Task> values for UTF-8 file I/O
|
|
93
|
+
|
|
94
|
+
=item * C<edit_lines>, C<edit_lines_utf8>
|
|
95
|
+
|
|
96
|
+
=item * C<each_line(callback, raw?)> where C<raw=true> yields C<BinaryString>
|
|
97
|
+
|
|
98
|
+
=item * C<next_line(raw?)> where C<raw=true> returns C<BinaryString>
|
|
99
|
+
|
|
100
|
+
=back
|
|
101
|
+
|
|
102
|
+
Traversal helpers:
|
|
103
|
+
|
|
104
|
+
=over
|
|
105
|
+
|
|
106
|
+
=item * C<children(...)>
|
|
107
|
+
|
|
108
|
+
=item * C<iterator(...)> returning C<PathIterator>
|
|
109
|
+
|
|
110
|
+
=item * C<visit(callback, ...)>
|
|
111
|
+
|
|
112
|
+
=back
|
|
113
|
+
|
|
114
|
+
Static helpers:
|
|
115
|
+
|
|
116
|
+
=over
|
|
117
|
+
|
|
118
|
+
=item * C<Path.cwd()>, C<Path.rootdir()>
|
|
119
|
+
|
|
120
|
+
=item * C<Path.tempfile(...)>, C<Path.tempdir(...)>
|
|
121
|
+
|
|
122
|
+
=item * C<Path.glob(pattern, options?)>
|
|
123
|
+
|
|
124
|
+
=item * C<Path.join(parts)>
|
|
125
|
+
|
|
126
|
+
=item * C<Path.split(path)>
|
|
127
|
+
|
|
128
|
+
=item * C<Path.normalize(path)>
|
|
129
|
+
|
|
130
|
+
=back
|
|
131
|
+
|
|
132
|
+
=item C<PathIterator>
|
|
133
|
+
|
|
134
|
+
Directory iterator object with C<next()>.
|
|
135
|
+
|
|
136
|
+
=item C<STDIN>
|
|
137
|
+
|
|
138
|
+
Read helpers: C<next_line(raw?)>, C<each_line(callback, raw?)>.
|
|
139
|
+
With C<raw=true>, values are C<BinaryString>; otherwise C<String>.
|
|
140
|
+
|
|
141
|
+
=item C<STDOUT>
|
|
142
|
+
|
|
143
|
+
Write helpers: C<print(...)>, C<say(...)>.
|
|
144
|
+
|
|
145
|
+
=item C<STDERR>
|
|
146
|
+
|
|
147
|
+
Write helpers: C<print(...)>, C<say(...)>.
|
|
148
|
+
|
|
149
|
+
=back
|
|
150
|
+
|
|
151
|
+
=head1 COPYRIGHT AND LICENCE
|
|
152
|
+
|
|
153
|
+
B<< std/io >> is copyright Toby Inkster.
|
|
154
|
+
|
|
155
|
+
It is free software; you may redistribute it and/or modify it under
|
|
156
|
+
the terms of either the Artistic License 1.0 or the GNU General Public
|
|
157
|
+
License version 2.
|