semantic-typescript 0.3.8 → 0.4.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.
@@ -1,5 +1,5 @@
1
1
  import { OrderedCollectable } from "./collectable";
2
- import { Collector, useBigIntAverage, useBigIntMedian, useBigIntMode, useBigIntSummate, useBigIntVariance, useFrequency, useNumericAverage, useNumericMedian, useNumericMode, useNumericStandardDeviation, useNumericSummate, useNumericVariance, useToAsyncGeneratorFunction, useToGeneratorFunction } from "./collector";
2
+ import { Collector, useBigIntAverage, useBigIntMedian, useBigIntMode, useBigIntSummate, useBigIntVariance, useFrequency, useNumericAverage, useNumericMedian, useNumericMode, useNumericStandardDeviation, useNumericSummate, useNumericVariance, useToArray } from "./collector";
3
3
  import { isFunction } from "./guard";
4
4
  import { useCompare, useToBigInt, useToNumber } from "./hook";
5
5
  import { StatisticsSymbol, NumericStatisticsSymbol, BigIntStatisticsSymbol } from "./symbol";
@@ -7,17 +7,19 @@ export class Statistics extends OrderedCollectable {
7
7
  Statistics = StatisticsSymbol;
8
8
  constructor(parameter, comparator) {
9
9
  super(parameter, comparator || useCompare);
10
- Object.defineProperty(this, "Statistics", {
11
- value: StatisticsSymbol,
12
- enumerable: false,
13
- writable: false,
14
- configurable: false
10
+ Object.defineProperties(this, {
11
+ "Statistics": {
12
+ value: StatisticsSymbol,
13
+ enumerable: false,
14
+ writable: false,
15
+ configurable: false
16
+ }
15
17
  });
16
18
  Object.freeze(this);
17
19
  }
18
20
  *[Symbol.iterator]() {
19
21
  try {
20
- let collector = useToGeneratorFunction();
22
+ let collector = useToArray();
21
23
  yield* collector.collect(this.source());
22
24
  }
23
25
  catch (error) {
@@ -26,7 +28,7 @@ export class Statistics extends OrderedCollectable {
26
28
  }
27
29
  async *[Symbol.asyncIterator]() {
28
30
  try {
29
- let collector = useToAsyncGeneratorFunction();
31
+ let collector = useToArray();
30
32
  yield* collector.collect(this.source());
31
33
  }
32
34
  catch (error) {
@@ -48,17 +50,19 @@ export class NumericStatistics extends Statistics {
48
50
  NumericStatistics = NumericStatisticsSymbol;
49
51
  constructor(parameter, comparator) {
50
52
  super(parameter, comparator || useCompare);
51
- Object.defineProperty(this, "NumericStatistics", {
52
- value: NumericStatisticsSymbol,
53
- enumerable: false,
54
- writable: false,
55
- configurable: false
53
+ Object.defineProperties(this, {
54
+ "NumericStatistics": {
55
+ value: NumericStatisticsSymbol,
56
+ enumerable: false,
57
+ writable: false,
58
+ configurable: false
59
+ }
56
60
  });
57
61
  Object.freeze(this);
58
62
  }
59
63
  *[Symbol.iterator]() {
60
64
  try {
61
- let collector = useToGeneratorFunction();
65
+ let collector = useToArray();
62
66
  yield* collector.collect(this.source());
63
67
  }
64
68
  catch (error) {
@@ -67,7 +71,7 @@ export class NumericStatistics extends Statistics {
67
71
  }
68
72
  async *[Symbol.asyncIterator]() {
69
73
  try {
70
- let collector = useToAsyncGeneratorFunction();
74
+ let collector = useToArray();
71
75
  yield* collector.collect(this.source());
72
76
  }
73
77
  catch (error) {
@@ -265,17 +269,19 @@ export class BigIntStatistics extends Statistics {
265
269
  BigIntStatistics = BigIntStatisticsSymbol;
266
270
  constructor(parameter, comparator) {
267
271
  super(parameter, comparator || useCompare);
268
- Object.defineProperty(this, "BigIntStatistics", {
269
- value: BigIntStatisticsSymbol,
270
- enumerable: false,
271
- writable: false,
272
- configurable: false
272
+ Object.defineProperties(this, {
273
+ "BigIntStatistics": {
274
+ value: BigIntStatisticsSymbol,
275
+ enumerable: false,
276
+ writable: false,
277
+ configurable: false
278
+ }
273
279
  });
274
280
  Object.freeze(this);
275
281
  }
276
282
  *[Symbol.iterator]() {
277
283
  try {
278
- let collector = useToGeneratorFunction();
284
+ let collector = useToArray();
279
285
  yield* collector.collect(this.source());
280
286
  }
281
287
  catch (error) {
@@ -284,7 +290,7 @@ export class BigIntStatistics extends Statistics {
284
290
  }
285
291
  async *[Symbol.asyncIterator]() {
286
292
  try {
287
- let collector = useToAsyncGeneratorFunction();
293
+ let collector = useToArray();
288
294
  yield* collector.collect(this.source());
289
295
  }
290
296
  catch (error) {
package/dist/symbol.d.ts CHANGED
@@ -8,3 +8,11 @@ export declare let StatisticsSymbol: symbol;
8
8
  export declare let NumericStatisticsSymbol: symbol;
9
9
  export declare let BigIntStatisticsSymbol: symbol;
10
10
  export declare let UnorderedCollectableSymbol: symbol;
11
+ export declare let SemanticMapSymbol: symbol;
12
+ export declare let HashMapSymbol: symbol;
13
+ export declare let HashSetSymbol: symbol;
14
+ export declare let TreeMapSymbol: symbol;
15
+ export declare let TreeSetSymbol: symbol;
16
+ export declare let BinaryNodeSymbol: symbol;
17
+ export declare let ReadBlackNodeSymbol: symbol;
18
+ export declare let HashableSymbol: symbol;
package/dist/symbol.js CHANGED
@@ -8,3 +8,11 @@ export let StatisticsSymbol = Symbol.for("Statistics");
8
8
  export let NumericStatisticsSymbol = Symbol.for("NumericStatistics");
9
9
  export let BigIntStatisticsSymbol = Symbol.for("BigIntStatistics");
10
10
  export let UnorderedCollectableSymbol = Symbol.for("UnorderedCollectable");
11
+ export let SemanticMapSymbol = Symbol.for("SemanticMap");
12
+ export let HashMapSymbol = Symbol.for("HashMap");
13
+ export let HashSetSymbol = Symbol.for("HashSet");
14
+ export let TreeMapSymbol = Symbol.for("TreeMap");
15
+ export let TreeSetSymbol = Symbol.for("TreeSet");
16
+ export let BinaryNodeSymbol = Symbol.for("BinaryNode");
17
+ export let ReadBlackNodeSymbol = Symbol.for("BlackAndRedNode");
18
+ export let HashableSymbol = Symbol.for("hashable");
package/dist/utility.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  export type Invalid<T> = T extends null | undefined ? T : never;
2
2
  export type Valid<T> = T extends null | undefined ? never : T;
3
3
  export type MaybeInvalid<T> = T | null | undefined;
4
+ export type MaybeUndefined<T> = T | undefined;
5
+ export type MaybeNull<T> = T | null;
4
6
  export declare let validate: <T>(t: MaybeInvalid<T>) => t is T;
5
7
  export declare let invalidate: <T>(t: MaybeInvalid<T>) => t is (null | undefined);
6
- export type Primitive = string | number | boolean | symbol | bigint | Function | ((...args: any[]) => any);
8
+ export type Type = "undefined" | "null" | "boolean" | "number" | "bigint" | "symbol" | "string" | "function" | "object";
9
+ export declare let typeOf: <T>(t: T) => Type;
10
+ export type Primitive = null | undefined | string | number | boolean | symbol | bigint | Function | ((...args: any[]) => any);
7
11
  export type MaybePrimitive<T> = T | Primitive;
8
12
  export type AsyncFunction = (...args: any[]) => Promise<unknown>;
9
13
  export type DeepPropertyKey<T extends object> = {
@@ -12,6 +16,9 @@ export type DeepPropertyKey<T extends object> = {
12
16
  export type DeepPropertyValue<T extends object> = {
13
17
  [K in keyof T]: T[K] extends object ? DeepPropertyValue<T[K]> : T[K];
14
18
  };
19
+ export interface Constructor<T> {
20
+ new (...args: any[]): T;
21
+ }
15
22
  export interface Runnable {
16
23
  (): void;
17
24
  }
package/dist/utility.js CHANGED
@@ -4,6 +4,15 @@ export let validate = (t) => {
4
4
  export let invalidate = (t) => {
5
5
  return t === null || t === (void 0);
6
6
  };
7
+ export let typeOf = (t) => {
8
+ if (typeof t === "object") {
9
+ if (t === null) {
10
+ return "null";
11
+ }
12
+ return "object";
13
+ }
14
+ return typeof t;
15
+ };
7
16
  ;
8
17
  ;
9
18
  ;
package/dist/window.js CHANGED
@@ -7,11 +7,13 @@ export class WindowCollectable extends OrderedCollectable {
7
7
  WindowCollectable = WindowCollectableSymbol;
8
8
  constructor(parameter, comparator = useCompare) {
9
9
  super(parameter, comparator);
10
- Object.defineProperty(this, "WindowCollectable", {
11
- value: WindowCollectableSymbol,
12
- enumerable: false,
13
- writable: false,
14
- configurable: false
10
+ Object.defineProperties(this, {
11
+ "WindowCollectable": {
12
+ value: WindowCollectableSymbol,
13
+ writable: false,
14
+ enumerable: false,
15
+ configurable: false
16
+ }
15
17
  });
16
18
  Object.freeze(this);
17
19
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/eloyhere"
7
7
  },
8
8
  "description": "A modern type-safe stream processing library inspired by JavaScript Generator, Java Stream, and MySQL Index. Supports lazy evaluation, async streams, statistics, and IO-like operations.",
9
- "version": "0.3.8",
9
+ "version": "0.4.1",
10
10
  "type": "module",
11
11
  "readme": "readme.md",
12
12
  "main": "dist/index.js",
@@ -52,10 +52,6 @@
52
52
  },
53
53
  "scripts": {
54
54
  "build": "tsc",
55
- "dev": "vite",
56
55
  "prepublishOnly": "npm run build"
57
- },
58
- "devDependencies": {
59
- "typescript": "~5.9.3"
60
56
  }
61
57
  }