-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
450 additions
and
19 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,18 +4,19 @@ | |
* https://github.com/alimilhim/woff2-wasm | ||
* @author mengke01([email protected]) | ||
*/ | ||
/* eslint-disable fecs-camel-case */ | ||
|
||
function convertFromVecToUint8Array(vector) { | ||
let arr = []; | ||
const arr = []; | ||
for (let i = 0, l = vector.size(); i < l; i++) { | ||
arr.push(vector.get(i)); | ||
} | ||
return new Uint8Array(arr); | ||
} | ||
|
||
|
||
// eslint-disable-next-line import/no-commonjs | ||
module.exports = { | ||
|
||
woff2Module: null, | ||
|
||
/** | ||
|
@@ -36,7 +37,7 @@ module.exports = { | |
* @return {Promise} | ||
*/ | ||
init(wasmUrl) { | ||
return new Promise((resolve, reject) => { | ||
return new Promise(resolve => { | ||
if (this.woff2Module) { | ||
resolve(this); | ||
return; | ||
|
@@ -76,7 +77,7 @@ module.exports = { | |
* @return {Uint8Array} uint8 array | ||
*/ | ||
encode(ttfBuffer) { | ||
let buffer = new Uint8Array(ttfBuffer); | ||
const buffer = new Uint8Array(ttfBuffer); | ||
const woffbuff = this.woff2Module.woff2Enc(buffer, buffer.byteLength); | ||
return convertFromVecToUint8Array(woffbuff); | ||
}, | ||
|
@@ -88,7 +89,7 @@ module.exports = { | |
* @return {Uint8Array} uint8 array | ||
*/ | ||
decode(woff2Buffer) { | ||
let buffer = new Uint8Array(woff2Buffer); | ||
const buffer = new Uint8Array(woff2Buffer); | ||
const ttfbuff = this.woff2Module.woff2Dec(buffer, buffer.byteLength); | ||
return convertFromVecToUint8Array(ttfbuff); | ||
} | ||
|