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.
Files changed (83) hide show
  1. package/dist/abstract-map.d.ts +4 -4
  2. package/dist/abstract-map.js +12 -15
  3. package/dist/abstract-set.d.ts +2 -2
  4. package/dist/abstract-set.js +6 -9
  5. package/dist/array-iterable.d.ts +1 -1
  6. package/dist/array-iterable.js +22 -26
  7. package/dist/collection.d.ts +4 -4
  8. package/dist/collection.js +50 -71
  9. package/dist/either.d.ts +4 -4
  10. package/dist/either.js +31 -39
  11. package/dist/hashmap.d.ts +2 -2
  12. package/dist/hashmap.js +9 -12
  13. package/dist/hashset.d.ts +3 -3
  14. package/dist/hashset.js +6 -11
  15. package/dist/index.d.ts +8 -8
  16. package/dist/index.js +9 -13
  17. package/dist/mappable.js +1 -2
  18. package/dist/mutable/hashmap.d.ts +3 -3
  19. package/dist/mutable/hashmap.js +3 -8
  20. package/dist/mutable/hashset.d.ts +2 -2
  21. package/dist/mutable/hashset.js +3 -8
  22. package/dist/mutable.d.ts +3 -3
  23. package/dist/mutable.js +3 -9
  24. package/dist/option.d.ts +6 -6
  25. package/dist/option.js +34 -44
  26. package/dist/try.d.ts +3 -3
  27. package/dist/try.js +27 -37
  28. package/dist/util.d.ts +2 -2
  29. package/dist/util.js +41 -50
  30. package/package.json +1 -1
  31. package/.eslintrc.cjs +0 -44
  32. package/coverage/clover.xml +0 -937
  33. package/coverage/coverage-final.json +0 -15
  34. package/coverage/lcov-report/array-iterable.ts.html +0 -1709
  35. package/coverage/lcov-report/base.css +0 -224
  36. package/coverage/lcov-report/block-navigation.js +0 -79
  37. package/coverage/lcov-report/collection.ts.html +0 -1475
  38. package/coverage/lcov-report/either.ts.html +0 -1934
  39. package/coverage/lcov-report/favicon.png +0 -0
  40. package/coverage/lcov-report/hashmap.ts.html +0 -527
  41. package/coverage/lcov-report/hashset.ts.html +0 -392
  42. package/coverage/lcov-report/index.html +0 -126
  43. package/coverage/lcov-report/index.ts.html +0 -101
  44. package/coverage/lcov-report/option.ts.html +0 -758
  45. package/coverage/lcov-report/prettify.css +0 -1
  46. package/coverage/lcov-report/prettify.js +0 -2
  47. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  48. package/coverage/lcov-report/sorter.js +0 -170
  49. package/coverage/lcov-report/src/abstract-map.ts.html +0 -317
  50. package/coverage/lcov-report/src/abstract-set.ts.html +0 -200
  51. package/coverage/lcov-report/src/array-iterable.ts.html +0 -1751
  52. package/coverage/lcov-report/src/collection.ts.html +0 -1778
  53. package/coverage/lcov-report/src/either.ts.html +0 -1934
  54. package/coverage/lcov-report/src/hashmap.ts.html +0 -428
  55. package/coverage/lcov-report/src/hashset.ts.html +0 -482
  56. package/coverage/lcov-report/src/index.html +0 -276
  57. package/coverage/lcov-report/src/index.ts.html +0 -110
  58. package/coverage/lcov-report/src/mutable/hashmap.ts.html +0 -821
  59. package/coverage/lcov-report/src/mutable/hashset.ts.html +0 -611
  60. package/coverage/lcov-report/src/mutable/index.html +0 -126
  61. package/coverage/lcov-report/src/mutable.ts.html +0 -89
  62. package/coverage/lcov-report/src/option.ts.html +0 -758
  63. package/coverage/lcov-report/src/try.ts.html +0 -923
  64. package/coverage/lcov-report/src/util.ts.html +0 -518
  65. package/coverage/lcov-report/try.ts.html +0 -923
  66. package/coverage/lcov-report/util.ts.html +0 -518
  67. package/coverage/lcov.info +0 -2223
  68. package/jest.config.js +0 -32
  69. package/src/abstract-map.ts +0 -79
  70. package/src/abstract-set.ts +0 -40
  71. package/src/array-iterable.ts +0 -557
  72. package/src/collection.ts +0 -619
  73. package/src/either.ts +0 -618
  74. package/src/hashmap.ts +0 -116
  75. package/src/hashset.ts +0 -134
  76. package/src/index.ts +0 -10
  77. package/src/mappable.ts +0 -8
  78. package/src/mutable/hashmap.ts +0 -247
  79. package/src/mutable/hashset.ts +0 -177
  80. package/src/mutable.ts +0 -3
  81. package/src/option.ts +0 -226
  82. package/src/try.ts +0 -281
  83. package/src/util.ts +0 -146
package/dist/util.js CHANGED
@@ -1,13 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.identity = identity;
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
- exports.toErrorConversion = toErrorConversion;
19
- class StepWithFilter {
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, (0, option_1.some)(condition));
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
- exports.StepWithFilter = StepWithFilter;
39
- class TaskWithFilter {
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, (0, option_1.some)(condition));
45
+ return new TaskWithFilter(this.name, this.f, some(condition));
47
46
  }
48
- invokeStep(state) {
49
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
50
- const result = yield this.f(state);
51
- return this.filter.filter(() => 'filter' in result).map(filter => {
52
- return result.filter(x => {
53
- this.name.foreach(name => state[name] = x);
54
- return filter(state);
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
- exports.TaskWithFilter = TaskWithFilter;
61
- function step(name, f) {
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
- exports.step = step;
65
- function task(name, f) {
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
- exports.task = task;
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
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
98
- const result = yield steps[stepIdx].invokeStep(acc);
99
- if (stepIdx < steps.length - 1) {
100
- return yield result.flatMapPromise(x => {
101
- steps[stepIdx].name.foreach(name => acc[name] = x);
102
- return processStep(stepIdx + 1, acc);
103
- });
104
- }
105
- else {
106
- return result.map(x => {
107
- steps[stepIdx].name.foreach(name => acc[name] = x);
108
- return final(acc);
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 = exports.forComprehension || (exports.forComprehension = {}));
109
+ })(forComprehension || (forComprehension = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scats",
3
- "version": "1.4.0-dev",
3
+ "version": "1.4.1-dev",
4
4
  "description": "Useful scala classes in typescript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
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
- };