Add eslint & update README

This commit is contained in:
Jerome Wu 2019-10-23 20:46:03 +08:00
parent 31b4857437
commit 26aed33e69
12 changed files with 1526 additions and 13 deletions

6
.eslintrc Normal file
View File

@ -0,0 +1,6 @@
{
"extends": "airbnb-base",
"rules": {
"no-underscore-dangle": 0
}
}

View File

@ -1,2 +1,4 @@
.eslintrc
.github
tests
examples

View File

@ -1,6 +1,10 @@
FFmpeg.js
=========
<p align="center">
<a href="#"><img alt="Tesseract.js" src="https://github.com/naptha/tesseract.js/raw/master/docs/images/cover.png"></a>
</p>
A FFmpeg WebAssembly version built from scratch, you can learn how to do it from this series of stories: [Build FFmpeg WebAssembly version (=ffmpeg.js)](https://medium.com/@jeromewus/build-ffmpeg-webassembly-version-ffmpeg-js-part-1-preparation-ed12bf4c8fac).
---

BIN
docs/images/cover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

1495
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,8 @@
"example": "examples"
},
"scripts": {
"test": "mocha"
"test": "mocha",
"lint": "eslint src"
},
"repository": {
"type": "git",
@ -26,5 +27,10 @@
"homepage": "https://github.com/jeromewu/ffmpeg.js#readme",
"dependencies": {
"@ffmpeg/core": "^0.1.0"
},
"devDependencies": {
"eslint": "^6.1.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2"
}
}

View File

@ -1,8 +1,8 @@
const { setModule } = require('./util/module');
const FFmpegCore = require('@ffmpeg/core');
const { setModule } = require('./util/module');
module.exports = () => (
new Promise((resolve, reject) => {
new Promise((resolve) => {
FFmpegCore()
.then((Module) => {
setModule(Module);

View File

@ -4,7 +4,7 @@ const getFFmpeg = require('./util/getFFmpeg');
const strList2ptr = require('./util/strList2ptr');
const defaultArgs = require('./constants/defaultArgs');
module.exports = (inputPath, outputExt, options='') => {
module.exports = (inputPath, outputExt, options = '') => {
const Module = getModule();
const data = new Uint8Array(fs.readFileSync(inputPath));
const iPath = `file.${inputPath.split('.').pop()}`;

View File

@ -1,6 +1,6 @@
let Module = null;
exports.setModule = m => {
exports.setModule = (m) => {
Module = m;
};

View File

@ -2,10 +2,10 @@ const { getModule } = require('./module');
module.exports = (s) => {
const Module = getModule();
const ptr = Module._malloc((s.length+1)*Uint8Array.BYTES_PER_ELEMENT);
for (let i = 0; i < s.length; i++) {
Module.setValue(ptr+i, s.charCodeAt(i), 'i8');
const ptr = Module._malloc((s.length + 1) * Uint8Array.BYTES_PER_ELEMENT);
for (let i = 0; i < s.length; i += 1) {
Module.setValue(ptr + i, s.charCodeAt(i), 'i8');
}
Module.setValue(ptr+s.length, 0, 'i8');
Module.setValue(ptr + s.length, 0, 'i8');
return ptr;
};

View File

@ -3,11 +3,11 @@ const str2ptr = require('./str2ptr');
module.exports = (strList) => {
const Module = getModule();
const listPtr = Module._malloc(strList.length*Uint32Array.BYTES_PER_ELEMENT);
const listPtr = Module._malloc(strList.length * Uint32Array.BYTES_PER_ELEMENT);
strList.forEach((s, idx) => {
const strPtr = str2ptr(s);
Module.setValue(listPtr + (4*idx), strPtr, 'i32');
Module.setValue(listPtr + (4 * idx), strPtr, 'i32');
});
return listPtr;