@ch20026103/anysis 0.0.6-alpha → 0.0.8-alpha
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/dist/cjs/analyze/Slope/index.d.ts +1 -1
- package/dist/cjs/analyze/Slope/index.js +2 -1
- package/dist/cjs/analyze/Slope/slope.test.js +5 -10
- package/dist/cjs/index.d.ts +5 -3
- package/dist/cjs/index.js +11 -7
- package/dist/cjs/utils/isJson.d.ts +1 -0
- package/dist/cjs/utils/isJson.js +12 -0
- package/dist/cjs/utils/isJson.test.d.ts +1 -0
- package/dist/cjs/utils/isJson.test.js +20 -0
- package/dist/cjs/utils/parseLsusbOutput.d.ts +6 -0
- package/dist/cjs/utils/parseLsusbOutput.js +20 -0
- package/dist/cjs/utils/parseLsusbOutput.test.d.ts +1 -0
- package/dist/cjs/utils/parseLsusbOutput.test.js +23 -0
- package/dist/esm/analyze/Slope/index.d.ts +1 -1
- package/dist/esm/analyze/Slope/index.js +2 -1
- package/dist/esm/analyze/Slope/slope.test.js +5 -10
- package/dist/esm/index.d.ts +5 -3
- package/dist/esm/index.js +5 -3
- package/dist/esm/utils/isJson.d.ts +1 -0
- package/dist/esm/utils/isJson.js +9 -0
- package/dist/esm/utils/isJson.test.d.ts +1 -0
- package/dist/esm/utils/isJson.test.js +18 -0
- package/dist/esm/utils/parseLsusbOutput.d.ts +6 -0
- package/dist/esm/utils/parseLsusbOutput.js +17 -0
- package/dist/esm/utils/parseLsusbOutput.test.d.ts +1 -0
- package/dist/esm/utils/parseLsusbOutput.test.js +21 -0
- package/dist/umd/index.js +307 -276
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function Slope(
|
|
1
|
+
export default function Slope(y: number[]): number;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function Slope(
|
|
3
|
+
function Slope(y) {
|
|
4
4
|
// 計算 x 和 y 的平均值
|
|
5
|
+
var x = Array.from({ length: y.length }, function (_, k) { return k + 1; });
|
|
5
6
|
var x_mean = x.reduce(function (acc, cur) { return acc + cur; }) / x.length;
|
|
6
7
|
var y_mean = y.reduce(function (acc, cur) { return acc + cur; }) / y.length;
|
|
7
8
|
// 計算斜率
|
|
@@ -3,33 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
var index_1 = require("./index");
|
|
4
4
|
describe("test Slope methods", function () {
|
|
5
5
|
it("test 123456", function () {
|
|
6
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
7
6
|
var y = [1, 2, 3, 4, 5, 6];
|
|
8
|
-
var slope = (0, index_1.default)(
|
|
7
|
+
var slope = (0, index_1.default)(y);
|
|
9
8
|
expect(slope).toEqual(1);
|
|
10
9
|
});
|
|
11
10
|
it("test -123456", function () {
|
|
12
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
13
11
|
var y = [-1, -2, -3, -4, -5, -6];
|
|
14
|
-
var slope = (0, index_1.default)(
|
|
12
|
+
var slope = (0, index_1.default)(y);
|
|
15
13
|
expect(slope).toEqual(-1);
|
|
16
14
|
});
|
|
17
15
|
it("test 654321", function () {
|
|
18
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
19
16
|
var y = [6, 5, 4, 3, 2, 1];
|
|
20
|
-
var slope = (0, index_1.default)(
|
|
17
|
+
var slope = (0, index_1.default)(y);
|
|
21
18
|
expect(slope).toEqual(-1);
|
|
22
19
|
});
|
|
23
20
|
it("test 222222", function () {
|
|
24
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
25
21
|
var y = [2, 2, 2, 2, 2, 2];
|
|
26
|
-
var slope = (0, index_1.default)(
|
|
22
|
+
var slope = (0, index_1.default)(y);
|
|
27
23
|
expect(slope).toEqual(0);
|
|
28
24
|
});
|
|
29
25
|
it("test 1,4,6,8,10,12", function () {
|
|
30
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
31
26
|
var y = [1, 4, 6, 8, 10, 12];
|
|
32
|
-
var slope = (0, index_1.default)(
|
|
27
|
+
var slope = (0, index_1.default)(y);
|
|
33
28
|
expect(slope).toEqual(2.142857142857143);
|
|
34
29
|
});
|
|
35
30
|
});
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -2,16 +2,18 @@ export { default as simpleRegressionModel } from "./analyze/Regression/simpleReg
|
|
|
2
2
|
export { default as slope } from "./analyze/Slope/index.js";
|
|
3
3
|
export { exponentialSmoothing, movingAverages, weightMovingAverages, } from "./analyze/TimeSeries/R/index.js";
|
|
4
4
|
export { calcSeasonalIndicesNoTrend } from "./analyze/TimeSeries/RS/index.js";
|
|
5
|
+
export { default as Boll } from "./stockSkills/boll.js";
|
|
6
|
+
export { default as Ema } from "./stockSkills/ema.js";
|
|
5
7
|
export { default as Gold } from "./stockSkills/gold.js";
|
|
6
8
|
export { default as Kd } from "./stockSkills/kd.js";
|
|
7
9
|
export { default as Ma } from "./stockSkills/ma.js";
|
|
8
10
|
export { default as Macd } from "./stockSkills/macd.js";
|
|
9
|
-
export { default as Rsi } from "./stockSkills/rsi.js";
|
|
10
11
|
export { default as Obv } from "./stockSkills/obv.js";
|
|
11
|
-
export { default as
|
|
12
|
+
export { default as Rsi } from "./stockSkills/rsi.js";
|
|
12
13
|
export { default as dateFormat } from "./stockSkills/utils/dateFormat.js";
|
|
13
14
|
export { default as getWeekLine } from "./stockSkills/utils/getWeekLine.js";
|
|
14
15
|
export { default as Williams } from "./stockSkills/williams.js";
|
|
15
|
-
export { default as Boll } from "./stockSkills/boll.js";
|
|
16
16
|
export { add } from "./test/add.js";
|
|
17
17
|
export { minus } from "./test/minus.js";
|
|
18
|
+
export { default as isJSON } from "./utils/isJson.js";
|
|
19
|
+
export { default as parseLsusbOutput } from "./utils/parseLsusbOutput.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.parseLsusbOutput = exports.isJSON = exports.minus = exports.add = exports.Williams = exports.getWeekLine = exports.dateFormat = exports.Rsi = exports.Obv = exports.Macd = exports.Ma = exports.Kd = exports.Gold = exports.Ema = exports.Boll = exports.calcSeasonalIndicesNoTrend = exports.weightMovingAverages = exports.movingAverages = exports.exponentialSmoothing = exports.slope = exports.simpleRegressionModel = void 0;
|
|
4
4
|
/*
|
|
5
5
|
請注意,在 src/index.ts 中,我的導入包含文件擴展名(.js)。
|
|
6
6
|
如果需要支持 Node.js 和構建工具(ex: webpack),則不需要這樣做。 **因為commonJs默認js副檔名**
|
|
@@ -16,6 +16,10 @@ Object.defineProperty(exports, "movingAverages", { enumerable: true, get: functi
|
|
|
16
16
|
Object.defineProperty(exports, "weightMovingAverages", { enumerable: true, get: function () { return index_js_2.weightMovingAverages; } });
|
|
17
17
|
var index_js_3 = require("./analyze/TimeSeries/RS/index.js");
|
|
18
18
|
Object.defineProperty(exports, "calcSeasonalIndicesNoTrend", { enumerable: true, get: function () { return index_js_3.calcSeasonalIndicesNoTrend; } });
|
|
19
|
+
var boll_js_1 = require("./stockSkills/boll.js");
|
|
20
|
+
Object.defineProperty(exports, "Boll", { enumerable: true, get: function () { return boll_js_1.default; } });
|
|
21
|
+
var ema_js_1 = require("./stockSkills/ema.js");
|
|
22
|
+
Object.defineProperty(exports, "Ema", { enumerable: true, get: function () { return ema_js_1.default; } });
|
|
19
23
|
var gold_js_1 = require("./stockSkills/gold.js");
|
|
20
24
|
Object.defineProperty(exports, "Gold", { enumerable: true, get: function () { return gold_js_1.default; } });
|
|
21
25
|
var kd_js_1 = require("./stockSkills/kd.js");
|
|
@@ -24,21 +28,21 @@ var ma_js_1 = require("./stockSkills/ma.js");
|
|
|
24
28
|
Object.defineProperty(exports, "Ma", { enumerable: true, get: function () { return ma_js_1.default; } });
|
|
25
29
|
var macd_js_1 = require("./stockSkills/macd.js");
|
|
26
30
|
Object.defineProperty(exports, "Macd", { enumerable: true, get: function () { return macd_js_1.default; } });
|
|
27
|
-
var rsi_js_1 = require("./stockSkills/rsi.js");
|
|
28
|
-
Object.defineProperty(exports, "Rsi", { enumerable: true, get: function () { return rsi_js_1.default; } });
|
|
29
31
|
var obv_js_1 = require("./stockSkills/obv.js");
|
|
30
32
|
Object.defineProperty(exports, "Obv", { enumerable: true, get: function () { return obv_js_1.default; } });
|
|
31
|
-
var
|
|
32
|
-
Object.defineProperty(exports, "
|
|
33
|
+
var rsi_js_1 = require("./stockSkills/rsi.js");
|
|
34
|
+
Object.defineProperty(exports, "Rsi", { enumerable: true, get: function () { return rsi_js_1.default; } });
|
|
33
35
|
var dateFormat_js_1 = require("./stockSkills/utils/dateFormat.js");
|
|
34
36
|
Object.defineProperty(exports, "dateFormat", { enumerable: true, get: function () { return dateFormat_js_1.default; } });
|
|
35
37
|
var getWeekLine_js_1 = require("./stockSkills/utils/getWeekLine.js");
|
|
36
38
|
Object.defineProperty(exports, "getWeekLine", { enumerable: true, get: function () { return getWeekLine_js_1.default; } });
|
|
37
39
|
var williams_js_1 = require("./stockSkills/williams.js");
|
|
38
40
|
Object.defineProperty(exports, "Williams", { enumerable: true, get: function () { return williams_js_1.default; } });
|
|
39
|
-
var boll_js_1 = require("./stockSkills/boll.js");
|
|
40
|
-
Object.defineProperty(exports, "Boll", { enumerable: true, get: function () { return boll_js_1.default; } });
|
|
41
41
|
var add_js_1 = require("./test/add.js");
|
|
42
42
|
Object.defineProperty(exports, "add", { enumerable: true, get: function () { return add_js_1.add; } });
|
|
43
43
|
var minus_js_1 = require("./test/minus.js");
|
|
44
44
|
Object.defineProperty(exports, "minus", { enumerable: true, get: function () { return minus_js_1.minus; } });
|
|
45
|
+
var isJson_js_1 = require("./utils/isJson.js");
|
|
46
|
+
Object.defineProperty(exports, "isJSON", { enumerable: true, get: function () { return isJson_js_1.default; } });
|
|
47
|
+
var parseLsusbOutput_js_1 = require("./utils/parseLsusbOutput.js");
|
|
48
|
+
Object.defineProperty(exports, "parseLsusbOutput", { enumerable: true, get: function () { return parseLsusbOutput_js_1.default; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isJSON(str: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var isJson_1 = require("./isJson");
|
|
4
|
+
describe("test isJSON methods", function () {
|
|
5
|
+
it("test {}", function () {
|
|
6
|
+
var text = "{}";
|
|
7
|
+
var json = (0, isJson_1.default)(text);
|
|
8
|
+
expect(json).toEqual(true);
|
|
9
|
+
});
|
|
10
|
+
it("test [{}]", function () {
|
|
11
|
+
var text = "[{}]";
|
|
12
|
+
var json = (0, isJson_1.default)(text);
|
|
13
|
+
expect(json).toEqual(true);
|
|
14
|
+
});
|
|
15
|
+
it("test [{}]);", function () {
|
|
16
|
+
var text = "[{}]);";
|
|
17
|
+
var json = (0, isJson_1.default)(text);
|
|
18
|
+
expect(json).toEqual(false);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function parseLsusbOutput(output) {
|
|
4
|
+
var lines = output.trim().split("\n");
|
|
5
|
+
var devices = lines
|
|
6
|
+
.map(function (line) {
|
|
7
|
+
var match = line.match(/Bus (\d+) Device (\d+): ID ([a-f0-9]+:[a-f0-9]+) (.+)/);
|
|
8
|
+
if (match) {
|
|
9
|
+
var bus = match[1];
|
|
10
|
+
var device = match[2];
|
|
11
|
+
var id = match[3];
|
|
12
|
+
var description = match[4];
|
|
13
|
+
return { bus: bus, device: device, id: id, description: description };
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
})
|
|
17
|
+
.filter(function (device) { return device !== null; });
|
|
18
|
+
return devices;
|
|
19
|
+
}
|
|
20
|
+
exports.default = parseLsusbOutput;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var parseLsusbOutput_1 = require("./parseLsusbOutput");
|
|
4
|
+
describe("test parseLsusbOutput methods", function () {
|
|
5
|
+
it("test case1", function () {
|
|
6
|
+
var lsusbOutput = "\n Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub\n Bus 001 Device 003: ID 0c45:64ad Microdia \n ";
|
|
7
|
+
var arr = (0, parseLsusbOutput_1.default)(lsusbOutput);
|
|
8
|
+
expect(arr).toEqual([
|
|
9
|
+
{
|
|
10
|
+
bus: "001",
|
|
11
|
+
device: "002",
|
|
12
|
+
id: "8087:0024",
|
|
13
|
+
description: "Intel Corp. Integrated Rate Matching Hub",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
bus: "001",
|
|
17
|
+
device: "003",
|
|
18
|
+
id: "0c45:64ad",
|
|
19
|
+
description: "Microdia",
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function Slope(
|
|
1
|
+
export default function Slope(y: number[]): number;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export default function Slope(
|
|
1
|
+
export default function Slope(y) {
|
|
2
2
|
// 計算 x 和 y 的平均值
|
|
3
|
+
var x = Array.from({ length: y.length }, function (_, k) { return k + 1; });
|
|
3
4
|
var x_mean = x.reduce(function (acc, cur) { return acc + cur; }) / x.length;
|
|
4
5
|
var y_mean = y.reduce(function (acc, cur) { return acc + cur; }) / y.length;
|
|
5
6
|
// 計算斜率
|
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
import Slope from "./index";
|
|
2
2
|
describe("test Slope methods", function () {
|
|
3
3
|
it("test 123456", function () {
|
|
4
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
5
4
|
var y = [1, 2, 3, 4, 5, 6];
|
|
6
|
-
var slope = Slope(
|
|
5
|
+
var slope = Slope(y);
|
|
7
6
|
expect(slope).toEqual(1);
|
|
8
7
|
});
|
|
9
8
|
it("test -123456", function () {
|
|
10
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
11
9
|
var y = [-1, -2, -3, -4, -5, -6];
|
|
12
|
-
var slope = Slope(
|
|
10
|
+
var slope = Slope(y);
|
|
13
11
|
expect(slope).toEqual(-1);
|
|
14
12
|
});
|
|
15
13
|
it("test 654321", function () {
|
|
16
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
17
14
|
var y = [6, 5, 4, 3, 2, 1];
|
|
18
|
-
var slope = Slope(
|
|
15
|
+
var slope = Slope(y);
|
|
19
16
|
expect(slope).toEqual(-1);
|
|
20
17
|
});
|
|
21
18
|
it("test 222222", function () {
|
|
22
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
23
19
|
var y = [2, 2, 2, 2, 2, 2];
|
|
24
|
-
var slope = Slope(
|
|
20
|
+
var slope = Slope(y);
|
|
25
21
|
expect(slope).toEqual(0);
|
|
26
22
|
});
|
|
27
23
|
it("test 1,4,6,8,10,12", function () {
|
|
28
|
-
var x = [1, 2, 3, 4, 5, 6];
|
|
29
24
|
var y = [1, 4, 6, 8, 10, 12];
|
|
30
|
-
var slope = Slope(
|
|
25
|
+
var slope = Slope(y);
|
|
31
26
|
expect(slope).toEqual(2.142857142857143);
|
|
32
27
|
});
|
|
33
28
|
});
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -2,16 +2,18 @@ export { default as simpleRegressionModel } from "./analyze/Regression/simpleReg
|
|
|
2
2
|
export { default as slope } from "./analyze/Slope/index.js";
|
|
3
3
|
export { exponentialSmoothing, movingAverages, weightMovingAverages, } from "./analyze/TimeSeries/R/index.js";
|
|
4
4
|
export { calcSeasonalIndicesNoTrend } from "./analyze/TimeSeries/RS/index.js";
|
|
5
|
+
export { default as Boll } from "./stockSkills/boll.js";
|
|
6
|
+
export { default as Ema } from "./stockSkills/ema.js";
|
|
5
7
|
export { default as Gold } from "./stockSkills/gold.js";
|
|
6
8
|
export { default as Kd } from "./stockSkills/kd.js";
|
|
7
9
|
export { default as Ma } from "./stockSkills/ma.js";
|
|
8
10
|
export { default as Macd } from "./stockSkills/macd.js";
|
|
9
|
-
export { default as Rsi } from "./stockSkills/rsi.js";
|
|
10
11
|
export { default as Obv } from "./stockSkills/obv.js";
|
|
11
|
-
export { default as
|
|
12
|
+
export { default as Rsi } from "./stockSkills/rsi.js";
|
|
12
13
|
export { default as dateFormat } from "./stockSkills/utils/dateFormat.js";
|
|
13
14
|
export { default as getWeekLine } from "./stockSkills/utils/getWeekLine.js";
|
|
14
15
|
export { default as Williams } from "./stockSkills/williams.js";
|
|
15
|
-
export { default as Boll } from "./stockSkills/boll.js";
|
|
16
16
|
export { add } from "./test/add.js";
|
|
17
17
|
export { minus } from "./test/minus.js";
|
|
18
|
+
export { default as isJSON } from "./utils/isJson.js";
|
|
19
|
+
export { default as parseLsusbOutput } from "./utils/parseLsusbOutput.js";
|
package/dist/esm/index.js
CHANGED
|
@@ -7,16 +7,18 @@ export { default as simpleRegressionModel } from "./analyze/Regression/simpleReg
|
|
|
7
7
|
export { default as slope } from "./analyze/Slope/index.js";
|
|
8
8
|
export { exponentialSmoothing, movingAverages, weightMovingAverages, } from "./analyze/TimeSeries/R/index.js";
|
|
9
9
|
export { calcSeasonalIndicesNoTrend } from "./analyze/TimeSeries/RS/index.js";
|
|
10
|
+
export { default as Boll } from "./stockSkills/boll.js";
|
|
11
|
+
export { default as Ema } from "./stockSkills/ema.js";
|
|
10
12
|
export { default as Gold } from "./stockSkills/gold.js";
|
|
11
13
|
export { default as Kd } from "./stockSkills/kd.js";
|
|
12
14
|
export { default as Ma } from "./stockSkills/ma.js";
|
|
13
15
|
export { default as Macd } from "./stockSkills/macd.js";
|
|
14
|
-
export { default as Rsi } from "./stockSkills/rsi.js";
|
|
15
16
|
export { default as Obv } from "./stockSkills/obv.js";
|
|
16
|
-
export { default as
|
|
17
|
+
export { default as Rsi } from "./stockSkills/rsi.js";
|
|
17
18
|
export { default as dateFormat } from "./stockSkills/utils/dateFormat.js";
|
|
18
19
|
export { default as getWeekLine } from "./stockSkills/utils/getWeekLine.js";
|
|
19
20
|
export { default as Williams } from "./stockSkills/williams.js";
|
|
20
|
-
export { default as Boll } from "./stockSkills/boll.js";
|
|
21
21
|
export { add } from "./test/add.js";
|
|
22
22
|
export { minus } from "./test/minus.js";
|
|
23
|
+
export { default as isJSON } from "./utils/isJson.js";
|
|
24
|
+
export { default as parseLsusbOutput } from "./utils/parseLsusbOutput.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function isJSON(str: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import isJSON from "./isJson";
|
|
2
|
+
describe("test isJSON methods", function () {
|
|
3
|
+
it("test {}", function () {
|
|
4
|
+
var text = "{}";
|
|
5
|
+
var json = isJSON(text);
|
|
6
|
+
expect(json).toEqual(true);
|
|
7
|
+
});
|
|
8
|
+
it("test [{}]", function () {
|
|
9
|
+
var text = "[{}]";
|
|
10
|
+
var json = isJSON(text);
|
|
11
|
+
expect(json).toEqual(true);
|
|
12
|
+
});
|
|
13
|
+
it("test [{}]);", function () {
|
|
14
|
+
var text = "[{}]);";
|
|
15
|
+
var json = isJSON(text);
|
|
16
|
+
expect(json).toEqual(false);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default function parseLsusbOutput(output) {
|
|
2
|
+
var lines = output.trim().split("\n");
|
|
3
|
+
var devices = lines
|
|
4
|
+
.map(function (line) {
|
|
5
|
+
var match = line.match(/Bus (\d+) Device (\d+): ID ([a-f0-9]+:[a-f0-9]+) (.+)/);
|
|
6
|
+
if (match) {
|
|
7
|
+
var bus = match[1];
|
|
8
|
+
var device = match[2];
|
|
9
|
+
var id = match[3];
|
|
10
|
+
var description = match[4];
|
|
11
|
+
return { bus: bus, device: device, id: id, description: description };
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
})
|
|
15
|
+
.filter(function (device) { return device !== null; });
|
|
16
|
+
return devices;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import parseLsusbOutput from "./parseLsusbOutput";
|
|
2
|
+
describe("test parseLsusbOutput methods", function () {
|
|
3
|
+
it("test case1", function () {
|
|
4
|
+
var lsusbOutput = "\n Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub\n Bus 001 Device 003: ID 0c45:64ad Microdia \n ";
|
|
5
|
+
var arr = parseLsusbOutput(lsusbOutput);
|
|
6
|
+
expect(arr).toEqual([
|
|
7
|
+
{
|
|
8
|
+
bus: "001",
|
|
9
|
+
device: "002",
|
|
10
|
+
id: "8087:0024",
|
|
11
|
+
description: "Intel Corp. Integrated Rate Matching Hub",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
bus: "001",
|
|
15
|
+
device: "003",
|
|
16
|
+
id: "0c45:64ad",
|
|
17
|
+
description: "Microdia",
|
|
18
|
+
},
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
});
|