whet 0.0.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 +21 -0
- package/README.md +47 -0
- package/bin/HxOverrides.d.ts +8 -0
- package/bin/HxOverrides.js +54 -0
- package/bin/Lambda.d.ts +86 -0
- package/bin/Lambda.js +141 -0
- package/bin/Map.d.ts +5 -0
- package/bin/Reflect.d.ts +19 -0
- package/bin/Reflect.js +41 -0
- package/bin/Std.d.ts +49 -0
- package/bin/Std.js +96 -0
- package/bin/StdTypes.d.ts +57 -0
- package/bin/StringTools.d.ts +23 -0
- package/bin/StringTools.js +36 -0
- package/bin/commander/AddHelpTextContext.d.ts +6 -0
- package/bin/commander/AddHelpTextPosition.d.ts +2 -0
- package/bin/commander/CommandOptions.d.ts +6 -0
- package/bin/commander/ErrorOptions.d.ts +11 -0
- package/bin/commander/ExecutableCommandOptions.d.ts +7 -0
- package/bin/commander/HelpContext.d.ts +4 -0
- package/bin/commander/HookEvent.d.ts +2 -0
- package/bin/commander/OptionValueSource.d.ts +2 -0
- package/bin/commander/OutputConfiguration.d.ts +8 -0
- package/bin/commander/ParseOptions.d.ts +4 -0
- package/bin/commander/ParseOptionsResult.d.ts +5 -0
- package/bin/genes/Register.d.ts +15 -0
- package/bin/genes/Register.js +107 -0
- package/bin/genes/util/EsMap.d.ts +12 -0
- package/bin/genes/util/EsMap.js +51 -0
- package/bin/haxe/Constraints.d.ts +8 -0
- package/bin/haxe/Constraints.js +5 -0
- package/bin/haxe/Exception.d.ts +66 -0
- package/bin/haxe/Exception.js +88 -0
- package/bin/haxe/NativeStackTrace.d.ts +7 -0
- package/bin/haxe/PosInfos.d.ts +19 -0
- package/bin/haxe/Rest.d.ts +2 -0
- package/bin/haxe/ValueException.d.ts +24 -0
- package/bin/haxe/ValueException.js +36 -0
- package/bin/haxe/crypto/Crc32.d.ts +12 -0
- package/bin/haxe/crypto/Crc32.js +40 -0
- package/bin/haxe/ds/List.d.ts +31 -0
- package/bin/haxe/ds/List.js +55 -0
- package/bin/haxe/ds/ObjectMap.d.ts +7 -0
- package/bin/haxe/ds/ObjectMap.js +25 -0
- package/bin/haxe/ds/StringMap.d.ts +6 -0
- package/bin/haxe/ds/StringMap.js +25 -0
- package/bin/haxe/exceptions/NotImplementedException.d.ts +10 -0
- package/bin/haxe/exceptions/NotImplementedException.js +27 -0
- package/bin/haxe/exceptions/PosException.d.ts +19 -0
- package/bin/haxe/exceptions/PosException.js +36 -0
- package/bin/haxe/extern/Rest.d.ts +11 -0
- package/bin/haxe/io/ArrayBufferView.d.ts +2 -0
- package/bin/haxe/io/Bytes.d.ts +19 -0
- package/bin/haxe/io/Bytes.js +78 -0
- package/bin/haxe/io/BytesBuffer.d.ts +19 -0
- package/bin/haxe/io/BytesBuffer.js +67 -0
- package/bin/haxe/io/BytesData.d.ts +2 -0
- package/bin/haxe/io/BytesOutput.d.ts +18 -0
- package/bin/haxe/io/BytesOutput.js +39 -0
- package/bin/haxe/io/Encoding.d.ts +20 -0
- package/bin/haxe/io/Encoding.js +20 -0
- package/bin/haxe/io/Error.d.ts +35 -0
- package/bin/haxe/io/Error.js +31 -0
- package/bin/haxe/io/Output.d.ts +63 -0
- package/bin/haxe/io/Output.js +126 -0
- package/bin/haxe/io/Path.d.ts +109 -0
- package/bin/haxe/io/Path.js +217 -0
- package/bin/haxe/io/UInt8Array.d.ts +2 -0
- package/bin/haxe/iterators/ArrayIterator.d.ts +19 -0
- package/bin/haxe/iterators/ArrayIterator.js +35 -0
- package/bin/haxe/macro/Expr.d.ts +331 -0
- package/bin/haxe/macro/Type.d.ts +609 -0
- package/bin/haxe/zip/Compress.d.ts +5 -0
- package/bin/haxe/zip/Compress.js +21 -0
- package/bin/haxe/zip/Entry.d.ts +27 -0
- package/bin/haxe/zip/Entry.js +15 -0
- package/bin/haxe/zip/Tools.d.ts +5 -0
- package/bin/haxe/zip/Tools.js +24 -0
- package/bin/haxe/zip/Writer.d.ts +22 -0
- package/bin/haxe/zip/Writer.js +149 -0
- package/bin/js/Boot.d.ts +18 -0
- package/bin/js/Boot.js +225 -0
- package/bin/js/Node.d.ts +6 -0
- package/bin/js/lib/ArrayBuffer.d.ts +4 -0
- package/bin/js/lib/ArrayBuffer.js +24 -0
- package/bin/js/lib/Iterator.d.ts +23 -0
- package/bin/js/lib/Map.d.ts +2 -0
- package/bin/js/lib/Object.d.ts +82 -0
- package/bin/js/lib/Promise.d.ts +10 -0
- package/bin/js/lib/intl/NumberFormat.d.ts +114 -0
- package/bin/js/node/Buffer.d.ts +3 -0
- package/bin/js/node/ChildProcess.d.ts +424 -0
- package/bin/js/node/Crypto.d.ts +21 -0
- package/bin/js/node/Dns.d.ts +57 -0
- package/bin/js/node/Fs.d.ts +308 -0
- package/bin/js/node/Http.d.ts +114 -0
- package/bin/js/node/Https.d.ts +330 -0
- package/bin/js/node/Iterator.d.ts +5 -0
- package/bin/js/node/Path.d.ts +44 -0
- package/bin/js/node/Process.d.ts +6 -0
- package/bin/js/node/Tls.d.ts +304 -0
- package/bin/js/node/Url.d.ts +126 -0
- package/bin/js/node/Util.d.ts +115 -0
- package/bin/js/node/Zlib.d.ts +29 -0
- package/bin/js/node/buffer/Buffer.d.ts +23 -0
- package/bin/js/node/buffer/Buffer.js +24 -0
- package/bin/js/node/child_process/ChildProcess.d.ts +11 -0
- package/bin/js/node/console/Console.d.ts +26 -0
- package/bin/js/node/http/Agent.d.ts +40 -0
- package/bin/js/node/http/ClientRequest.d.ts +10 -0
- package/bin/js/node/https/Agent.d.ts +50 -0
- package/bin/js/node/net/Server.d.ts +22 -0
- package/bin/js/node/net/Socket.d.ts +101 -0
- package/bin/js/node/stream/Duplex.d.ts +86 -0
- package/bin/js/node/stream/Readable.d.ts +41 -0
- package/bin/js/node/stream/Transform.d.ts +92 -0
- package/bin/js/node/stream/Writable.d.ts +57 -0
- package/bin/js/node/tls/SecureContext.d.ts +74 -0
- package/bin/js/node/tls/TLSSocket.d.ts +47 -0
- package/bin/ts/Undefined.d.ts +5 -0
- package/bin/whet/Log.d.ts +16 -0
- package/bin/whet/Log.js +106 -0
- package/bin/whet/Project.d.ts +33 -0
- package/bin/whet/Project.js +71 -0
- package/bin/whet/Source.d.ts +51 -0
- package/bin/whet/Source.js +136 -0
- package/bin/whet/SourceHash.d.ts +15 -0
- package/bin/whet/SourceHash.js +68 -0
- package/bin/whet/SourceId.d.ts +10 -0
- package/bin/whet/SourceId.js +74 -0
- package/bin/whet/Stone.d.ts +88 -0
- package/bin/whet/Stone.js +157 -0
- package/bin/whet/Utils.d.ts +16 -0
- package/bin/whet/Utils.js +72 -0
- package/bin/whet/Whet.d.ts +4 -0
- package/bin/whet/Whet.js +117 -0
- package/bin/whet/cache/BaseCache.d.ts +27 -0
- package/bin/whet/cache/BaseCache.js +210 -0
- package/bin/whet/cache/Cache.d.ts +72 -0
- package/bin/whet/cache/Cache.js +57 -0
- package/bin/whet/cache/CacheManager.d.ts +23 -0
- package/bin/whet/cache/CacheManager.js +103 -0
- package/bin/whet/cache/FileCache.d.ts +35 -0
- package/bin/whet/cache/FileCache.js +295 -0
- package/bin/whet/cache/MemoryCache.d.ts +12 -0
- package/bin/whet/cache/MemoryCache.js +58 -0
- package/bin/whet/magic/MaybeArray.d.ts +4 -0
- package/bin/whet/magic/MaybeArray.js +25 -0
- package/bin/whet/magic/RoutePathType.d.ts +9 -0
- package/bin/whet/magic/RoutePathType.js +48 -0
- package/bin/whet/magic/RouteType.d.ts +12 -0
- package/bin/whet/magic/RouteType.js +70 -0
- package/bin/whet/magic/StoneId.d.ts +5 -0
- package/bin/whet/magic/StoneId.js +32 -0
- package/bin/whet/route/Route.d.ts +15 -0
- package/bin/whet/route/Route.js +81 -0
- package/bin/whet/route/RouteResult.d.ts +22 -0
- package/bin/whet/route/RouteResult.js +25 -0
- package/bin/whet/route/Router.d.ts +33 -0
- package/bin/whet/route/Router.js +224 -0
- package/bin/whet/stones/Files.d.ts +28 -0
- package/bin/whet/stones/Files.js +86 -0
- package/bin/whet/stones/JsonStone.d.ts +33 -0
- package/bin/whet/stones/JsonStone.js +117 -0
- package/bin/whet/stones/RemoteFile.d.ts +28 -0
- package/bin/whet/stones/RemoteFile.js +71 -0
- package/bin/whet/stones/Server.d.ts +42 -0
- package/bin/whet/stones/Server.js +113 -0
- package/bin/whet/stones/Zip.d.ts +30 -0
- package/bin/whet/stones/Zip.js +111 -0
- package/bin/whet/stones/haxe/HaxeBuild.d.ts +34 -0
- package/bin/whet/stones/haxe/HaxeBuild.js +89 -0
- package/bin/whet/stones/haxe/Hxml.d.ts +102 -0
- package/bin/whet/stones/haxe/Hxml.js +348 -0
- package/bin/whet.d.ts +20 -0
- package/bin/whet.js +18 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Peter Achberger
|
|
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
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Whet
|
|
2
|
+
|
|
3
|
+
A NodeJS-based tool for managing things every project needs, such as configuration, build scripts, assets, etc., using a flexible everything-is-an-asset approach, with configurable caching.
|
|
4
|
+
|
|
5
|
+
## Project Files
|
|
6
|
+
|
|
7
|
+
Project files define a project, its [stones](#Stones). Their content defines what [commands](#Commands) are available.
|
|
8
|
+
|
|
9
|
+
## Stones
|
|
10
|
+
|
|
11
|
+
Stones (named after _whetstone_) are individual building blocks of a project.
|
|
12
|
+
|
|
13
|
+
They represent a single logical asset (can be multiple files) or functionality (e.g. a dev web server). Stones can use other stones (via routes), to achieve their objective, forming a dependency tree. E.g. a css file could be made by minifying a file generated from scss source, and each step could be individually cached.
|
|
14
|
+
|
|
15
|
+
### Stones Configuration
|
|
16
|
+
|
|
17
|
+
Stones try to keep all their state in a `config` object. Each stone requires it to be supplied. The `config` object should be designed for scripting, i.e. allow dynamic types as long as they make sense.
|
|
18
|
+
|
|
19
|
+
Reading and applying the configuration should be limited to generating resources/hashes from the stone. Invalid configuration therefore won't crash the project initialization until it's being used. This is just a guideline and not a requirement, and stones might validate the configuration immediately where it makes sense.
|
|
20
|
+
|
|
21
|
+
<!-- TODO: Implement, and then mention `project.getHash()` as a way to verify the whole project. -->
|
|
22
|
+
|
|
23
|
+
Some stones might provide helper methods to modify the configuration after it was passed in. Such methods might modify the `config` object, e.g. turning a single entry into array of them.
|
|
24
|
+
|
|
25
|
+
### Hashes
|
|
26
|
+
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
### Commands
|
|
30
|
+
|
|
31
|
+
...
|
|
32
|
+
|
|
33
|
+
## Routes And Routers
|
|
34
|
+
|
|
35
|
+
...
|
|
36
|
+
|
|
37
|
+
## Core Concepts
|
|
38
|
+
|
|
39
|
+
Project files should have no side effects, unless some of their commands are executed. They only process the active configuration, initializing the available commands.
|
|
40
|
+
|
|
41
|
+
<!-- TODO: document configuration handlers -->
|
|
42
|
+
|
|
43
|
+
All paths are in stored as absolute (starting with `/`), but are actually relative to root project directory. Path that is a directory ends with a `/`, otherwise it's considered a file. That means:
|
|
44
|
+
|
|
45
|
+
- `/assets/` is a **directory** called `assets` that's in the project root.
|
|
46
|
+
- `assets/` is a **directory** called `assets` that's relative to the structure within the project (routing/stones).
|
|
47
|
+
- `/assets` is a **file** called `assets` in the project root.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
export declare class HxOverrides {
|
|
3
|
+
protected static dateStr(date: Date): string
|
|
4
|
+
protected static cca(s: string, index: number): null | number
|
|
5
|
+
protected static substr(s: string, pos: number, len?: null | number): string
|
|
6
|
+
protected static remove<T>(a: T[], obj: T): boolean
|
|
7
|
+
protected static now(): number
|
|
8
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import {Register} from "./genes/Register.js"
|
|
2
|
+
|
|
3
|
+
const $global = Register.$global
|
|
4
|
+
|
|
5
|
+
export const HxOverrides = Register.global("$hxClasses")["HxOverrides"] =
|
|
6
|
+
class HxOverrides {
|
|
7
|
+
static dateStr(date) {
|
|
8
|
+
var m = date.getMonth() + 1;
|
|
9
|
+
var d = date.getDate();
|
|
10
|
+
var h = date.getHours();
|
|
11
|
+
var mi = date.getMinutes();
|
|
12
|
+
var s = date.getSeconds();
|
|
13
|
+
return date.getFullYear() + "-" + ((m < 10) ? "0" + m : "" + m) + "-" + ((d < 10) ? "0" + d : "" + d) + " " + ((h < 10) ? "0" + h : "" + h) + ":" + ((mi < 10) ? "0" + mi : "" + mi) + ":" + ((s < 10) ? "0" + s : "" + s);
|
|
14
|
+
}
|
|
15
|
+
static cca(s, index) {
|
|
16
|
+
var x = s.charCodeAt(index);
|
|
17
|
+
if (x != x) {
|
|
18
|
+
return undefined;
|
|
19
|
+
};
|
|
20
|
+
return x;
|
|
21
|
+
}
|
|
22
|
+
static substr(s, pos, len) {
|
|
23
|
+
if (len == null) {
|
|
24
|
+
len = s.length;
|
|
25
|
+
} else if (len < 0) {
|
|
26
|
+
if (pos == 0) {
|
|
27
|
+
len = s.length + len;
|
|
28
|
+
} else {
|
|
29
|
+
return "";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
return s.substr(pos, len);
|
|
33
|
+
}
|
|
34
|
+
static remove(a, obj) {
|
|
35
|
+
var i = a.indexOf(obj);
|
|
36
|
+
if (i == -1) {
|
|
37
|
+
return false;
|
|
38
|
+
};
|
|
39
|
+
a.splice(i, 1);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
static now() {
|
|
43
|
+
return Date.now();
|
|
44
|
+
}
|
|
45
|
+
static get __name__() {
|
|
46
|
+
return "HxOverrides"
|
|
47
|
+
}
|
|
48
|
+
get __class__() {
|
|
49
|
+
return HxOverrides
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
;((typeof(performance) != "undefined") ? typeof(performance.now) == "function" : false) ? HxOverrides.now = performance.now.bind(performance) : null
|
package/bin/Lambda.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import {List} from "./haxe/ds/List"
|
|
2
|
+
import {Iterable} from "./StdTypes"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
The `Lambda` class is a collection of methods to support functional
|
|
6
|
+
programming. It is ideally used with `using Lambda` and then acts as an
|
|
7
|
+
extension to Iterable types.
|
|
8
|
+
|
|
9
|
+
On static platforms, working with the Iterable structure might be slower
|
|
10
|
+
than performing the operations directly on known types, such as Array and
|
|
11
|
+
List.
|
|
12
|
+
|
|
13
|
+
If the first argument to any of the methods is null, the result is
|
|
14
|
+
unspecified.
|
|
15
|
+
|
|
16
|
+
@see https://haxe.org/manual/std-Lambda.html
|
|
17
|
+
*/
|
|
18
|
+
export declare class Lambda {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
Creates a List form Iterable `it`.
|
|
22
|
+
|
|
23
|
+
If `it` is a List, this function returns a copy of it.
|
|
24
|
+
*/
|
|
25
|
+
static list<A>(it: Iterable<A>): List<A>
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
Tells if `it` contains an element for which `f` is true.
|
|
29
|
+
|
|
30
|
+
This function returns true as soon as an element is found for which a
|
|
31
|
+
call to `f` returns true.
|
|
32
|
+
|
|
33
|
+
If no such element is found, the result is false.
|
|
34
|
+
|
|
35
|
+
If `f` is null, the result is unspecified.
|
|
36
|
+
*/
|
|
37
|
+
static exists<A>(it: Iterable<A>, f: ((item: A) => boolean)): boolean
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
Tells if `f` is true for all elements of `it`.
|
|
41
|
+
|
|
42
|
+
This function returns false as soon as an element is found for which a
|
|
43
|
+
call to `f` returns false.
|
|
44
|
+
|
|
45
|
+
If no such element is found, the result is true.
|
|
46
|
+
|
|
47
|
+
In particular, this function always returns true if `it` is empty.
|
|
48
|
+
|
|
49
|
+
If `f` is null, the result is unspecified.
|
|
50
|
+
*/
|
|
51
|
+
static foreach<A>(it: Iterable<A>, f: ((item: A) => boolean)): boolean
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
Functional fold on Iterable `it`, using function `f` with start argument
|
|
55
|
+
`first`.
|
|
56
|
+
|
|
57
|
+
If `it` has no elements, the result is `first`.
|
|
58
|
+
|
|
59
|
+
Otherwise the first element of `it` is passed to `f` alongside `first`.
|
|
60
|
+
The result of that call is then passed to `f` with the next element of
|
|
61
|
+
`it`, and so on until `it` has no more elements.
|
|
62
|
+
|
|
63
|
+
If `it` or `f` are null, the result is unspecified.
|
|
64
|
+
*/
|
|
65
|
+
static fold<B, A>(it: Iterable<A>, f: ((item: A, result: B) => B), first: B): B
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
Returns the number of elements in `it` for which `pred` is true, or the
|
|
69
|
+
total number of elements in `it` if `pred` is null.
|
|
70
|
+
|
|
71
|
+
This function traverses all elements.
|
|
72
|
+
*/
|
|
73
|
+
static count<A>(it: Iterable<A>, pred?: null | ((item: A) => boolean)): number
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
Returns the first element of `it` for which `f` is true.
|
|
77
|
+
|
|
78
|
+
This function returns as soon as an element is found for which a call to
|
|
79
|
+
`f` returns true.
|
|
80
|
+
|
|
81
|
+
If no such element is found, the result is null.
|
|
82
|
+
|
|
83
|
+
If `f` is null, the result is unspecified.
|
|
84
|
+
*/
|
|
85
|
+
static find<T>(it: Iterable<T>, f: ((item: T) => boolean)): null | T
|
|
86
|
+
}
|
package/bin/Lambda.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {List} from "./haxe/ds/List.js"
|
|
2
|
+
import {Register} from "./genes/Register.js"
|
|
3
|
+
|
|
4
|
+
const $global = Register.$global
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
The `Lambda` class is a collection of methods to support functional
|
|
8
|
+
programming. It is ideally used with `using Lambda` and then acts as an
|
|
9
|
+
extension to Iterable types.
|
|
10
|
+
|
|
11
|
+
On static platforms, working with the Iterable structure might be slower
|
|
12
|
+
than performing the operations directly on known types, such as Array and
|
|
13
|
+
List.
|
|
14
|
+
|
|
15
|
+
If the first argument to any of the methods is null, the result is
|
|
16
|
+
unspecified.
|
|
17
|
+
|
|
18
|
+
@see https://haxe.org/manual/std-Lambda.html
|
|
19
|
+
*/
|
|
20
|
+
export const Lambda = Register.global("$hxClasses")["Lambda"] =
|
|
21
|
+
class Lambda {
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
Creates a List form Iterable `it`.
|
|
25
|
+
|
|
26
|
+
If `it` is a List, this function returns a copy of it.
|
|
27
|
+
*/
|
|
28
|
+
static list(it) {
|
|
29
|
+
var l = new List();
|
|
30
|
+
var i = Register.iter(it);
|
|
31
|
+
while (i.hasNext()) l.add(i.next());
|
|
32
|
+
return l;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
Tells if `it` contains an element for which `f` is true.
|
|
37
|
+
|
|
38
|
+
This function returns true as soon as an element is found for which a
|
|
39
|
+
call to `f` returns true.
|
|
40
|
+
|
|
41
|
+
If no such element is found, the result is false.
|
|
42
|
+
|
|
43
|
+
If `f` is null, the result is unspecified.
|
|
44
|
+
*/
|
|
45
|
+
static exists(it, f) {
|
|
46
|
+
var x = Register.iter(it);
|
|
47
|
+
while (x.hasNext()) if (f(x.next())) {
|
|
48
|
+
return true;
|
|
49
|
+
};
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
Tells if `f` is true for all elements of `it`.
|
|
55
|
+
|
|
56
|
+
This function returns false as soon as an element is found for which a
|
|
57
|
+
call to `f` returns false.
|
|
58
|
+
|
|
59
|
+
If no such element is found, the result is true.
|
|
60
|
+
|
|
61
|
+
In particular, this function always returns true if `it` is empty.
|
|
62
|
+
|
|
63
|
+
If `f` is null, the result is unspecified.
|
|
64
|
+
*/
|
|
65
|
+
static foreach(it, f) {
|
|
66
|
+
var x = Register.iter(it);
|
|
67
|
+
while (x.hasNext()) if (!f(x.next())) {
|
|
68
|
+
return false;
|
|
69
|
+
};
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
Functional fold on Iterable `it`, using function `f` with start argument
|
|
75
|
+
`first`.
|
|
76
|
+
|
|
77
|
+
If `it` has no elements, the result is `first`.
|
|
78
|
+
|
|
79
|
+
Otherwise the first element of `it` is passed to `f` alongside `first`.
|
|
80
|
+
The result of that call is then passed to `f` with the next element of
|
|
81
|
+
`it`, and so on until `it` has no more elements.
|
|
82
|
+
|
|
83
|
+
If `it` or `f` are null, the result is unspecified.
|
|
84
|
+
*/
|
|
85
|
+
static fold(it, f, first) {
|
|
86
|
+
var x = Register.iter(it);
|
|
87
|
+
while (x.hasNext()) first = f(x.next(), first);
|
|
88
|
+
return first;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
Returns the number of elements in `it` for which `pred` is true, or the
|
|
93
|
+
total number of elements in `it` if `pred` is null.
|
|
94
|
+
|
|
95
|
+
This function traverses all elements.
|
|
96
|
+
*/
|
|
97
|
+
static count(it, pred) {
|
|
98
|
+
var n = 0;
|
|
99
|
+
if (pred == null) {
|
|
100
|
+
var _ = Register.iter(it);
|
|
101
|
+
while (_.hasNext()) {
|
|
102
|
+
_.next();
|
|
103
|
+
++n;
|
|
104
|
+
};
|
|
105
|
+
} else {
|
|
106
|
+
var x = Register.iter(it);
|
|
107
|
+
while (x.hasNext()) if (pred(x.next())) {
|
|
108
|
+
++n;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
return n;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
Returns the first element of `it` for which `f` is true.
|
|
116
|
+
|
|
117
|
+
This function returns as soon as an element is found for which a call to
|
|
118
|
+
`f` returns true.
|
|
119
|
+
|
|
120
|
+
If no such element is found, the result is null.
|
|
121
|
+
|
|
122
|
+
If `f` is null, the result is unspecified.
|
|
123
|
+
*/
|
|
124
|
+
static find(it, f) {
|
|
125
|
+
var v = Register.iter(it);
|
|
126
|
+
while (v.hasNext()) {
|
|
127
|
+
var v1 = v.next();
|
|
128
|
+
if (f(v1)) {
|
|
129
|
+
return v1;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
static get __name__() {
|
|
135
|
+
return "Lambda"
|
|
136
|
+
}
|
|
137
|
+
get __class__() {
|
|
138
|
+
return Lambda
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
package/bin/Map.d.ts
ADDED
package/bin/Reflect.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
The Reflect API is a way to manipulate values dynamically through an
|
|
4
|
+
abstract interface in an untyped manner. Use with care.
|
|
5
|
+
|
|
6
|
+
@see https://haxe.org/manual/std-reflection.html
|
|
7
|
+
*/
|
|
8
|
+
export declare class Reflect {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
Returns the fields of structure `o`.
|
|
12
|
+
|
|
13
|
+
This method is only guaranteed to work on anonymous structures. Refer to
|
|
14
|
+
`Type.getInstanceFields` for a function supporting class instances.
|
|
15
|
+
|
|
16
|
+
If `o` is null, the result is unspecified.
|
|
17
|
+
*/
|
|
18
|
+
static fields(o: any): string[]
|
|
19
|
+
}
|
package/bin/Reflect.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {Register} from "./genes/Register.js"
|
|
2
|
+
|
|
3
|
+
const $global = Register.$global
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
The Reflect API is a way to manipulate values dynamically through an
|
|
7
|
+
abstract interface in an untyped manner. Use with care.
|
|
8
|
+
|
|
9
|
+
@see https://haxe.org/manual/std-reflection.html
|
|
10
|
+
*/
|
|
11
|
+
export const Reflect = Register.global("$hxClasses")["Reflect"] =
|
|
12
|
+
class Reflect {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
Returns the fields of structure `o`.
|
|
16
|
+
|
|
17
|
+
This method is only guaranteed to work on anonymous structures. Refer to
|
|
18
|
+
`Type.getInstanceFields` for a function supporting class instances.
|
|
19
|
+
|
|
20
|
+
If `o` is null, the result is unspecified.
|
|
21
|
+
*/
|
|
22
|
+
static fields(o) {
|
|
23
|
+
var a = [];
|
|
24
|
+
if (o != null) {
|
|
25
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
26
|
+
for( var f in o ) {;
|
|
27
|
+
if (f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o, f)) {
|
|
28
|
+
a.push(f);
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
return a;
|
|
33
|
+
}
|
|
34
|
+
static get __name__() {
|
|
35
|
+
return "Reflect"
|
|
36
|
+
}
|
|
37
|
+
get __class__() {
|
|
38
|
+
return Reflect
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
package/bin/Std.d.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
The Std class provides standard methods for manipulating basic types.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Std {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
Converts any value to a String.
|
|
9
|
+
|
|
10
|
+
If `s` is of `String`, `Int`, `Float` or `Bool`, its value is returned.
|
|
11
|
+
|
|
12
|
+
If `s` is an instance of a class and that class or one of its parent classes has
|
|
13
|
+
a `toString` method, that method is called. If no such method is present, the result
|
|
14
|
+
is unspecified.
|
|
15
|
+
|
|
16
|
+
If `s` is an enum constructor without argument, the constructor's name is returned. If
|
|
17
|
+
arguments exists, the constructor's name followed by the String representations of
|
|
18
|
+
the arguments is returned.
|
|
19
|
+
|
|
20
|
+
If `s` is a structure, the field names along with their values are returned. The field order
|
|
21
|
+
and the operator separating field names and values are unspecified.
|
|
22
|
+
|
|
23
|
+
If s is null, "null" is returned.
|
|
24
|
+
*/
|
|
25
|
+
static string(s: any): string
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
Converts a `String` to an `Int`.
|
|
29
|
+
|
|
30
|
+
Leading whitespaces are ignored.
|
|
31
|
+
|
|
32
|
+
If `x` starts with 0x or 0X, hexadecimal notation is recognized where the following digits may
|
|
33
|
+
contain 0-9 and A-F.
|
|
34
|
+
|
|
35
|
+
Otherwise `x` is read as decimal number with 0-9 being allowed characters. `x` may also start with
|
|
36
|
+
a - to denote a negative value.
|
|
37
|
+
|
|
38
|
+
In decimal mode, parsing continues until an invalid character is detected, in which case the
|
|
39
|
+
result up to that point is returned. For hexadecimal notation, the effect of invalid characters
|
|
40
|
+
is unspecified.
|
|
41
|
+
|
|
42
|
+
Leading 0s that are not part of the 0x/0X hexadecimal notation are ignored, which means octal
|
|
43
|
+
notation is not supported.
|
|
44
|
+
|
|
45
|
+
If `x` is null, the result is unspecified.
|
|
46
|
+
If `x` cannot be parsed as integer, the result is `null`.
|
|
47
|
+
*/
|
|
48
|
+
static parseInt(x: string): null | number
|
|
49
|
+
}
|
package/bin/Std.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {Boot} from "./js/Boot.js"
|
|
2
|
+
import {Register} from "./genes/Register.js"
|
|
3
|
+
|
|
4
|
+
const $global = Register.$global
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
The Std class provides standard methods for manipulating basic types.
|
|
8
|
+
*/
|
|
9
|
+
export const Std = Register.global("$hxClasses")["Std"] =
|
|
10
|
+
class Std {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
Converts any value to a String.
|
|
14
|
+
|
|
15
|
+
If `s` is of `String`, `Int`, `Float` or `Bool`, its value is returned.
|
|
16
|
+
|
|
17
|
+
If `s` is an instance of a class and that class or one of its parent classes has
|
|
18
|
+
a `toString` method, that method is called. If no such method is present, the result
|
|
19
|
+
is unspecified.
|
|
20
|
+
|
|
21
|
+
If `s` is an enum constructor without argument, the constructor's name is returned. If
|
|
22
|
+
arguments exists, the constructor's name followed by the String representations of
|
|
23
|
+
the arguments is returned.
|
|
24
|
+
|
|
25
|
+
If `s` is a structure, the field names along with their values are returned. The field order
|
|
26
|
+
and the operator separating field names and values are unspecified.
|
|
27
|
+
|
|
28
|
+
If s is null, "null" is returned.
|
|
29
|
+
*/
|
|
30
|
+
static string(s) {
|
|
31
|
+
return Boot.__string_rec(s, "");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
Converts a `String` to an `Int`.
|
|
36
|
+
|
|
37
|
+
Leading whitespaces are ignored.
|
|
38
|
+
|
|
39
|
+
If `x` starts with 0x or 0X, hexadecimal notation is recognized where the following digits may
|
|
40
|
+
contain 0-9 and A-F.
|
|
41
|
+
|
|
42
|
+
Otherwise `x` is read as decimal number with 0-9 being allowed characters. `x` may also start with
|
|
43
|
+
a - to denote a negative value.
|
|
44
|
+
|
|
45
|
+
In decimal mode, parsing continues until an invalid character is detected, in which case the
|
|
46
|
+
result up to that point is returned. For hexadecimal notation, the effect of invalid characters
|
|
47
|
+
is unspecified.
|
|
48
|
+
|
|
49
|
+
Leading 0s that are not part of the 0x/0X hexadecimal notation are ignored, which means octal
|
|
50
|
+
notation is not supported.
|
|
51
|
+
|
|
52
|
+
If `x` is null, the result is unspecified.
|
|
53
|
+
If `x` cannot be parsed as integer, the result is `null`.
|
|
54
|
+
*/
|
|
55
|
+
static parseInt(x) {
|
|
56
|
+
if (x != null) {
|
|
57
|
+
var _g = 0;
|
|
58
|
+
var _g1 = x.length;
|
|
59
|
+
while (_g < _g1) {
|
|
60
|
+
var i = _g++;
|
|
61
|
+
var c = x.charCodeAt(i);
|
|
62
|
+
if (c <= 8 || c >= 14 && c != 32 && c != 45) {
|
|
63
|
+
var nc = x.charCodeAt(i + 1);
|
|
64
|
+
var v = parseInt(x, (nc == 120 || nc == 88) ? 16 : 10);
|
|
65
|
+
if ((isNaN)(v)) {
|
|
66
|
+
return null;
|
|
67
|
+
} else {
|
|
68
|
+
return v;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
static get __name__() {
|
|
76
|
+
return "Std"
|
|
77
|
+
}
|
|
78
|
+
get __class__() {
|
|
79
|
+
return Std
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
;{
|
|
85
|
+
String.prototype.__class__ = String;
|
|
86
|
+
String.__name__ = "String";
|
|
87
|
+
Array.__name__ = "Array";
|
|
88
|
+
Date.prototype.__class__ = Date;
|
|
89
|
+
Date.__name__ = "Date";
|
|
90
|
+
var Int = { };;
|
|
91
|
+
var Dynamic = { };;
|
|
92
|
+
var Float = Number;
|
|
93
|
+
var Bool = Boolean;
|
|
94
|
+
var Class = { };;
|
|
95
|
+
var Enum = { };;
|
|
96
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
An `Iterator` is a structure that permits iteration over elements of type `T`.
|
|
4
|
+
|
|
5
|
+
Any class with matching `hasNext()` and `next()` fields is considered an `Iterator`
|
|
6
|
+
and can then be used e.g. in `for`-loops. This makes it easy to implement
|
|
7
|
+
custom iterators.
|
|
8
|
+
|
|
9
|
+
@see https://haxe.org/manual/lf-iterators.html
|
|
10
|
+
*/
|
|
11
|
+
export type Iterator<T> = {
|
|
12
|
+
/**
|
|
13
|
+
Returns `false` if the iteration is complete, `true` otherwise.
|
|
14
|
+
|
|
15
|
+
Usually iteration is considered to be complete if all elements of the
|
|
16
|
+
underlying data structure were handled through calls to `next()`. However,
|
|
17
|
+
in custom iterators any logic may be used to determine the completion
|
|
18
|
+
state.
|
|
19
|
+
*/
|
|
20
|
+
hasNext: () => boolean,
|
|
21
|
+
/**
|
|
22
|
+
Returns the current item of the `Iterator` and advances to the next one.
|
|
23
|
+
|
|
24
|
+
This method is not required to check `hasNext()` first. A call to this
|
|
25
|
+
method while `hasNext()` is `false` yields unspecified behavior.
|
|
26
|
+
|
|
27
|
+
On the other hand, iterators should not require a call to `hasNext()`
|
|
28
|
+
before the first call to `next()` if an element is available.
|
|
29
|
+
*/
|
|
30
|
+
next: () => T
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
An `Iterable` is a data structure which has an `iterator()` method.
|
|
35
|
+
See `Lambda` for generic functions on iterable structures.
|
|
36
|
+
|
|
37
|
+
@see https://haxe.org/manual/lf-iterators.html
|
|
38
|
+
*/
|
|
39
|
+
export type Iterable<T> = {
|
|
40
|
+
iterator: () => Iterator<T>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
A `KeyValueIterator` is an `Iterator` that has a key and a value.
|
|
45
|
+
*/
|
|
46
|
+
export type KeyValueIterator<K, V> = Iterator<{
|
|
47
|
+
key: K,
|
|
48
|
+
value: V
|
|
49
|
+
}>
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
A `KeyValueIterable` is a data structure which has a `keyValueIterator()`
|
|
53
|
+
method to iterate over key-value-pairs.
|
|
54
|
+
*/
|
|
55
|
+
export type KeyValueIterable<K, V> = {
|
|
56
|
+
keyValueIterator: () => KeyValueIterator<K, V>
|
|
57
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
This class provides advanced methods on Strings. It is ideally used with
|
|
4
|
+
`using StringTools` and then acts as an [extension](https://haxe.org/manual/lf-static-extension.html)
|
|
5
|
+
to the `String` class.
|
|
6
|
+
|
|
7
|
+
If the first argument to any of the methods is null, the result is
|
|
8
|
+
unspecified.
|
|
9
|
+
*/
|
|
10
|
+
export declare class StringTools {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
Replace all occurrences of the String `sub` in the String `s` by the
|
|
14
|
+
String `by`.
|
|
15
|
+
|
|
16
|
+
If `sub` is the empty String `""`, `by` is inserted after each character
|
|
17
|
+
of `s` except the last one. If `by` is also the empty String `""`, `s`
|
|
18
|
+
remains unchanged.
|
|
19
|
+
|
|
20
|
+
If `sub` or `by` are null, the result is unspecified.
|
|
21
|
+
*/
|
|
22
|
+
static replace(s: string, sub: string, by: string): string
|
|
23
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {Register} from "./genes/Register.js"
|
|
2
|
+
|
|
3
|
+
const $global = Register.$global
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
This class provides advanced methods on Strings. It is ideally used with
|
|
7
|
+
`using StringTools` and then acts as an [extension](https://haxe.org/manual/lf-static-extension.html)
|
|
8
|
+
to the `String` class.
|
|
9
|
+
|
|
10
|
+
If the first argument to any of the methods is null, the result is
|
|
11
|
+
unspecified.
|
|
12
|
+
*/
|
|
13
|
+
export const StringTools = Register.global("$hxClasses")["StringTools"] =
|
|
14
|
+
class StringTools {
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
Replace all occurrences of the String `sub` in the String `s` by the
|
|
18
|
+
String `by`.
|
|
19
|
+
|
|
20
|
+
If `sub` is the empty String `""`, `by` is inserted after each character
|
|
21
|
+
of `s` except the last one. If `by` is also the empty String `""`, `s`
|
|
22
|
+
remains unchanged.
|
|
23
|
+
|
|
24
|
+
If `sub` or `by` are null, the result is unspecified.
|
|
25
|
+
*/
|
|
26
|
+
static replace(s, sub, by) {
|
|
27
|
+
return s.split(sub).join(by);
|
|
28
|
+
}
|
|
29
|
+
static get __name__() {
|
|
30
|
+
return "StringTools"
|
|
31
|
+
}
|
|
32
|
+
get __class__() {
|
|
33
|
+
return StringTools
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|