@jscad/io-utils 2.0.13 → 2.0.16
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/BinaryReader.js +1 -1
- package/Blob.js +10 -1
- package/Blob.test.js +1 -1
- package/CHANGELOG.md +27 -0
- package/convertToBlob.test.js +4 -4
- package/package.json +3 -3
package/BinaryReader.js
CHANGED
|
@@ -80,7 +80,7 @@ class BinaryReader {
|
|
|
80
80
|
|
|
81
81
|
return exponent === (bias << 1) + 1 ? significand ? NaN : signal ? -Infinity : +Infinity
|
|
82
82
|
: (1 + signal * -2) * (exponent || significand ? !exponent ? Math.pow(2, -bias + 1) * significand
|
|
83
|
-
|
|
83
|
+
: Math.pow(2, exponent - bias) * (1 + significand) : 0)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
_decodeInt (bits, signed) {
|
package/Blob.js
CHANGED
|
@@ -38,11 +38,20 @@ class Blob {
|
|
|
38
38
|
this.encoding = 'utf8'
|
|
39
39
|
// storage
|
|
40
40
|
this.buffer = null
|
|
41
|
-
this.length =
|
|
41
|
+
this.length = 0 // allocation, not contents
|
|
42
42
|
|
|
43
43
|
if (!contents) return
|
|
44
44
|
if (!Array.isArray(contents)) return
|
|
45
45
|
|
|
46
|
+
// Find content length
|
|
47
|
+
contents.forEach((content) => {
|
|
48
|
+
if (typeof (content) === 'string') {
|
|
49
|
+
this.length += content.length
|
|
50
|
+
} else if (content instanceof ArrayBuffer) {
|
|
51
|
+
this.length += content.byteLength
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
|
|
46
55
|
// process options if any
|
|
47
56
|
if (options.type) {
|
|
48
57
|
// TBD if type contains any chars outside range U+0020 to U+007E, then set type to the empty string
|
package/Blob.test.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.16](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@2.0.15...@jscad/io-utils@2.0.16) (2022-04-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @jscad/io-utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [2.0.15](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@2.0.14...@jscad/io-utils@2.0.15) (2022-03-13)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @jscad/io-utils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [2.0.14](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@2.0.13...@jscad/io-utils@2.0.14) (2022-03-06)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **io:** corrected Blob to allocate internal buffer based contents ([#1006](https://github.com/jscad/OpenJSCAD.org/issues/1006)) ([df4552a](https://github.com/jscad/OpenJSCAD.org/commit/df4552a842fd884680d618f6f9b97ac7c7eb9d8b))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
## [2.0.13](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/io-utils@2.0.12...@jscad/io-utils@2.0.13) (2022-02-19)
|
|
7
34
|
|
|
8
35
|
**Note:** Version bump only for package @jscad/io-utils
|
package/convertToBlob.test.js
CHANGED
|
@@ -8,7 +8,7 @@ test('convert strings', (t) => {
|
|
|
8
8
|
t.is(ablob.type, 'test1')
|
|
9
9
|
t.is(ablob.isClosed, false)
|
|
10
10
|
t.is(ablob.encoding, 'utf8')
|
|
11
|
-
t.is(ablob.length,
|
|
11
|
+
t.is(ablob.length, 4)
|
|
12
12
|
t.not(ablob.buffer, null)
|
|
13
13
|
|
|
14
14
|
ablob = convertToBlob({ data: ['1FAE', '0c8a'], mimeType: 'test2' })
|
|
@@ -16,7 +16,7 @@ test('convert strings', (t) => {
|
|
|
16
16
|
t.is(ablob.type, 'test2')
|
|
17
17
|
t.is(ablob.isClosed, false)
|
|
18
18
|
t.is(ablob.encoding, 'utf8')
|
|
19
|
-
t.is(ablob.length,
|
|
19
|
+
t.is(ablob.length, 8)
|
|
20
20
|
t.not(ablob.buffer, null)
|
|
21
21
|
})
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ test('convert array buffers', (t) => {
|
|
|
26
26
|
t.is(ablob.type, 'test3')
|
|
27
27
|
t.is(ablob.isClosed, false)
|
|
28
28
|
t.is(ablob.encoding, 'utf8')
|
|
29
|
-
t.is(ablob.length,
|
|
29
|
+
t.is(ablob.length, 20)
|
|
30
30
|
t.not(ablob.buffer, null)
|
|
31
31
|
|
|
32
32
|
// multiple buffers
|
|
@@ -35,6 +35,6 @@ test('convert array buffers', (t) => {
|
|
|
35
35
|
t.is(ablob.type, 'test4')
|
|
36
36
|
t.is(ablob.isClosed, false)
|
|
37
37
|
t.is(ablob.encoding, 'utf8')
|
|
38
|
-
t.is(ablob.length,
|
|
38
|
+
t.is(ablob.length, 30)
|
|
39
39
|
t.not(ablob.buffer, null)
|
|
40
40
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jscad/io-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.16",
|
|
4
4
|
"description": "Utilities for JSCAD IO Packages",
|
|
5
5
|
"repository": "https://github.com/jscad/OpenJSCAD.org",
|
|
6
6
|
"main": "index.js",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
],
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@jscad/modeling": "2.
|
|
35
|
+
"@jscad/modeling": "2.9.1",
|
|
36
36
|
"ava": "3.15.0",
|
|
37
37
|
"nyc": "15.1.0"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "a90b9bad95a417661c619dc733e62c587dc71a4a"
|
|
40
40
|
}
|