functionalscript 0.3.7 → 0.3.8

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 (109) hide show
  1. package/com/cpp/module.f.js +0 -1
  2. package/com/cs/module.f.js +5 -6
  3. package/com/rust/module.f.d.ts +3 -3
  4. package/com/rust/module.f.js +24 -29
  5. package/com/test/build.f.js +2 -2
  6. package/com/types/module.f.d.ts +1 -1
  7. package/com/types/module.f.js +1 -2
  8. package/com/types/testlib.f.js +0 -1
  9. package/commonjs/build/module.f.d.ts +2 -2
  10. package/commonjs/build/module.f.js +3 -6
  11. package/commonjs/build/test.f.js +0 -4
  12. package/commonjs/module/function/module.f.d.ts +1 -1
  13. package/commonjs/module/function/module.f.js +1 -1
  14. package/commonjs/module/module.f.d.ts +1 -1
  15. package/commonjs/module/module.f.js +2 -3
  16. package/commonjs/path/module.f.d.ts +5 -5
  17. package/commonjs/path/module.f.js +6 -8
  18. package/commonjs/path/test.f.js +1 -2
  19. package/crypto/prime_field/module.f.d.ts +1 -1
  20. package/crypto/prime_field/module.f.js +1 -1
  21. package/crypto/secp/module.f.d.ts +1 -1
  22. package/crypto/secp/module.f.js +2 -2
  23. package/crypto/sha2/module.f.d.ts +75 -12
  24. package/crypto/sha2/module.f.js +246 -139
  25. package/crypto/sha2/test.f.d.ts +22 -3
  26. package/crypto/sha2/test.f.js +120 -67
  27. package/dev/test/module.f.d.ts +1 -1
  28. package/dev/test/module.f.js +4 -5
  29. package/dev/test.f.js +0 -4
  30. package/djs/module.f.d.ts +1 -1
  31. package/djs/module.f.js +0 -1
  32. package/djs/parser/module.f.d.ts +1 -1
  33. package/djs/parser/module.f.js +0 -2
  34. package/djs/serializer/module.f.d.ts +2 -2
  35. package/djs/serializer/module.f.js +0 -2
  36. package/djs/tokenizer/module.f.js +0 -1
  37. package/fsc/test.f.js +0 -1
  38. package/js/tokenizer/module.f.d.ts +1 -1
  39. package/js/tokenizer/module.f.js +1 -1
  40. package/json/parser/module.f.d.ts +2 -2
  41. package/json/parser/module.f.js +0 -3
  42. package/json/serializer/module.f.js +0 -2
  43. package/json/tokenizer/module.f.js +0 -1
  44. package/package.json +1 -1
  45. package/text/ascii/module.f.d.ts +1 -1
  46. package/text/ascii/module.f.js +2 -3
  47. package/text/ascii/test.f.js +2 -4
  48. package/text/module.f.d.ts +18 -3
  49. package/text/module.f.js +22 -6
  50. package/text/sgr/module.f.js +1 -1
  51. package/text/test.f.d.ts +4 -1
  52. package/text/test.f.js +24 -16
  53. package/text/utf16/module.f.d.ts +5 -6
  54. package/text/utf16/module.f.js +9 -10
  55. package/text/utf16/test.f.js +29 -30
  56. package/text/utf8/module.f.d.ts +8 -5
  57. package/text/utf8/module.f.js +3 -5
  58. package/text/utf8/test.f.js +34 -35
  59. package/types/bigfloat/module.f.js +1 -1
  60. package/types/bigint/module.f.d.ts +17 -5
  61. package/types/bigint/module.f.js +19 -4
  62. package/types/bigint/test.f.d.ts +1 -0
  63. package/types/bigint/test.f.js +7 -2
  64. package/types/bit_vec/module.f.d.ts +103 -83
  65. package/types/bit_vec/module.f.js +68 -110
  66. package/types/bit_vec/test.f.d.ts +20 -8
  67. package/types/bit_vec/test.f.js +110 -117
  68. package/types/btree/find/test.f.js +3 -4
  69. package/types/btree/module.f.d.ts +3 -3
  70. package/types/btree/module.f.js +2 -5
  71. package/types/btree/remove/test.f.js +2 -3
  72. package/types/btree/set/test.f.js +3 -6
  73. package/types/btree/test.f.js +0 -1
  74. package/types/btree/types/module.f.d.ts +3 -3
  75. package/types/byte_set/module.f.d.ts +2 -2
  76. package/types/byte_set/module.f.js +0 -2
  77. package/types/function/compare/module.f.d.ts +1 -1
  78. package/types/function/compare/module.f.js +0 -1
  79. package/types/function/compare/test.f.js +1 -2
  80. package/types/function/module.f.d.ts +1 -1
  81. package/types/function/module.f.js +1 -1
  82. package/types/function/operator/module.f.d.ts +2 -3
  83. package/types/function/operator/module.f.js +5 -5
  84. package/types/function/test.f.js +1 -2
  85. package/types/list/module.f.d.ts +1 -1
  86. package/types/list/module.f.js +9 -9
  87. package/types/list/test.f.js +2 -4
  88. package/types/map/module.f.d.ts +6 -6
  89. package/types/map/module.f.js +6 -15
  90. package/types/map/test.f.js +1 -2
  91. package/types/nibble_set/module.f.d.ts +2 -3
  92. package/types/nibble_set/test.f.js +1 -2
  93. package/types/number/test.f.js +1 -2
  94. package/types/object/module.f.d.ts +5 -5
  95. package/types/object/module.f.js +2 -4
  96. package/types/range_map/module.f.d.ts +4 -4
  97. package/types/range_map/module.f.js +3 -9
  98. package/types/result/module.f.d.ts +2 -3
  99. package/types/sorted_list/module.f.d.ts +6 -6
  100. package/types/sorted_list/module.f.js +2 -6
  101. package/types/sorted_list/test.f.js +4 -9
  102. package/types/sorted_set/module.f.d.ts +1 -1
  103. package/types/sorted_set/module.f.js +2 -5
  104. package/types/sorted_set/test.f.js +4 -9
  105. package/types/string/module.f.d.ts +3 -3
  106. package/types/string/module.f.js +1 -2
  107. package/types/string/test.f.js +2 -4
  108. package/types/string_set/module.f.d.ts +1 -1
  109. package/types/string_set/module.f.js +5 -11
