pptxtojson 0.0.1

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/src/utils.js ADDED
@@ -0,0 +1,72 @@
1
+ export function base64ArrayBuffer(arrayBuffer) {
2
+ let base64 = ''
3
+ const encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
4
+ const bytes = new Uint8Array(arrayBuffer)
5
+ const byteLength = bytes.byteLength
6
+ const byteRemainder = byteLength % 3
7
+ const mainLength = byteLength - byteRemainder
8
+
9
+ let a, b, c, d
10
+ let chunk
11
+
12
+ for (let i = 0; i < mainLength; i = i + 3) {
13
+ chunk = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2]
14
+ a = (chunk & 16515072) >> 18
15
+ b = (chunk & 258048) >> 12
16
+ c = (chunk & 4032) >> 6
17
+ d = chunk & 63
18
+ base64 += encodings[a] + encodings[b] + encodings[c] + encodings[d]
19
+ }
20
+
21
+ if (byteRemainder === 1) {
22
+ chunk = bytes[mainLength]
23
+ a = (chunk & 252) >> 2
24
+ b = (chunk & 3) << 4
25
+ base64 += encodings[a] + encodings[b] + '=='
26
+ }
27
+ else if (byteRemainder === 2) {
28
+ chunk = (bytes[mainLength] << 8) | bytes[mainLength + 1]
29
+ a = (chunk & 64512) >> 10
30
+ b = (chunk & 1008) >> 4
31
+ c = (chunk & 15) << 2
32
+ base64 += encodings[a] + encodings[b] + encodings[c] + '='
33
+ }
34
+
35
+ return base64
36
+ }
37
+
38
+ export function extractFileExtension(filename) {
39
+ return filename.substr((~-filename.lastIndexOf('.') >>> 0) + 2)
40
+ }
41
+
42
+ export function eachElement(node, doFunction) {
43
+ if (!node) return node
44
+
45
+ let result = ''
46
+ if (node.constructor === Array) {
47
+ for (let i = 0; i < node.length; i++) {
48
+ result += doFunction(node[i], i)
49
+ }
50
+ }
51
+ else result += doFunction(node, 0)
52
+
53
+ return result
54
+ }
55
+
56
+ export function getTextByPathList(node, path) {
57
+ if (path.constructor !== Array) throw Error('Error of path type! path is not array.')
58
+
59
+ if (!node) return node
60
+
61
+ for (const key of path) {
62
+ node = node[key]
63
+ if (!node) return node
64
+ }
65
+
66
+ return node
67
+ }
68
+
69
+ export function angleToDegrees(angle) {
70
+ if (!angle) return 0
71
+ return Math.round(angle / 60000)
72
+ }
package/test.pptx ADDED
Binary file