wc3maptranslator 4.0.0 → 4.0.2

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 (118) hide show
  1. package/LICENSE.md +23 -23
  2. package/dist/AngleConverter.d.ts +3 -0
  3. package/dist/AngleConverter.d.ts.map +1 -0
  4. package/dist/AngleConverter.js +12 -0
  5. package/dist/AngleConverter.js.map +1 -0
  6. package/dist/CommonInterfaces.d.ts +17 -0
  7. package/dist/CommonInterfaces.d.ts.map +1 -0
  8. package/dist/CommonInterfaces.js +3 -0
  9. package/dist/CommonInterfaces.js.map +1 -0
  10. package/dist/HexBuffer.d.ts +15 -0
  11. package/dist/HexBuffer.d.ts.map +1 -0
  12. package/{lib/HexBuffer.ts → dist/HexBuffer.js} +71 -81
  13. package/dist/HexBuffer.js.map +1 -0
  14. package/dist/W3Buffer.d.ts +14 -0
  15. package/dist/W3Buffer.d.ts.map +1 -0
  16. package/{lib/W3Buffer.ts → dist/W3Buffer.js} +63 -69
  17. package/dist/W3Buffer.js.map +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/{index.js → dist/index.js} +1 -1
  21. package/dist/index.js.map +1 -0
  22. package/dist/translators/CamerasTranslator.d.ts +23 -0
  23. package/dist/translators/CamerasTranslator.d.ts.map +1 -0
  24. package/{lib/translators/CamerasTranslator.ts → dist/translators/CamerasTranslator.js} +76 -101
  25. package/dist/translators/CamerasTranslator.js.map +1 -0
  26. package/dist/translators/DoodadsTranslator.d.ts +23 -0
  27. package/dist/translators/DoodadsTranslator.d.ts.map +1 -0
  28. package/{lib/translators/DoodadsTranslator.ts → dist/translators/DoodadsTranslator.js} +146 -178
  29. package/dist/translators/DoodadsTranslator.js.map +1 -0
  30. package/dist/translators/ImportsTranslator.d.ts +16 -0
  31. package/dist/translators/ImportsTranslator.d.ts.map +1 -0
  32. package/{lib/translators/ImportsTranslator.ts → dist/translators/ImportsTranslator.js} +62 -78
  33. package/dist/translators/ImportsTranslator.js.map +1 -0
  34. package/dist/translators/InfoTranslator.d.ts +124 -0
  35. package/dist/translators/InfoTranslator.d.ts.map +1 -0
  36. package/{lib/translators/InfoTranslator.ts → dist/translators/InfoTranslator.js} +422 -584
  37. package/dist/translators/InfoTranslator.js.map +1 -0
  38. package/dist/translators/ObjectsTranslator.d.ts +23 -0
  39. package/dist/translators/ObjectsTranslator.d.ts.map +1 -0
  40. package/{lib/translators/ObjectsTranslator.ts → dist/translators/ObjectsTranslator.js} +91 -125
  41. package/dist/translators/ObjectsTranslator.js.map +1 -0
  42. package/dist/translators/RegionsTranslator.d.ts +22 -0
  43. package/dist/translators/RegionsTranslator.d.ts.map +1 -0
  44. package/{lib/translators/RegionsTranslator.ts → dist/translators/RegionsTranslator.js} +96 -123
  45. package/dist/translators/RegionsTranslator.js.map +1 -0
  46. package/dist/translators/SoundsTranslator.d.ts +35 -0
  47. package/dist/translators/SoundsTranslator.d.ts.map +1 -0
  48. package/{lib/translators/SoundsTranslator.ts → dist/translators/SoundsTranslator.js} +183 -237
  49. package/dist/translators/SoundsTranslator.js.map +1 -0
  50. package/dist/translators/StringsTranslator.d.ts +7 -0
  51. package/dist/translators/StringsTranslator.d.ts.map +1 -0
  52. package/{lib/translators/StringsTranslator.ts → dist/translators/StringsTranslator.js} +44 -49
  53. package/dist/translators/StringsTranslator.js.map +1 -0
  54. package/dist/translators/TerrainTranslator.d.ts +33 -0
  55. package/dist/translators/TerrainTranslator.d.ts.map +1 -0
  56. package/{lib/translators/TerrainTranslator.ts → dist/translators/TerrainTranslator.js} +221 -276
  57. package/dist/translators/TerrainTranslator.js.map +1 -0
  58. package/dist/translators/UnitsTranslator.d.ts +40 -0
  59. package/dist/translators/UnitsTranslator.d.ts.map +1 -0
  60. package/{lib/translators/UnitsTranslator.ts → dist/translators/UnitsTranslator.js} +199 -261
  61. package/dist/translators/UnitsTranslator.js.map +1 -0
  62. package/{lib/translators/index.ts → dist/translators/index.d.ts} +11 -10
  63. package/dist/translators/index.d.ts.map +1 -0
  64. package/dist/translators/index.js +23 -0
  65. package/dist/translators/index.js.map +1 -0
  66. package/package.json +4 -2
  67. package/.codeclimate.yml +0 -12
  68. package/.editorconfig +0 -8
  69. package/.eslintignore +0 -5
  70. package/.eslintrc +0 -55
  71. package/.github/workflows/codeql-analysis.yml +0 -54
  72. package/.nycrc +0 -18
  73. package/.travis.yml +0 -23
  74. package/CHANGELOG.md +0 -73
  75. package/index.ts +0 -14
  76. package/lib/AngleConverter.ts +0 -7
  77. package/lib/CommonInterfaces.ts +0 -22
  78. package/test/.mocharc.json +0 -4
  79. package/test/AngleConverterTest.ts +0 -18
  80. package/test/HexBufferTest.ts +0 -170
  81. package/test/TranslatorReversion.ts +0 -218
  82. package/test/W3BufferTest.ts +0 -50
  83. package/test/data/cameras.json +0 -16
  84. package/test/data/doodads.json +0 -2730
  85. package/test/data/imports.json +0 -386
  86. package/test/data/info.json +0 -250
  87. package/test/data/obj-abilities.json +0 -4892
  88. package/test/data/obj-buffs.json +0 -38
  89. package/test/data/obj-destructables.json +0 -31
  90. package/test/data/obj-doodads.json +0 -38
  91. package/test/data/obj-items.json +0 -31
  92. package/test/data/obj-units.json +0 -40
  93. package/test/data/obj-upgrades.json +0 -38
  94. package/test/data/regions.json +0 -206
  95. package/test/data/sounds.json +0 -50
  96. package/test/data/strings.json +0 -115
  97. package/test/data/terrain.json +0 -1
  98. package/test/data/units.json +0 -452
  99. package/test/data/war3map.doo +0 -0
  100. package/test/data/war3map.imp +0 -0
  101. package/test/data/war3map.j +0 -3442
  102. package/test/data/war3map.shd +0 -0
  103. package/test/data/war3map.w3a +0 -0
  104. package/test/data/war3map.w3b +0 -0
  105. package/test/data/war3map.w3c +0 -0
  106. package/test/data/war3map.w3d +0 -0
  107. package/test/data/war3map.w3e +0 -0
  108. package/test/data/war3map.w3h +0 -0
  109. package/test/data/war3map.w3i +0 -0
  110. package/test/data/war3map.w3q +0 -0
  111. package/test/data/war3map.w3r +0 -0
  112. package/test/data/war3map.w3s +0 -0
  113. package/test/data/war3map.w3t +0 -0
  114. package/test/data/war3map.w3u +0 -0
  115. package/test/data/war3map.wts +0 -631
  116. package/test/data/war3mapUnits.doo +0 -0
  117. package/tsconfig.json +0 -25
  118. package/tslint.json +0 -47