package/dev/test.f.js CHANGED
@@ -1,7 +1,3 @@
1
- const assert = () => { throw 'assert'; };
2
- const assert_if = c => { if (c) {
3
- throw 'assert_if';
4
- } };
5
1
  export default {
6
2
  ctor: () => {
7
3
  const c = (() => { })['constructor'];
package/djs/module.f.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as list from '../types/list/module.f.ts';
2
- import * as O from '../types/object/module.f.ts';
2
+ import type * as O from '../types/object/module.f.ts';
3
3
  type Object = {
4
4
  readonly [k in string]: Unknown;
5
5
  };
package/djs/module.f.js CHANGED
@@ -2,7 +2,6 @@ import * as list from "../types/list/module.f.js";
2
2
  const { flat, map } = list;
3
3
  import * as string from "../types/string/module.f.js";
4
4
  const { concat } = string;
5
- import * as O from "../types/object/module.f.js";
6
5
  import * as f from "../types/function/module.f.js";
7
6
  const { compose, fn } = f;
8
7
  const { entries } = Object;
@@ -1,6 +1,6 @@
1
1
  import * as result from '../../types/result/module.f.ts';
2
2
  import { type List } from '../../types/list/module.f.ts';
3
- import * as tokenizerT from '../tokenizer/module.f.ts';
3
+ import type * as tokenizerT from '../tokenizer/module.f.ts';
4
4
  export type DjsModule = [readonly string[], readonly DjsConst[]];
5
5
  export type DjsConst = boolean | string | number | null | bigint | undefined | DjsModuleRef | DjsArray | DjsObject;
6
6
  type DjsModuleRef = ['aref' | 'cref', number];
@@ -1,7 +1,5 @@
1
1
  import * as result from "../../types/result/module.f.js";
2
2
  import { fold, first, drop, toArray, length, concat } from "../../types/list/module.f.js";
3
- import * as Operator from "../../types/function/operator/module.f.js";
4
- import * as tokenizerT from "../tokenizer/module.f.js";
5
3
  import { setReplace, at } from "../../types/map/module.f.js";
6
4
  import * as o from "../../types/object/module.f.js";
7
5
  const { fromMap } = o;
@@ -1,6 +1,6 @@
1
1
  import * as list from '../../types/list/module.f.ts';
2
- import * as O from '../../types/object/module.f.ts';
3
- import * as DjsParser from '../parser/module.f.ts';
2
+ import type * as O from '../../types/object/module.f.ts';
3
+ import type * as DjsParser from '../parser/module.f.ts';
4
4
  export declare const undefinedSerialize: string[];
5
5
  type Entry = O.Entry<DjsParser.DjsConst>;
6
6
  type Entries = list.List<Entry>;
@@ -2,7 +2,6 @@ import * as list from "../../types/list/module.f.js";
2
2
  const { flat, map, entries: listEntries, concat: listConcat, flatMap } = list;
3
3
  import * as string from "../../types/string/module.f.js";
4
4
  const { concat } = string;
5
- import * as O from "../../types/object/module.f.js";
6
5
  import * as f from "../../types/function/module.f.js";
7
6
  const { compose, fn } = f;
8
7
  const { entries } = Object;
@@ -10,7 +9,6 @@ import * as bi from "../../types/bigint/module.f.js";
10
9
  const { serialize: bigintSerialize } = bi;
11
10
  import * as j from "../../json/serializer/module.f.js";
12
11
  const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = j;
13
- import * as DjsParser from "../parser/module.f.js";
14
12
  const colon = [':'];
15
13
  export const undefinedSerialize = ['undefined'];
16
14
  const djsConstSerialize = sort => {
@@ -1,4 +1,3 @@
1
- import * as Operator from "../../types/function/operator/module.f.js";
2
1
  import * as list from "../../types/list/module.f.js";
3
2
  const { empty, flat, stateScan } = list;
4
3
  import * as bf from "../../types/bigfloat/module.f.js";
package/fsc/test.f.js CHANGED
@@ -4,7 +4,6 @@ const { one } = ascii;
4
4
  import * as j from "../json/module.f.js";
5
5
  const { stringify } = j;
6
6
  const s = stringify(i => i);
7
- /** @type {} */
8
7
  const f = v => {
9
8
  const n = one(v);
10
9
  return s(_.init(n)[0]);
@@ -81,6 +81,6 @@ export type CommentToken = {
81
81
  };
82
82
  export type JsToken = KeywordToken | TrueToken | FalseToken | NullToken | WhitespaceToken | NewLineToken | StringToken | NumberToken | ErrorToken | IdToken | BigIntToken | UndefinedToken | OperatorToken | CommentToken;
83
83
  type ErrorMessage = '" are missing' | 'unescaped character' | 'invalid hex value' | 'unexpected character' | 'invalid number' | 'invalid token' | '*\/ expected' | 'unterminated string literal' | 'eof';
84
- export declare const isKeywordToken: (token: JsToken) => Boolean;
84
+ export declare const isKeywordToken: (token: JsToken) => boolean;
85
85
  export declare const tokenize: (input: list.List<number>) => list.List<JsToken>;
86
86
  export {};
@@ -485,8 +485,8 @@ const tokenizeEofOp = state => {
485
485
  case 'e':
486
486
  case 'e+':
487
487
  case 'e-': return [[{ kind: 'error', message: 'invalid number' }], { kind: 'eof', }];
488
- default: return [[bufferToNumberToken(state)], { kind: 'eof' }];
489
488
  }
489
+ return [[bufferToNumberToken(state)], { kind: 'eof' }];
490
490
  case 'op': return [[getOperatorToken(state.value)], { kind: 'eof' }];
491
491
  case '//': return [[{ kind: '//', value: state.value }], { kind: 'eof' }];
492
492
  case '/*':
@@ -1,5 +1,5 @@
1
1
  import * as result from '../../types/result/module.f.ts';
2
2
  import * as list from '../../types/list/module.f.ts';
3
- import * as Tokenizer from '../tokenizer/module.f.ts';
4
- import * as Json from '../module.f.ts';
3
+ import type * as Tokenizer from '../tokenizer/module.f.ts';
4
+ import type * as Json from '../module.f.ts';
5
5
  export declare const parse: (tokenList: list.List<Tokenizer.JsonToken>) => result.Result<Json.Unknown, string>;
@@ -1,11 +1,8 @@
1
1
  import * as result from "../../types/result/module.f.js";
2
2
  import * as list from "../../types/list/module.f.js";
3
3
  const { fold, first, drop, toArray } = list;
4
- import * as Operator from "../../types/function/operator/module.f.js";
5
- import * as Tokenizer from "../tokenizer/module.f.js";
6
4
  import * as map from "../../types/map/module.f.js";
7
5
  const { setReplace } = map;
8
- import * as Json from "../module.f.js";
9
6
  import * as o from "../../types/object/module.f.js";
10
7
  const { fromMap } = o;
11
8
  const addKeyToObject = obj => key => ({ kind: 'object', values: obj.values, key: key });
@@ -1,7 +1,5 @@
1
1
  import * as list from "../../types/list/module.f.js";
2
2
  const { flat, reduce, empty } = list;
3
- import * as O from "../../types/object/module.f.js";
4
- import * as Operator from "../../types/function/operator/module.f.js";
5
3
  const jsonStringify = JSON.stringify;
6
4
  export const stringSerialize = input => [jsonStringify(input)];
7
5
  export const numberSerialize = input => [jsonStringify(input)];
@@ -1,4 +1,3 @@
1
- import * as Operator from "../../types/function/operator/module.f.js";
2
1
  import * as list from "../../types/list/module.f.js";
3
2
  const { empty, flat, stateScan } = list;
4
3
  import * as bf from "../../types/bigfloat/module.f.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "**/*.f.d.ts",
@@ -1,4 +1,4 @@
1
- import { type Range } from '../../types/range/module.f.ts';
1
+ import type { Range } from '../../types/range/module.f.ts';
2
2
  export declare const one: (s: string) => number;
3
3
  export declare const range: (s: string) => Range;
4
4
  /** 0x08 */
@@ -1,5 +1,4 @@
1
- import {} from "../../types/range/module.f.js";
2
- const at = s => i => {
1
+ const at = (s) => (i) => {
3
2
  const r = s.codePointAt(i);
4
3
  if (r === void 0) {
5
4
  throw s;
@@ -7,7 +6,7 @@ const at = s => i => {
7
6
  return r;
8
7
  };
9
8
  export const one = (s) => at(s)(0);
10
- export const range = s => {
9
+ export const range = (s) => {
11
10
  const f = at(s);
12
11
  const f0 = f(0);
13
12
  if (s.length === 1) {
@@ -1,8 +1,6 @@
1
- import * as _ from "./module.f.js";
2
- const { range } = _;
1
+ import { range } from "./module.f.js";
3
2
  import * as json from "../../json/module.f.js";
4
- import * as o from "../../types/object/module.f.js";
5
- const { sort } = o;
3
+ import { sort } from "../../types/object/module.f.js";
6
4
  const stringify = json.stringify(sort);
7
5
  export default {
8
6
  range: () => {
@@ -1,8 +1,23 @@
1
- import * as list from '../types/list/module.f.ts';
1
+ import { type Vec } from "../types/bit_vec/module.f.ts";
2
+ import { type List } from '../types/list/module.f.ts';
2
3
  export type Block = ItemThunk | ItemArray;
3
4
  type ItemArray = readonly Item[];
4
- type ItemThunk = () => list.List<Item>;
5
+ type ItemThunk = () => List<Item>;
5
6
  export type Item = string | ItemArray | ItemThunk;
6
- export declare const flat: (indent: string) => (text: Block) => list.List<string>;
7
+ export declare const flat: (indent: string) => (text: Block) => List<string>;
7
8
  export declare const curly: (type: string) => (name: string) => (body: Block) => Block;
9
+ /**
10
+ * Converts a string to an UTF-8, represented as an MSB first bit vector.
11
+ *
12
+ * @param s The input string to be converted.
13
+ * @returns The resulting UTF-8 bit vector, MSB first.
14
+ */
15
+ export declare const msbUtf8: (s: string) => Vec;
16
+ /**
17
+ * Converts a UTF-8 bit vector with MSB first encoding to a string.
18
+ *
19
+ * @param msbV - The UTF-8 bit vector with MSB first encoding.
20
+ * @returns The resulting string.
21
+ */
22
+ export declare const msbUtf8ToString: (msbV: Vec) => string;
8
23
  export {};
package/text/module.f.js CHANGED
@@ -1,10 +1,26 @@
1
- import * as list from "../types/list/module.f.js";
2
- const { flatMap } = list;
3
- export const flat = indent => {
4
- const f = prefix => {
5
- const g = item => typeof (item) === 'string' ? [`${prefix}${item}`] : f(`${prefix}${indent}`)(item);
1
+ import { msb, u8List, u8ListToVec } from "../types/bit_vec/module.f.js";
2
+ import { flatMap } from "../types/list/module.f.js";
3
+ import * as utf8 from "./utf8/module.f.js";
4
+ import * as utf16 from "./utf16/module.f.js";
5
+ export const flat = (indent) => {
6
+ const f = (prefix) => {
7
+ const g = (item) => typeof (item) === 'string' ? [`${prefix}${item}`] : f(`${prefix}${indent}`)(item);
6
8
  return flatMap(g);
7
9
  };
8
10
  return f('');
9
11
  };
10
- export const curly = type => name => body => [`${type} ${name}`, '{', body, '}'];
12
+ export const curly = (type) => (name) => (body) => [`${type} ${name}`, '{', body, '}'];
13
+ /**
14
+ * Converts a string to an UTF-8, represented as an MSB first bit vector.
15
+ *
16
+ * @param s The input string to be converted.
17
+ * @returns The resulting UTF-8 bit vector, MSB first.
18
+ */
19
+ export const msbUtf8 = (s) => u8ListToVec(msb)(utf8.fromCodePointList(utf16.toCodePointList(utf16.stringToList(s))));
20
+ /**
21
+ * Converts a UTF-8 bit vector with MSB first encoding to a string.
22
+ *
23
+ * @param msbV - The UTF-8 bit vector with MSB first encoding.
24
+ * @returns The resulting string.
25
+ */
26
+ export const msbUtf8ToString = (msbV) => utf16.listToString(utf16.fromCodePointList(utf8.toCodePointList(u8List(msb)(msbV))));
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * https://en.wikipedia.org/wiki/ANSI_escape_code#SGR
3
3
  */
4
- export const sgr = c => `\x1b[${c.toString()}m`;
4
+ export const sgr = (c) => `\x1b[${c.toString()}m`;
5
5
  export const reset = sgr(0);
6
6
  export const bold = sgr(1);
7
7
  export const fgRed = sgr(31);
package/text/test.f.d.ts CHANGED
@@ -1,2 +1,5 @@
1
- declare const _default: () => void;
1
+ declare const _default: {
2
+ block: () => void;
3
+ encoding: () => void;
4
+ };
2
5
  export default _default;
package/text/test.f.js CHANGED
@@ -1,18 +1,26 @@
1
- import * as _ from "./module.f.js";
2
- import * as string from "../types/string/module.f.js";
3
- const { join } = string;
4
- export default () => {
5
- const text = [
6
- 'a',
7
- 'b',
8
- () => [
9
- 'c',
10
- () => ['d'],
11
- ],
12
- 'e',
13
- ];
14
- const result = join('\n')(_.flat(':')(text));
15
- if (result !== 'a\nb\n:c\n::d\ne') {
16
- throw result;
1
+ import { flat, msbUtf8, msbUtf8ToString } from "./module.f.js";
2
+ import { join } from "../types/string/module.f.js";
3
+ export default {
4
+ block: () => {
5
+ const text = [
6
+ 'a',
7
+ 'b',
8
+ () => [
9
+ 'c',
10
+ () => ['d'],
11
+ ],
12
+ 'e',
13
+ ];
14
+ const result = join('\n')(flat(':')(text));
15
+ if (result !== 'a\nb\n:c\n::d\ne') {
16
+ throw result;
17
+ }
18
+ },
19
+ encoding: () => {
20
+ const v = msbUtf8('Hello world!');
21
+ const r = msbUtf8ToString(v);
22
+ if (r !== 'Hello world!') {
23
+ throw r;
24
+ }
17
25
  }
18
26
  };
@@ -1,9 +1,8 @@
1
1
  import { type List, type Thunk } from '../../types/list/module.f.ts';
2
- type u16 = number;
3
- type i32 = number;
2
+ type U16 = number;
3
+ type I32 = number;
4
4
  export declare const fromCodePointList: (input: List<number>) => Thunk<number>;
5
- declare const u16: (i: number) => boolean;
6
- export declare const toCodePointList: (input: List<u16>) => List<i32>;
7
- export declare const stringToList: (s: string) => List<u16>;
8
- export declare const listToString: (input: List<u16>) => string;
5
+ export declare const toCodePointList: (input: List<U16>) => List<I32>;
6
+ export declare const stringToList: (s: string) => List<U16>;
7
+ export declare const listToString: (input: List<U16>) => string;
9
8
  export {};
@@ -1,16 +1,15 @@
1
1
  import { map, flat, stateScan, reduce, flatMap, empty, } from "../../types/list/module.f.js";
2
- import * as operator from "../../types/function/operator/module.f.js";
2
+ import { concat } from "../../types/function/operator/module.f.js";
3
3
  import { contains } from "../../types/range/module.f.js";
4
- import * as f from "../../types/function/module.f.js";
5
- const { fn } = f;
4
+ import { fn } from "../../types/function/module.f.js";
6
5
  const lowBmp = contains([0x0000, 0xd7ff]);
7
6
  const highBmp = contains([0xe000, 0xffff]);
8
- const isBmpCodePoint = codePoint => lowBmp(codePoint) || highBmp(codePoint);
7
+ const isBmpCodePoint = (codePoint) => lowBmp(codePoint) || highBmp(codePoint);
9
8
  const isHighSurrogate = contains([0xd800, 0xdbff]);
10
9
  const isLowSurrogate = contains([0xdc00, 0xdfff]);
11
10
  const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000;
12
11
  const isSupplementaryPlane = contains([0x01_0000, 0x10_ffff]);
13
- const codePointToUtf16 = codePoint => {
12
+ const codePointToUtf16 = (codePoint) => {
14
13
  if (isBmpCodePoint(codePoint)) {
15
14
  return [codePoint];
16
15
  }
@@ -50,17 +49,17 @@ const utf16ByteToCodePointOp = state => word => {
50
49
  }
51
50
  return [[state | errorMask, word | errorMask], null];
52
51
  };
53
- const utf16EofToCodePointOp = state => [state === null ? empty : [state | errorMask], null];
52
+ const utf16EofToCodePointOp = (state) => [state === null ? empty : [state | errorMask], null];
54
53
  const utf16ByteOrEofToCodePointOp = state => input => input === null ? utf16EofToCodePointOp(state) : utf16ByteToCodePointOp(state)(input);
55
54
  const eofList = [null];
56
- export const toCodePointList = input => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])));
57
- export const stringToList = s => {
58
- const at = i => {
55
+ export const toCodePointList = (input) => flat(stateScan(utf16ByteOrEofToCodePointOp)(null)(flat([input, eofList])));
56
+ export const stringToList = (s) => {
57
+ const at = (i) => {
59
58
  const first = s.charCodeAt(i);
60
59
  return isNaN(first) ? empty : { first, tail: () => at(i + 1) };
61
60
  };
62
61
  return at(0);
63
62
  };
64
63
  export const listToString = fn(map(String.fromCharCode))
65
- .then(reduce(operator.concat)(''))
64
+ .then(reduce(concat)(''))
66
65
  .result;
@@ -1,55 +1,54 @@
1
- import * as encoding from "./module.f.js";
1
+ import { toCodePointList, fromCodePointList, stringToList, listToString } from "./module.f.js";
2
2
  import * as json from "../../json/module.f.js";
3
- import * as o from "../../types/object/module.f.js";
4
- const { sort } = o;
5
- import * as list from "../../types/list/module.f.js";
6
- const stringify = a => json.stringify(sort)(a);
3
+ import { sort } from "../../types/object/module.f.js";
4
+ import { toArray } from "../../types/list/module.f.js";
5
+ const stringify = (a) => json.stringify(sort)(a);
7
6
  export default {
8
7
  toCodePointList: [
9
8
  () => {
10
- const result = stringify(list.toArray(encoding.toCodePointList([-1, 65536])));
9
+ const result = stringify(toArray(toCodePointList([-1, 65536])));
11
10
  if (result !== '[4294967295,4294967295]') {
12
11
  throw result;
13
12
  }
14
13
  },
15
14
  () => {
16
- const result = stringify(list.toArray(encoding.toCodePointList([0, 36, 8364, 55295, 57344, 65535])));
15
+ const result = stringify(toArray(toCodePointList([0, 36, 8364, 55295, 57344, 65535])));
17
16
  if (result !== '[0,36,8364,55295,57344,65535]') {
18
17
  throw result;
19
18
  }
20
19
  },
21
20
  () => {
22
- const result = stringify(list.toArray(encoding.toCodePointList([56320, 57343])));
21
+ const result = stringify(toArray(toCodePointList([56320, 57343])));
23
22
  if (result !== '[-2147427328,-2147426305]') {
24
23
  throw result;
25
24
  }
26
25
  },
27
26
  () => {
28
- const result = stringify(list.toArray(encoding.toCodePointList([55296, 56320, 55297, 56375, 55378, 57186, 56319, 57343])));
27
+ const result = stringify(toArray(toCodePointList([55296, 56320, 55297, 56375, 55378, 57186, 56319, 57343])));
29
28
  if (result !== '[65536,66615,150370,1114111]') {
30
29
  throw result;
31
30
  }
32
31
  },
33
32
  () => {
34
- const result = stringify(list.toArray(encoding.toCodePointList([55296, 55296])));
33
+ const result = stringify(toArray(toCodePointList([55296, 55296])));
35
34
  if (result !== '[-2147428352,-2147428352]') {
36
35
  throw result;
37
36
  }
38
37
  },
39
38
  () => {
40
- const result = stringify(list.toArray(encoding.toCodePointList([55296, 0])));
39
+ const result = stringify(toArray(toCodePointList([55296, 0])));
41
40
  if (result !== '[-2147428352,0]') {
42
41
  throw result;
43
42
  }
44
43
  },
45
44
  () => {
46
- const result = stringify(list.toArray(encoding.toCodePointList([56320])));
45
+ const result = stringify(toArray(toCodePointList([56320])));
47
46
  if (result !== '[-2147427328]') {
48
47
  throw result;
49
48
  }
50
49
  },
51
50
  () => {
52
- const result = stringify(list.toArray(encoding.toCodePointList([56320, 0])));
51
+ const result = stringify(toArray(toCodePointList([56320, 0])));
53
52
  if (result !== '[-2147427328,0]') {
54
53
  throw result;
55
54
  }
@@ -57,67 +56,67 @@ export default {
57
56
  ],
58
57
  fromCodePointList: [
59
58
  () => {
60
- const result = stringify(list.toArray(encoding.fromCodePointList([0])));
59
+ const result = stringify(toArray(fromCodePointList([0])));
61
60
  if (result !== '[0]') {
62
61
  throw result;
63
62
  }
64
63
  },
65
64
  () => {
66
- const result = stringify(list.toArray(encoding.fromCodePointList([0x24])));
65
+ const result = stringify(toArray(fromCodePointList([0x24])));
67
66
  if (result !== '[36]') {
68
67
  throw result;
69
68
  }
70
69
  },
71
70
  () => {
72
- const result = stringify(list.toArray(encoding.fromCodePointList([0x20AC])));
71
+ const result = stringify(toArray(fromCodePointList([0x20AC])));
73
72
  if (result !== '[8364]') {
74
73
  throw result;
75
74
  }
76
75
  },
77
76
  () => {
78
- const result = stringify(list.toArray(encoding.fromCodePointList([0xd7ff])));
77
+ const result = stringify(toArray(fromCodePointList([0xd7ff])));
79
78
  if (result !== '[55295]') {
80
79
  throw result;
81
80
  }
82
81
  },
83
82
  () => {
84
- const result = stringify(list.toArray(encoding.fromCodePointList([0xe000])));
83
+ const result = stringify(toArray(fromCodePointList([0xe000])));
85
84
  if (result !== '[57344]') {
86
85
  throw result;
87
86
  }
88
87
  },
89
88
  () => {
90
- const result = stringify(list.toArray(encoding.fromCodePointList([0xffff])));
89
+ const result = stringify(toArray(fromCodePointList([0xffff])));
91
90
  if (result !== '[65535]') {
92
91
  throw result;
93
92
  }
94
93
  },
95
94
  () => {
96
- const result = stringify(list.toArray(encoding.fromCodePointList([0x10000])));
95
+ const result = stringify(toArray(fromCodePointList([0x10000])));
97
96
  if (result !== '[55296,56320]') {
98
97
  throw result;
99
98
  }
100
99
  },
101
100
  () => {
102
- const result = stringify(list.toArray(encoding.fromCodePointList([0x10437])));
101
+ const result = stringify(toArray(fromCodePointList([0x10437])));
103
102
  if (result !== '[55297,56375]') {
104
103
  throw result;
105
104
  }
106
105
  },
107
106
  () => {
108
- const result = stringify(list.toArray(encoding.fromCodePointList([0x24B62])));
107
+ const result = stringify(toArray(fromCodePointList([0x24B62])));
109
108
  if (result !== '[55378,57186]') {
110
109
  throw result;
111
110
  }
112
111
  },
113
112
  () => {
114
- const result = stringify(list.toArray(encoding.fromCodePointList([0x10ffff])));
113
+ const result = stringify(toArray(fromCodePointList([0x10ffff])));
115
114
  if (result !== '[56319,57343]') {
116
115
  throw result;
117
116
  }
118
117
  },
119
118
  () => {
120
- const result = stringify(list.toArray(encoding.fromCodePointList([-1, 0xd800, 0xdfff, 0x110000])));
119
+ const result = stringify(toArray(fromCodePointList([-1, 0xd800, 0xdfff, 0x110000])));
121
120
  if (result !== '[65535,55296,57343,0]') {
122
121
  throw result;
123
122
  }
@@ -125,17 +124,17 @@ export default {
125
124
  ],
126
125
  string: [
127
126
  () => {
128
- const utf16List = encoding.stringToList("Hello world!😂🚜🚲");
129
- const result = encoding.listToString(utf16List);
127
+ const utf16List = stringToList("Hello world!😂🚜🚲");
128
+ const result = listToString(utf16List);
130
129
  if (result !== "Hello world!😂🚜🚲") {
131
130
  throw result;
132
131
  }
133
132
  },
134
133
  () => {
135
- const a = encoding.stringToList("Hello world!😂🚜🚲");
136
- const b = encoding.toCodePointList(a);
137
- const c = encoding.fromCodePointList(b);
138
- const result = encoding.listToString(c);
134
+ const a = stringToList("Hello world!😂🚜🚲");
135
+ const b = toCodePointList(a);
136
+ const c = fromCodePointList(b);
137
+ const result = listToString(c);
139
138
  if (result !== "Hello world!😂🚜🚲") {
140
139
  throw result;
141
140
  }
@@ -1,6 +1,9 @@
1
1
  import { type List, type Thunk } from '../../types/list/module.f.ts';
2
- type u8 = number;
3
- type i32 = number;
4
- export declare const fromCodePointList: (input: List<number>) => Thunk<number>;
5
- export declare const toCodePointList: (input: List<u8>) => List<i32>;
6
- export {};
2
+ import type { Array1, Array2, Array3 } from '../../types/array/module.f.ts';
3
+ export type ByteOrEof = U8 | null;
4
+ export type Utf8NonEmptyState = Array1<number> | Array2<number> | Array3<number>;
5
+ export type Utf8State = null | Utf8NonEmptyState;
6
+ export type U8 = number;
7
+ export type I32 = number;
8
+ export declare const fromCodePointList: (input: List<number>) => Thunk<U8>;
9
+ export declare const toCodePointList: (input: List<U8>) => List<I32>;
@@ -1,8 +1,6 @@
1
1
  import { flatMap, flat, stateScan } from "../../types/list/module.f.js";
2
- import * as operator from "../../types/function/operator/module.f.js";
3
- import * as Array from "../../types/array/module.f.js";
4
2
  const errorMask = 0b1000_0000_0000_0000_0000_0000_0000_0000;
5
- const codePointToUtf8 = input => {
3
+ const codePointToUtf8 = (input) => {
6
4
  if (input >= 0x0000 && input <= 0x007f) {
7
5
  return [input & 0b01111_1111];
8
6
  }
@@ -32,7 +30,7 @@ const codePointToUtf8 = input => {
32
30
  return [errorMask];
33
31
  };
34
32
  export const fromCodePointList = flatMap(codePointToUtf8);
35
- const utf8StateToError = state => {
33
+ const utf8StateToError = (state) => {
36
34
  let x;
37
35
  switch (state.length) {
38
36
  case 1: {
@@ -106,7 +104,7 @@ const utf8ByteToCodePointOp = state => byte => {
106
104
  }
107
105
  return [[error, byte | errorMask], null];
108
106
  };
109
- const utf8EofToCodePointOp = state => [state === null ? null : [utf8StateToError(state)], null];
107
+ const utf8EofToCodePointOp = (state) => [state === null ? null : [utf8StateToError(state)], null];
110
108
  const utf8ByteOrEofToCodePointOp = state => input => input === null ? utf8EofToCodePointOp(state) : utf8ByteToCodePointOp(state)(input);
111
109
  const eofList = [null];
112
110
  export const toCodePointList = input => flat(stateScan(utf8ByteOrEofToCodePointOp)(null)(flat([input, eofList])));