scats 1.4.0-dev → 1.4.1-dev
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/dist/abstract-map.d.ts +4 -4
- package/dist/abstract-map.js +12 -15
- package/dist/abstract-set.d.ts +2 -2
- package/dist/abstract-set.js +6 -9
- package/dist/array-iterable.d.ts +1 -1
- package/dist/array-iterable.js +22 -26
- package/dist/collection.d.ts +4 -4
- package/dist/collection.js +50 -71
- package/dist/either.d.ts +4 -4
- package/dist/either.js +31 -39
- package/dist/hashmap.d.ts +2 -2
- package/dist/hashmap.js +9 -12
- package/dist/hashset.d.ts +3 -3
- package/dist/hashset.js +6 -11
- package/dist/index.d.ts +8 -8
- package/dist/index.js +9 -13
- package/dist/mappable.js +1 -2
- package/dist/mutable/hashmap.d.ts +3 -3
- package/dist/mutable/hashmap.js +3 -8
- package/dist/mutable/hashset.d.ts +2 -2
- package/dist/mutable/hashset.js +3 -8
- package/dist/mutable.d.ts +3 -3
- package/dist/mutable.js +3 -9
- package/dist/option.d.ts +6 -6
- package/dist/option.js +34 -44
- package/dist/try.d.ts +3 -3
- package/dist/try.js +27 -37
- package/dist/util.d.ts +2 -2
- package/dist/util.js +41 -50
- package/package.json +1 -1
- package/.eslintrc.cjs +0 -44
- package/coverage/clover.xml +0 -937
- package/coverage/coverage-final.json +0 -15
- package/coverage/lcov-report/array-iterable.ts.html +0 -1709
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -79
- package/coverage/lcov-report/collection.ts.html +0 -1475
- package/coverage/lcov-report/either.ts.html +0 -1934
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/hashmap.ts.html +0 -527
- package/coverage/lcov-report/hashset.ts.html +0 -392
- package/coverage/lcov-report/index.html +0 -126
- package/coverage/lcov-report/index.ts.html +0 -101
- package/coverage/lcov-report/option.ts.html +0 -758
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -170
- package/coverage/lcov-report/src/abstract-map.ts.html +0 -317
- package/coverage/lcov-report/src/abstract-set.ts.html +0 -200
- package/coverage/lcov-report/src/array-iterable.ts.html +0 -1751
- package/coverage/lcov-report/src/collection.ts.html +0 -1778
- package/coverage/lcov-report/src/either.ts.html +0 -1934
- package/coverage/lcov-report/src/hashmap.ts.html +0 -428
- package/coverage/lcov-report/src/hashset.ts.html +0 -482
- package/coverage/lcov-report/src/index.html +0 -276
- package/coverage/lcov-report/src/index.ts.html +0 -110
- package/coverage/lcov-report/src/mutable/hashmap.ts.html +0 -821
- package/coverage/lcov-report/src/mutable/hashset.ts.html +0 -611
- package/coverage/lcov-report/src/mutable/index.html +0 -126
- package/coverage/lcov-report/src/mutable.ts.html +0 -89
- package/coverage/lcov-report/src/option.ts.html +0 -758
- package/coverage/lcov-report/src/try.ts.html +0 -923
- package/coverage/lcov-report/src/util.ts.html +0 -518
- package/coverage/lcov-report/try.ts.html +0 -923
- package/coverage/lcov-report/util.ts.html +0 -518
- package/coverage/lcov.info +0 -2223
- package/jest.config.js +0 -32
- package/src/abstract-map.ts +0 -79
- package/src/abstract-set.ts +0 -40
- package/src/array-iterable.ts +0 -557
- package/src/collection.ts +0 -619
- package/src/either.ts +0 -618
- package/src/hashmap.ts +0 -116
- package/src/hashset.ts +0 -134
- package/src/index.ts +0 -10
- package/src/mappable.ts +0 -8
- package/src/mutable/hashmap.ts +0 -247
- package/src/mutable/hashset.ts +0 -177
- package/src/mutable.ts +0 -3
- package/src/option.ts +0 -226
- package/src/try.ts +0 -281
- package/src/util.ts +0 -146
package/dist/util.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.forComprehension = exports.task = exports.step = exports.TaskWithFilter = exports.StepWithFilter = exports.toErrorConversion = exports.identity = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const option_1 = require("./option");
|
|
6
|
-
function identity(x) {
|
|
1
|
+
import { none, some } from './option.js';
|
|
2
|
+
export function identity(x) {
|
|
7
3
|
return x;
|
|
8
4
|
}
|
|
9
|
-
|
|
10
|
-
function toErrorConversion(x) {
|
|
5
|
+
export function toErrorConversion(x) {
|
|
11
6
|
if (x instanceof Error) {
|
|
12
7
|
return x;
|
|
13
8
|
}
|
|
@@ -15,15 +10,17 @@ function toErrorConversion(x) {
|
|
|
15
10
|
return new Error(`${x}`);
|
|
16
11
|
}
|
|
17
12
|
}
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
export class StepWithFilter {
|
|
14
|
+
name;
|
|
15
|
+
f;
|
|
16
|
+
filter;
|
|
20
17
|
constructor(name, f, filter) {
|
|
21
18
|
this.name = name;
|
|
22
19
|
this.f = f;
|
|
23
20
|
this.filter = filter;
|
|
24
21
|
}
|
|
25
22
|
if(condition) {
|
|
26
|
-
return new StepWithFilter(this.name, this.f,
|
|
23
|
+
return new StepWithFilter(this.name, this.f, some(condition));
|
|
27
24
|
}
|
|
28
25
|
invokeStep(state) {
|
|
29
26
|
const result = this.f(state);
|
|
@@ -35,38 +32,35 @@ class StepWithFilter {
|
|
|
35
32
|
}).getOrElseValue(result);
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
export class TaskWithFilter {
|
|
36
|
+
name;
|
|
37
|
+
f;
|
|
38
|
+
filter;
|
|
40
39
|
constructor(name, f, filter) {
|
|
41
40
|
this.name = name;
|
|
42
41
|
this.f = f;
|
|
43
42
|
this.filter = filter;
|
|
44
43
|
}
|
|
45
44
|
if(condition) {
|
|
46
|
-
return new TaskWithFilter(this.name, this.f,
|
|
45
|
+
return new TaskWithFilter(this.name, this.f, some(condition));
|
|
47
46
|
}
|
|
48
|
-
invokeStep(state) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}).getOrElseValue(result);
|
|
57
|
-
});
|
|
47
|
+
async invokeStep(state) {
|
|
48
|
+
const result = await this.f(state);
|
|
49
|
+
return this.filter.filter(() => 'filter' in result).map(filter => {
|
|
50
|
+
return result.filter(x => {
|
|
51
|
+
this.name.foreach(name => state[name] = x);
|
|
52
|
+
return filter(state);
|
|
53
|
+
});
|
|
54
|
+
}).getOrElseValue(result);
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return new StepWithFilter((0, option_1.some)(name), f, option_1.none);
|
|
57
|
+
export function step(name, f) {
|
|
58
|
+
return new StepWithFilter(some(name), f, none);
|
|
63
59
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return new TaskWithFilter((0, option_1.some)(name), f, option_1.none);
|
|
60
|
+
export function task(name, f) {
|
|
61
|
+
return new TaskWithFilter(some(name), f, none);
|
|
67
62
|
}
|
|
68
|
-
|
|
69
|
-
function forComprehension(...steps) {
|
|
63
|
+
export function forComprehension(...steps) {
|
|
70
64
|
return {
|
|
71
65
|
yield: function (final) {
|
|
72
66
|
function processStep(stepIdx, acc) {
|
|
@@ -88,31 +82,28 @@ function forComprehension(...steps) {
|
|
|
88
82
|
}
|
|
89
83
|
};
|
|
90
84
|
}
|
|
91
|
-
exports.forComprehension = forComprehension;
|
|
92
85
|
(function (forComprehension) {
|
|
93
86
|
function promise(...steps) {
|
|
94
87
|
return {
|
|
95
88
|
yield: function (final) {
|
|
96
|
-
function processStep(stepIdx, acc) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
});
|
|
89
|
+
async function processStep(stepIdx, acc) {
|
|
90
|
+
const result = await steps[stepIdx].invokeStep(acc);
|
|
91
|
+
if (stepIdx < steps.length - 1) {
|
|
92
|
+
return await result.flatMapPromise(x => {
|
|
93
|
+
steps[stepIdx].name.foreach(name => acc[name] = x);
|
|
94
|
+
return processStep(stepIdx + 1, acc);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return result.map(x => {
|
|
99
|
+
steps[stepIdx].name.foreach(name => acc[name] = x);
|
|
100
|
+
return final(acc);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
112
103
|
}
|
|
113
104
|
return processStep(0, {});
|
|
114
105
|
}
|
|
115
106
|
};
|
|
116
107
|
}
|
|
117
108
|
forComprehension.promise = promise;
|
|
118
|
-
})(forComprehension
|
|
109
|
+
})(forComprehension || (forComprehension = {}));
|
package/package.json
CHANGED
package/.eslintrc.cjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
parser: '@typescript-eslint/parser',
|
|
3
|
-
parserOptions: {
|
|
4
|
-
project: './tsconfig-eslint.json',
|
|
5
|
-
sourceType: 'module',
|
|
6
|
-
},
|
|
7
|
-
plugins: ['@typescript-eslint/eslint-plugin'],
|
|
8
|
-
extends: [
|
|
9
|
-
"eslint:recommended",
|
|
10
|
-
'plugin:@typescript-eslint/eslint-recommended',
|
|
11
|
-
'plugin:@typescript-eslint/recommended'
|
|
12
|
-
],
|
|
13
|
-
root: true,
|
|
14
|
-
env: {
|
|
15
|
-
node: true,
|
|
16
|
-
jest: true,
|
|
17
|
-
},
|
|
18
|
-
rules: {
|
|
19
|
-
'@typescript-eslint/interface-name-prefix': 'off',
|
|
20
|
-
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
21
|
-
'@typescript-eslint/no-explicit-any': 'off',
|
|
22
|
-
'@typescript-eslint/no-namespace': 'off',
|
|
23
|
-
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
24
|
-
'@typescript-eslint/member-delimiter-style': 'error',
|
|
25
|
-
'quotes': ["error", "single"],
|
|
26
|
-
"camelcase": ["error", {"properties": "always"}],
|
|
27
|
-
"semi": "off",
|
|
28
|
-
"@typescript-eslint/semi": ["error"],
|
|
29
|
-
"@typescript-eslint/prefer-readonly": ["error"],
|
|
30
|
-
"no-labels": "error",
|
|
31
|
-
"key-spacing": "error",
|
|
32
|
-
"keyword-spacing": "error",
|
|
33
|
-
"no-continue": "error",
|
|
34
|
-
"no-lonely-if": "error",
|
|
35
|
-
"no-multi-assign": "error",
|
|
36
|
-
"no-nested-ternary": "error",
|
|
37
|
-
"no-new-object": "error",
|
|
38
|
-
"no-unneeded-ternary": "error",
|
|
39
|
-
"no-whitespace-before-property": "error",
|
|
40
|
-
"nonblock-statement-body-position": "error",
|
|
41
|
-
'arrow-spacing': "error",
|
|
42
|
-
"@typescript-eslint/no-unused-vars": ["error", {"argsIgnorePattern": "_"}]
|
|
43
|
-
},
|
|
44
|
-
};
|