package/.eslintrc DELETED
@@ -1,55 +0,0 @@
1
- {
2
- "env": {
3
- "node": true
4
- },
5
- "parserOptions": {
6
- "ecmaVersion": 6,
7
- "sourceType": "module"
8
- },
9
- "rules": {
10
- "no-cond-assign": [2,"always"],
11
- "no-console": 2,
12
- "no-constant-condition": 2,
13
- "no-control-regex": 2,
14
- "no-debugger": 2,
15
- "no-dupe-args": 2,
16
- "no-dupe-keys": 2,
17
- "no-duplicate-case": 2,
18
- "no-empty-character-class": 2,
19
- "no-empty": 2,
20
- "no-ex-assign": 2,
21
- "no-extra-boolean-cast": 1,
22
- "no-extra-parens": [1,"all"],
23
- "no-extra-semi": 1,
24
- "no-func-assign": 2,
25
- "no-irregular-whitespace": 1,
26
- "no-sparse-arrays": 2,
27
- "use-isnan": 2,
28
- "valid-typeof": 2,
29
- "no-alert": 2,
30
- "no-caller": 2,
31
- "no-labels": 2,
32
- "no-octal": 2,
33
- "no-redeclare": 2,
34
- "no-script-url": 2,
35
- "no-warning-comments": [2,{"terms":["TODO","FIXME"],"location":"anywhere"}],
36
- "wrap-iife": [2,"any"],
37
- "strict": [2,"never"],
38
- "no-delete-var": 2,
39
- "callback-return": 2,
40
- "no-path-concat": 2,
41
- "brace-style": [2,"stroustrup",{"allowSingleLine":true}],
42
- "comma-spacing": [2,{"after":true}],
43
- "eol-last": 2,
44
- "id-length": [2,{"min":2,"max":26,"exceptions":["b","i","j","k","x","y"]}],
45
- "indent": [2,4],
46
- "no-underscore-dangle": 2,
47
- "object-curly-spacing": [2,"always",{"arraysInObjects":true,"objectsInObjects":true}],
48
- "one-var": 1,
49
- "quotes": [2,"single","avoid-escape"],
50
- "semi": [2,"always"],
51
- "space-before-blocks": [2,"always"],
52
- "arrow-parens": [2,"always"],
53
- "no-var": 1
54
- }
55
- }
@@ -1,54 +0,0 @@
1
- name: "Code scanning - action"
2
-
3
- on:
4
- push:
5
- branches: [master, ]
6
- pull_request:
7
- # The branches below must be a subset of the branches above
8
- branches: [master]
9
- schedule:
10
- - cron: '0 22 * * 5'
11
-
12
- jobs:
13
- CodeQL-Build:
14
-
15
- runs-on: ubuntu-latest
16
-
17
- steps:
18
- - name: Checkout repository
19
- uses: actions/checkout@v2
20
- with:
21
- # We must fetch at least the immediate parents so that if this is
22
- # a pull request then we can checkout the head.
23
- fetch-depth: 2
24
-
25
- # If this run was triggered by a pull request event, then checkout
26
- # the head of the pull request instead of the merge commit.
27
- - run: git checkout HEAD^2
28
- if: ${{ github.event_name == 'pull_request' }}
29
-
30
- # Initializes the CodeQL tools for scanning.
31
- - name: Initialize CodeQL
32
- uses: github/codeql-action/init@v1
33
- # Override language selection by uncommenting this and choosing your languages
34
- # with:
35
- # languages: go, javascript, csharp, python, cpp, java
36
-
37
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
38
- # If this step fails, then you should remove it and run the build manually (see below)
39
- - name: Autobuild
40
- uses: github/codeql-action/autobuild@v1
41
-
42
- # ℹ️ Command-line programs to run using the OS shell.
43
- # 📚 https://git.io/JvXDl
44
-
45
- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
46
- # and modify them (or add more) to build your code if your project
47
- # uses a compiled language
48
-
49
- #- run: |
50
- # make bootstrap
51
- # make release
52
-
53
- - name: Perform CodeQL Analysis
54
- uses: github/codeql-action/analyze@v1
package/.nycrc DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "extends": "@istanbuljs/nyc-config-typescript",
3
- "check-coverage": true,
4
- "per-file": true,
5
- "extension": [
6
- ".ts",
7
- ".tsx"
8
- ],
9
- "exclude": [
10
- "**/*.d.ts",
11
- "**/coverage/**"
12
- ],
13
- "reporter": [
14
- "lcov",
15
- "text-summary"
16
- ],
17
- "all": true
18
- }
package/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- # Modeled after: https://travis-ci.org/microsoft/TypeScript/jobs/625136191/config
2
-
3
- language: node_js
4
-
5
- node_js:
6
- - "14"
7
-
8
- branches:
9
- only:
10
- - master
11
-
12
- install:
13
- - npm uninstall typescript --no-save
14
- - npm install
15
-
16
- cache:
17
- directories:
18
- - node_modules
19
-
20
- script: "npm run-script test-travis"
21
-
22
- # Send coverage data to Coveralls
23
- after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
package/CHANGELOG.md DELETED
@@ -1,73 +0,0 @@
1
- # 4.0.0 (2021-02-28)
2
- ## SUMMARY
3
- **🔥 Breaking changes**
4
-
5
- This major release significantly overhauls WC3MapTranslator since the release of WarCraft III: Reforged. There are a few breaking changes in this release.
6
-
7
- The two largest changes include a new usage contract and changes to the terrain `.json` format, both of which are detailed below. This release also integrates the latest file formats, after a few changes to the war3map formats to support Reforged.
8
-
9
- The old usage contract meant that developers had to instantiate translators, which didn't make much sense. Now translators are static classes that can be used directly after importing.
10
-
11
- The `.json` format for terrain gets rid of the bulky `tile` objects and returns to a one-dimensional mask array for things like ground height, boundary flags, etc. In an older version of WC3MapTranslator, terrain used to be a multi-dimensional array of rows, followed by the `tile` object format. The problems with the `tile` object format were two-fold: (1) file size would blow up (e.g. a 29kB `.w3e` file would become a 1199kB `.json` terrain file); and (2) the bulky `tile` objects did not lend themselves to the spirit of having a diff-able JSON file. We believe that a single-dimensional array will allow developers to more easily see differences between JSONs.
12
-
13
- Another exciting change is a new [WC3MapSpecification](https://github.com/ChiefOfGxBxL/WC3MapSpecification) repository for documenting the war3map specifications. This is a living document, meaning it may be updated in-place as our understanding of the file formats improves!
14
-
15
- ## FEATURES
16
- * 🔥 Improve usage contract:
17
- * Translators are now exported by this library (e.g. `import { ObjectTranslator } from 'wc3maptranslator'`)
18
- * Translators no longer need to be instantiated to be used
19
- * 🔥 Change terrain format:
20
- * Tiles are now defined via "masks", for ground height, texture, variation, etc.
21
- * Before: `tiles` is an array of objects... `{ groundHeight, waterHeight, boundaryFlag, flags, groundTexture, groundVariation, cliffVariation, cliffTexture, layerHeight }`
22
- * After: a one-dimensional array for each of the above fields... e.g. for a 64x64 map, `groundHeight` is an array of 65*65=4225 tile points
23
- * Some fields have been renamed into camelCase for consistency:
24
- * `customtileset` -> `customTileset`
25
- * `tilepalette` -> `tilePalette`
26
- * `clifftilepalette` -> `cliffTilePalette`
27
- * Upgrade to latest file formats
28
- * Sounds version upgraded from `1` -> `3`
29
- * Info version upgraded from `25` -> `31`
30
- * Add more type safety:
31
- * Translator results from `jsonToWar()` and `warToJson()` are now typed by `WarResult` and `JsonResult`, respectively
32
- * `JsonResult` is generically typed to describe what it contains (e.g. `Sound[]`)
33
- * Introduced new `angle` type, which is an alias for `number`; `angle`'s should always be specified in degrees, not radians
34
- ## FIXES
35
- * Resolve `[DEP0005] DeprecationWarning: Buffer()` warning in `HexBuffer.ts`
36
- * Fix scoping issues on `*Translator.ts`, `HexBuffer.ts` and `W3Buffer.ts` where certain fields that should be `private` were marked as `public`
37
- * Fix InfoTranslator reading random item table ID length as 1 instead of 4
38
- * Fix potential null-terminator errors related to string or character-array fields
39
- ## MAINTENANCE
40
- * Upgrade to Node 14.x LTS
41
- * Upgrade to npm 7.x
42
- * Upgrade `round-to` 4.1.0 -> 5.0.0
43
- * Upgrade `@types/fs-extra` 8.1.0 -> 9.0.7
44
- * Upgrade `@types/mocha` 7.0.1 -> 8.2.1
45
- * Upgrade `@types/node` 12.12.28 -> 14.14.31
46
- * Upgrade `fs-extra` 8.1.0 -> 9.1.0
47
- * Upgrade `mocha` 7.0.1 -> 8.3.0
48
- * Upgrade `nyc` 15.0.0 -> 15.1.0
49
- * Upgrade `ts-node` 8.6.2 -> 9.1.1
50
- * Upgrade `tslint` 6.0.0 -> 6.1.3
51
- * Upgrade `typescript` 3.8.2 -> 4.2.2
52
- * The project structure has changed:
53
- * `examples` sub-project directory is removed
54
- * Refer to `USAGE.md` for how to use the code
55
- * Add all contributors to `package.json`
56
- * Resolve all security issues via `npm audit fix` (5 low, 1 high, 1 critical)
57
- ## TESTING
58
- * Travis CI will now use Node 14 LTS to build the project
59
- * `test` directory now contains the WC3 and JSON data files the tests require
60
- * Implement the StringsTranslator test
61
- * Resolve all broken unit tests, most of them being reversion tests
62
- <!--
63
- # x.y.z (YYYY-MM-DD)
64
- ## SUMMARY
65
- **🔥 Breaking changes**
66
- ## FEATURES
67
- ## FIXES
68
- ## MAINTENANCE
69
- ## TESTING
70
- -->
71
-
72
- # Previous versions
73
- The `CHANGELOG.md` file was introduced with the 4.x release. For details on previous changes, please refer to https://github.com/ChiefOfGxBxL/WC3MapTranslator/releases.
package/index.ts DELETED
@@ -1,14 +0,0 @@
1
- import { CamerasTranslator, DoodadsTranslator, ImportsTranslator, InfoTranslator, ObjectsTranslator, RegionsTranslator, SoundsTranslator, StringsTranslator, TerrainTranslator, UnitsTranslator } from './lib/translators';
2
-
3
- export {
4
- CamerasTranslator,
5
- DoodadsTranslator,
6
- ImportsTranslator,
7
- InfoTranslator,
8
- ObjectsTranslator,
9
- RegionsTranslator,
10
- SoundsTranslator,
11
- StringsTranslator,
12
- TerrainTranslator,
13
- UnitsTranslator
14
- };
@@ -1,7 +0,0 @@
1
- export function deg2Rad(angleInDegrees: number): number {
2
- return angleInDegrees * Math.PI / 180;
3
- }
4
-
5
- export function rad2Deg(angleInRadians: number): number {
6
- return angleInRadians * 180 / Math.PI;
7
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * @type angle - An angle is measured in degrees, 0 <= angle < 360
3
- */
4
- export type angle = number;
5
-
6
- // TranslationError is reserved for future use in case
7
- // additional constraints are added to translated output,
8
- // like if WC3 has maximum string lengths, or if certain
9
- // values must be in a specific range
10
- export interface TranslationError {
11
- message: string
12
- }
13
-
14
- export interface WarResult {
15
- buffer: Buffer,
16
- errors?: TranslationError[]
17
- }
18
-
19
- export interface JsonResult<T = object> {
20
- json: T,
21
- errors?: TranslationError[]
22
- }
@@ -1,4 +0,0 @@
1
- {
2
- "recursive": true,
3
- "require": ["ts-node/register", "source-map-support/register"]
4
- }
@@ -1,18 +0,0 @@
1
- import assert from 'assert';
2
- import { deg2Rad, rad2Deg } from '../lib/AngleConverter';
3
-
4
- describe('AngleConverter', () => {
5
-
6
- it('should convert degrees to radians', () => {
7
- const angleInDegrees = 90;
8
- const convertedToRadians = deg2Rad(angleInDegrees);
9
- assert.equal(convertedToRadians, Math.PI / 2);
10
- });
11
-
12
- it('should convert radians to degrees', () => {
13
- const angleInRadians = Math.PI;
14
- const convertedToDegrees = rad2Deg(angleInRadians);
15
- assert.equal(convertedToDegrees, 180);
16
- });
17
-
18
- });
@@ -1,170 +0,0 @@
1
- import assert from 'assert';
2
- import { HexBuffer } from '../lib/HexBuffer';
3
-
4
- let hexBuffer: HexBuffer;
5
-
6
- describe('HexBuffer', () => {
7
-
8
- beforeEach(() => {
9
- // clear the buffer before each test in this block so we
10
- // don't have to care about what we added in prior tests
11
- hexBuffer = new HexBuffer();
12
- });
13
-
14
- it('should addString', () => {
15
- const testWords = [
16
- 'Hallo, wêreld!', // Afrikaans
17
- 'Pershëndetje Botë', // Albanian
18
- 'أهلاً بالعالم', // Arabic
19
- 'Բարե՛ւ, աշխարհ։', // Armenian
20
- 'Salam Dünya', // Azeri
21
- 'Ahoj Světe!', // Czech
22
- 'Kaixo mundua!', // Basque/Euskara
23
- 'Прывітанне свет', // Belarusian
24
- 'Shani Mwechalo!', // Bemba
25
- 'Shagatam Prithivi!', // Bengali
26
- 'Zdravo Svijete!', // Bosnian
27
- 'Здравей, свят!', // Bulgarian
28
- 'ជំរាបសួរ ពិភពលោក', // Cambodian
29
- 'Hola món!', // Catalan
30
- '你好世界', // Chinese
31
- 'ᎣᏏᏲ ᎡᎶᎯ', // Cherokee
32
- 'Klahowya Hayas Klaska', // Chinook Wawa
33
- 'Bok Svijete!', // Croatian
34
- 'Hej, Verden!', // Danish
35
- 'Hallo, wereld!', // Dutch
36
- 'Hello World!', // English
37
- 'Saluton mondo!', // Esperanto
38
- 'Tere maailm!', // Estonian
39
- 'Hei maailma!', // Finnish
40
- 'Salut le Monde!', // French
41
- 'Hallo, wrâld!', // Frisian
42
- 'Ola mundo!', // Galician
43
- 'Hallo Welt!', // German
44
- 'Γεια σου κόσμε!', // Greek
45
- 'Aloha Honua', // Hawaiian
46
- 'שלום עולם', // Hebrew
47
- 'नमस्ते दुनिया', // Hindi
48
- 'Nyob zoo ntiaj teb.', // Hmong
49
- 'Helló világ!', // Hungarian
50
- 'Halló heimur!', // Icelandic
51
- 'Ndewo Ụwa', // Igbo
52
- 'Halo Dunia!', // Indonesian
53
- 'Dia dhaoibh, a dhomhain!', // Irish
54
- 'Ciao Mondo!', // Italian
55
- 'こんにちは、 世界!', // Japanese
56
- 'ಹಲೋ ವರ್ಲ್ಡ್', // Kannada
57
- 'Habari dunia!', // Kiswahili
58
- 'Niatia thi!', // Kikuyu
59
- 'nuqneH', // Klingon
60
- '반갑다 세상아', // Korean
61
- 'ສະບາຍດີ,ໂລກ', // Lao
62
- 'AVE MVNDE', // Latin
63
- 'Sveika, Pasaule!', // Latvian
64
- 'Sveikas, Pasauli', // Lithuanian
65
- 'coi li terdi', // Lojban
66
- 'Moien Welt!', // Luxembourgish
67
- 'Manao ahoana ry tany!', // Malagasy
68
- 'Namaskaram, lokame', // Malayalam
69
- 'Merhba lid-dinja', // Maltese
70
- 'Hallo verden!', // Norwegian
71
- '!سلام دنیا', // Persian
72
- 'Witaj świecie!', // Polish
73
- 'Olá, mundo!', // Portuguese
74
- 'ਸਤਿ ਸ੍ਰੀ ਅਕਾਲ ਦੁਨਿਆ', // Punjabi
75
- 'Salut lume!', // Romanian
76
- 'Здравствуй, мир!', // Russian
77
- 'Halò, a Shaoghail!', // Scots Gaelic
78
- 'Zdravo Svete!', // Serbian
79
- 'Ahoj, svet!', // Slovak
80
- 'Pozdravljen svet!', // Slovenian
81
- '¡Hola mundo!', // Spanish
82
- 'Hallå världen!', // Swedish
83
- 'Kamusta mundo!', // Tagalog
84
- 'ஹலோ உலகம்', // Tamil
85
- 'హలో వరల్డ్', // Telugu
86
- 'สวัสดีโลก!', // Thai
87
- 'Merhaba Dünya!', // Turkish
88
- 'Привiт, свiте!', // Ukrainian
89
- 'ہیلو دنیا والو', // Urdu
90
- 'Xin chào thế giới', // Vietnamese
91
- 'S\'mae byd!', // Welsh
92
- 'העלא וועלט', // Yiddish
93
- 'Sawubona Mhlaba' // Zulu
94
- ];
95
-
96
- let totalLength = 0;
97
- // tslint:disable-next-line: forin
98
- for (const word of testWords) {
99
- const bufLength = Buffer.from(word).length;
100
- hexBuffer.addString(word);
101
- totalLength += bufLength + 1; // adding one accounts for the null terminator at the end of the string
102
- const bufferLength = hexBuffer.getBuffer().length;
103
- assert.equal(bufferLength, totalLength);
104
- }
105
- });
106
-
107
- it('should addNewLine', () => {
108
- hexBuffer.addNewLine();
109
- assert.equal(hexBuffer.getBuffer().length, 2);
110
- assert.equal(hexBuffer.getBuffer()[0], 0x0d);
111
- assert.equal(hexBuffer.getBuffer()[1], 0x0a);
112
- });
113
-
114
- it('should addChar', () => {
115
- hexBuffer.addChar('A');
116
- assert.equal(hexBuffer.getBuffer().length, 1);
117
- assert.equal(hexBuffer.getBuffer()[0], 65); // charcode for the ASCII letter "A"
118
- });
119
-
120
- it('should addChars', () => {
121
- hexBuffer.addChars('ABCD');
122
- assert.equal(hexBuffer.getBuffer().length, 4);
123
- assert.equal(hexBuffer.getBuffer()[0], 65); // charcode for the ASCII letter "A"
124
- assert.equal(hexBuffer.getBuffer()[1], 66); // charcode for the ASCII letter "B"
125
- assert.equal(hexBuffer.getBuffer()[2], 67); // charcode for the ASCII letter "C"
126
- assert.equal(hexBuffer.getBuffer()[3], 68); // charcode for the ASCII letter "D"
127
- });
128
-
129
- it('should addInt', () => {
130
- hexBuffer.addInt(0);
131
- assert.equal(hexBuffer.getBuffer().length, 4); // integer is 4 bytes in length
132
- assert.equal(hexBuffer.getBuffer()[0], 0x00);
133
- assert.equal(hexBuffer.getBuffer()[1], 0x00);
134
- assert.equal(hexBuffer.getBuffer()[2], 0x00);
135
- assert.equal(hexBuffer.getBuffer()[3], 0x00);
136
- });
137
-
138
- it('should addShort', () => {
139
- hexBuffer.addShort(14);
140
- assert.equal(hexBuffer.getBuffer().length, 2); // 2 bytes in length
141
- assert.equal(hexBuffer.getBuffer()[0], 0x0e);
142
- assert.equal(hexBuffer.getBuffer()[1], 0x00);
143
- });
144
-
145
- it('should addFloat', () => {
146
- hexBuffer.addFloat(1.234);
147
- assert.equal(hexBuffer.getBuffer().length, 4); // 4 bytes in length
148
- assert.equal(hexBuffer.getBuffer()[0], 0xb6);
149
- assert.equal(hexBuffer.getBuffer()[1], 0xf3);
150
- assert.equal(hexBuffer.getBuffer()[2], 0x9d);
151
- assert.equal(hexBuffer.getBuffer()[3], 0x3f);
152
- });
153
-
154
- it('should addByte', () => {
155
- hexBuffer.addByte(15);
156
- assert.equal(hexBuffer.getBuffer()[0], 15);
157
- });
158
-
159
- it('should addNullTerminator', () => {
160
- hexBuffer.addNullTerminator();
161
- assert.equal(hexBuffer.getBuffer().length, 1);
162
- assert.equal(hexBuffer.getBuffer()[0], 0);
163
- });
164
-
165
- it('should getBuffer', () => {
166
- hexBuffer.addString('');
167
- assert(hexBuffer.getBuffer()); // test if this function works
168
- });
169
-
170
- });