@dprint/typescript 0.55.0 → 0.56.0
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.
- package/buffer.generated.js +1 -1
- package/index.d.ts +2 -0
- package/index.js +16 -16
- package/package.json +2 -1
package/index.d.ts
ADDED
package/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* @returns {ArrayBuffer}
|
|
4
4
|
*/
|
|
5
5
|
function getBuffer() {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const encodedBuffer = require("./buffer.generated").encodedBuffer;
|
|
7
|
+
return decodeEncodedBuffer(encodedBuffer);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -12,23 +12,23 @@ function getBuffer() {
|
|
|
12
12
|
* @returns {ArrayBuffer}
|
|
13
13
|
*/
|
|
14
14
|
function decodeEncodedBuffer(encodedBuffer) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
// https://stackoverflow.com/a/51473757/188246
|
|
16
|
+
const binaryString = toBinaryString();
|
|
17
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
18
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
19
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
20
|
+
}
|
|
21
|
+
return bytes.buffer;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
23
|
+
function toBinaryString() {
|
|
24
|
+
if (typeof atob === "function") {
|
|
25
|
+
return atob(encodedBuffer);
|
|
26
|
+
} else {
|
|
27
|
+
return Buffer.from(encodedBuffer, "base64").toString("binary");
|
|
29
28
|
}
|
|
29
|
+
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
module.exports = {
|
|
33
|
-
|
|
33
|
+
getBuffer,
|
|
34
34
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dprint/typescript",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "Wasm buffer for dprint-plugin-typescript.",
|
|
5
5
|
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "git+https://github.com/dprint/dprint-plugin-typescript.git"
|