ts-server-lib 0.0.48

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 (46) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +8 -0
  3. package/db/TSJournal.d.ts +108 -0
  4. package/db/TSJournal.js +229 -0
  5. package/db/TSMongo.d.ts +103 -0
  6. package/db/TSMongo.js +516 -0
  7. package/db/TSRQW.d.ts +625 -0
  8. package/db/TSRQW.js +1204 -0
  9. package/db/TSRedis.d.ts +530 -0
  10. package/db/TSRedis.js +1368 -0
  11. package/db/TSRedisTB.d.ts +80 -0
  12. package/db/TSRedisTB.js +178 -0
  13. package/package.json +85 -0
  14. package/ussd/TSUssdMenu.d.ts +139 -0
  15. package/ussd/TSUssdMenu.js +368 -0
  16. package/ussd/TSUssdScreen.d.ts +58 -0
  17. package/ussd/TSUssdScreen.js +218 -0
  18. package/ussd/index.d.ts +3 -0
  19. package/ussd/index.js +19 -0
  20. package/ussd/providers/AfricasTalking.d.ts +3 -0
  21. package/ussd/providers/AfricasTalking.js +17 -0
  22. package/ussd/providers/AirtelDRC.d.ts +9 -0
  23. package/ussd/providers/AirtelDRC.js +31 -0
  24. package/ussd/providers/OrangeDRC.d.ts +5 -0
  25. package/ussd/providers/OrangeDRC.js +213 -0
  26. package/ussd/providers/VodacomDRC.d.ts +9 -0
  27. package/ussd/providers/VodacomDRC.js +48 -0
  28. package/ussd/providers/_.d.ts +55 -0
  29. package/ussd/providers/_.js +83 -0
  30. package/ussd/providers/index.d.ts +13 -0
  31. package/ussd/providers/index.js +56 -0
  32. package/utils/TSFifo.d.ts +109 -0
  33. package/utils/TSFifo.js +145 -0
  34. package/utils/TSFile.d.ts +36 -0
  35. package/utils/TSFile.js +244 -0
  36. package/utils/TSHash.d.ts +19 -0
  37. package/utils/TSHash.js +71 -0
  38. package/utils/TSRequest.d.ts +248 -0
  39. package/utils/TSRequest.js +689 -0
  40. package/utils/TSStub.d.ts +159 -0
  41. package/utils/TSStub.js +296 -0
  42. package/utils/abort.d.ts +18 -0
  43. package/utils/abort.js +97 -0
  44. package/utils/mime.json +11358 -0
  45. package/utils/object-keys.d.ts +39 -0
  46. package/utils/object-keys.js +52 -0
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Allocation-free own-key predicates — the counting half of the cooperative-yield rules (CLY-3).
3
+ *
4
+ * ### The defect these replace
5
+ *
6
+ * `Object.keys(o).length > 0` and `Object.keys(o).length === 0` both MATERIALISE an array of every key to
7
+ * answer a question the first key already settles. On a per-message path that is a throwaway allocation per
8
+ * call, sized by the object — and the objects on a feed path are markets and outcomes, so they are not
9
+ * small. `Object.values(o).length` and `Object.entries(o).length` are worse: they build the values or the
10
+ * pairs as well.
11
+ *
12
+ * Both functions here return on the first iteration for the populated case and iterate nothing for the empty
13
+ * one, so neither ever allocates.
14
+ *
15
+ * ### Why they live in ts-server-lib
16
+ *
17
+ * Same reason `TSFifo` does. The canonical copies were in core-service, one layer too high for the two
18
+ * packages that most need them: this library's own hot paths, and the atfeed betradar driver — whose
19
+ * `Object.keys(...).length` calls run INSIDE the AMQP parse worker, once per market on every odds message.
20
+ * Neither can import core-service, so without these they would each grow their own copy.
21
+ *
22
+ * NOTE: core-service still carries its own `hasOwnKey`/`countOwnKeys` in
23
+ * `common/resilience/cooperative-yield.ts`. Collapsing that onto these is the right end state, but it
24
+ * couples core-service to a ts-server-lib version and is deliberately left as a separate, coordinated
25
+ * change rather than folded into a publish.
26
+ */
27
+ /**
28
+ * True when `o` has at least one own enumerable key.
29
+ *
30
+ * Prefer over `countOwnKeys(o) > 0`: counting walks every entry to answer a question the first key settles.
31
+ */
32
+ export declare function hasOwnKey(o: object): boolean;
33
+ /**
34
+ * Number of own enumerable keys, counted by enumeration rather than by building an array.
35
+ *
36
+ * Use only when the COUNT itself is needed. When the question is merely "is it empty", {@link hasOwnKey}
37
+ * answers it without walking the whole object.
38
+ */
39
+ export declare function countOwnKeys(o: object): number;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ /**
3
+ * Allocation-free own-key predicates — the counting half of the cooperative-yield rules (CLY-3).
4
+ *
5
+ * ### The defect these replace
6
+ *
7
+ * `Object.keys(o).length > 0` and `Object.keys(o).length === 0` both MATERIALISE an array of every key to
8
+ * answer a question the first key already settles. On a per-message path that is a throwaway allocation per
9
+ * call, sized by the object — and the objects on a feed path are markets and outcomes, so they are not
10
+ * small. `Object.values(o).length` and `Object.entries(o).length` are worse: they build the values or the
11
+ * pairs as well.
12
+ *
13
+ * Both functions here return on the first iteration for the populated case and iterate nothing for the empty
14
+ * one, so neither ever allocates.
15
+ *
16
+ * ### Why they live in ts-server-lib
17
+ *
18
+ * Same reason `TSFifo` does. The canonical copies were in core-service, one layer too high for the two
19
+ * packages that most need them: this library's own hot paths, and the atfeed betradar driver — whose
20
+ * `Object.keys(...).length` calls run INSIDE the AMQP parse worker, once per market on every odds message.
21
+ * Neither can import core-service, so without these they would each grow their own copy.
22
+ *
23
+ * NOTE: core-service still carries its own `hasOwnKey`/`countOwnKeys` in
24
+ * `common/resilience/cooperative-yield.ts`. Collapsing that onto these is the right end state, but it
25
+ * couples core-service to a ts-server-lib version and is deliberately left as a separate, coordinated
26
+ * change rather than folded into a publish.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.hasOwnKey = hasOwnKey;
30
+ exports.countOwnKeys = countOwnKeys;
31
+ /**
32
+ * True when `o` has at least one own enumerable key.
33
+ *
34
+ * Prefer over `countOwnKeys(o) > 0`: counting walks every entry to answer a question the first key settles.
35
+ */
36
+ function hasOwnKey(o) {
37
+ for (const _ in o)
38
+ return true;
39
+ return false;
40
+ }
41
+ /**
42
+ * Number of own enumerable keys, counted by enumeration rather than by building an array.
43
+ *
44
+ * Use only when the COUNT itself is needed. When the question is merely "is it empty", {@link hasOwnKey}
45
+ * answers it without walking the whole object.
46
+ */
47
+ function countOwnKeys(o) {
48
+ let n = 0;
49
+ for (const _ in o)
50
+ n++;
51
+ return n;
52
+ }